Index: build/Jamfile.v2 =================================================================== --- build/Jamfile.v2 (revision 68347) +++ build/Jamfile.v2 (working copy) @@ -1,30 +1,24 @@ import quickbook ; import modules ; +import os ; -local boost = [ modules.peek : BOOST ] ; - -exe auto_index : - ../src/auto_index.cpp - ../src/file_scanning.cpp - ../src/index_generator.cpp - ../src/tiny_xml.cpp - $(boost)/libs/regex/build//boost_regex - $(boost)/libs/filesystem/build//boost_filesystem - $(boost)/libs/system/build//boost_system -: BOOST_ALL_NO_LIB=1 static ; - -install aii : auto_index : . ; -install ai2 : ../auto-index.jam : $(boost)/tools/build/v2/tools ; - - - - - - - - - - +local BOOST_ROOT = [ os.environ BOOST_ROOT ] ; +use-project /boost : $(BOOST_ROOT) ; +project + : build-dir $(BOOST_ROOT)/bin.v2 + ; + +exe auto_index + : ../src/auto_index.cpp + ../src/file_scanning.cpp + ../src/index_generator.cpp + ../src/tiny_xml.cpp + /boost//system + /boost//filesystem + /boost//regex + : BOOST_ALL_NO_LIB=1 + static + ; Index: doc/auto_index.qbk =================================================================== --- doc/auto_index.qbk (revision 68347) +++ doc/auto_index.qbk (working copy) @@ -17,7 +17,7 @@ Traditionally, in order to index a Docbook document you would have to manually add a large amount of `` markup: -in fact one `` for each occurance of each term to be +in fact one `` for each occurrence of each term to be indexed. Instead AutoIndex will scan one or more C\/C++ header files @@ -25,7 +25,7 @@ names that are defined by those headers, and then insert the ``'s into the XML document for you. -AutoIndex creates index entries as follows - for each occurance of +AutoIndex creates index entries as follows - for each occurrence of each search term, it creates two index entries - one has the search term as the primary index key and the title of the section it appears in as a subterm, the other has the section title as the main index entry and the @@ -55,7 +55,7 @@ AutoIndex also supports multiple indexes (as does Docbook), and since it knows which search terms are ['function], ['class], ['macro] or ['typedef] names, it -can add the necessary attritubes to the XML so that you can have separate +can add the necessary attributes to the XML so that you can have separate indexes for each of these different types. These specialised indexes only contain entries for the ['function], ['class], ['macro] or ['typedef] names, ['section names] are never used as primary index terms here, unlike the main "include everything" @@ -67,7 +67,7 @@ as index entries this leads to a lot of repetition, so as an alternative AutoIndex can be instructed to construct the index itself. This is faster than using the XSL stylesheets, and now each index entry is a hyperlink to the -approprate section: +appropriate section: [$../students_t_eg_3.png] @@ -78,7 +78,7 @@ Finally, you can choose what kind of XML container wraps an internally generated index - this defaults to `
...
` but you can use either command line options -or bjam Jamfile features, to select an alternative wrapper - for example "appendix" +or Boost.Build features, to select an alternative wrapper - for example "appendix" or "chapter" would be good choices, whatever fits best into the flow of the document. You can even set the container wrapper to type "index" provided you turn off index generation by the XSL stylesheets, for example by setting the following @@ -226,7 +226,7 @@ '''''' -If you are using auto-index's internal index generation (usually recomended for HTML output) +If you are using auto-index's internal index generation (usually recommended for HTML output) then you can also decide what kind of XML wrapper the generated index is placed in. By default this is a `
...
` XML block (this replaces the original `...` block). However, depending upon the structure of the document @@ -295,7 +295,7 @@ foobar -will index occurances of "foobar" and: +will index occurrences of "foobar" and: foobar \<\w*(foo|bar)\w*\> @@ -305,14 +305,14 @@ reflex -Will only index occurances of "reflex" as a whole word, but: +Will only index occurrences of "reflex" as a whole word, but: reflex \ -will index occurances of "reflex", reflexing" and +will index occurrences of "reflex", reflexing" and "reflexed" all under the same entry ['reflex]. -This inclusion rule can also restict the term to +This inclusion rule can also restrict the term to certain sections, and add an index category that the term should belong to (so it only appears in certain indexes). @@ -393,34 +393,34 @@ also will be used as a secondary entry beneath each of the section titles that the term occurs in.]] -[[regular-expression1][An optional regular expression: each occurance +[[regular-expression1][An optional regular expression: each occurrence of the regular expression in the text of the document will result in one index term being emitted. If the regular expression is omitted or is "", then the ['term] itself -will be used as the search text - and only occurance of whole words matching +will be used as the search text - and only occurrence of whole words matching ['term] will be indexed.]] [[regular-expression2][A constraint that specifies which sections are indexed for ['term]: only if the ID of the section matches -['regular-expression2] exactly will that section be indexed for occurances +['regular-expression2] exactly will that section be indexed for occurrences of ['term]. For example: `myclass "" "mylib.examples.*"` -Will index occurances of "myclass" as a whole word only in sections +Will index occurrences of "myclass" as a whole word only in sections whose ID begins "mylib.examples", while: `myclass "" "(?!mylib.introduction.*).*"` -will index occurances of "myclass" in any section, except those whose +will index occurrences of "myclass" in any section, except those whose ID's begin "mylib.introduction". If this field is omitted or is "", then all sections are indexed for this term.]] -[[category][Optionally an index category to place occurances of +[[category][Optionally an index category to place occurrences of ['term] in. If you have multiple indexes then this is the name assigned to the indexes "type" attribute. ]] @@ -439,7 +439,7 @@ in a specialised index whose "type" attribute has the same category name. [important -When actually indexing a document, the scanner will not index just any old occurance of the +When actually indexing a document, the scanner will not index just any old occurrence of the terms found in the source files. Instead it searches for class definitions or function or typedef declarations. This reduces the number of spurious matches placed in the index, but may also miss some legitimate terms: refer to the /define-scanner/ command for information on how to @@ -458,7 +458,7 @@ [[file-name-regex][A regular expression: any file in the directory whose name matches the regular expression will be scanned for terms to index.]] -[[recurse][An optional boolian value - either "true" or "false" - that +[[recurse][An optional boolean value - either "true" or "false" - that indicates whether to recurse into subdirectories. This defaults to "false"]] ] @@ -519,11 +519,11 @@ a match against this expression will be transformed by the next two arguments.]] [[xml-regex-formatter][A regular expression format string that extracts the salient information from whatever matched the ['file-search-expression] in the source file, and creates ['a new regular expression] that will -be used to search the document being indexed for occurances of this index term.]] +be used to search the document being indexed for occurrences of this index term.]] [[term-formatter][A regular expression format string that extracts the salient information from whatever matched the ['file-search-expression] in the source file, and creates the index term that will appear in the index.]] -[[id-filter][Optional. A regular expression that resticts the section-id's that are searched in the document being indexed: +[[id-filter][Optional. A regular expression that restricts the section-id's that are searched in the document being indexed: only sections whose ID attribute matches this expression exactly will be considered for indexing terms found by this scanner.]] [[filename-filter][Optional. A regular expression that restricts which files are scanned by this scanner: only files whose file name matches this expression exactly will be scanned for index terms to use. Note that the filename matched against this may @@ -555,7 +555,7 @@ !define-scanner class_name "^[[:space:]]*(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\<\w+\>([[:blank:]]*\([^)]*\))?[[:space:]]*)*(\<\w*\>)[[:space:]]*(<[^;:{]+>)?[[:space:]]*(\{|:[^;\{()]*\{)" "\\<\5\\>" \5 -Will look for ['any] occurance of whatever class names the scanner may find in the documentation. +Will look for ['any] occurrence of whatever class names the scanner may find in the documentation. [h4 Debugging] Index: src/auto_index.cpp =================================================================== --- src/auto_index.cpp (revision 68347) +++ src/auto_index.cpp (working copy) @@ -165,7 +165,51 @@ { static const boost::array names = { - "abbrev", "accel", "ackno", "acronym", "action", "answer", "appendix", "appendixinfo", "application", "article", "articleinfo", "artpagenums", "attribution", "authorinitials", "bibliocoverage", "bibliodiv", "biblioentry", "bibliography", "bibliographyinfo", "biblioid", "bibliomisc", "bibliomixed", "bibliomset", "bibliorelation", "biblioset", "bibliosource", "blockinfo", "blockquote", "bookinfo", "bridgehead", "callout", "caution", "chapter", "chapterinfo", "citation", "citebiblioid", "citetitle", "city", "classname", "classsynopsisinfo", "code", "collabname", "command", "computeroutput", "confdates", "confnum", "confsponsor", "conftitle", "constant", "constraintdef", "contractnum", "contractsponsor", "contrib", "corpauthor", "corpcredit", "corpname", "country", "database", "date", "dedication", "edition", "email", "emphasis", "entry", "envar", "errorcode", "errorname", "errortext", "errortype", "example", "exceptionname", "fax", "figure", "filename", "firstname", "firstterm", "foreignphrase", "formalpara", "funcparams", "funcsynopsisinfo", "function", "glossary", "glossaryinfo", "glossdef", "glossdiv", "glossentry", "glosssee", "glossseealso", "glossterm", "guibutton", "guiicon", "guilabel", "guimenu", "guimenuitem", "guisubmenu", "hardware", "highlights", "holder", "honorific", "important", "index", "indexinfo", "informalexample", "informalfigure", "initializer", "interface", "interfacename", "invpartnumber", "isbn", "issn", "issuenum", "itemizedlist", "itermset", "jobtitle", "keycap", "keycode", "keysym", "label", "legalnotice", "lineage", "lineannotation", /*"link", */"listitem", "literal", "literallayout", "lotentry", "manvolnum", "markup", "medialabel", "member", "methodname", "modespec", "modifier", "mousebutton", "msgaud", "msgexplan", "msglevel", "msgorig", "msgtext", "note", "objectinfo", "olink", "option", "optional", "orderedlist", "orgdiv", "orgname", "otheraddr", "othername", "package", "pagenums", "para", "parameter", "partinfo", "partintro", "phone", "phrase", "pob", "postcode", "preface", "prefaceinfo", "procedure", "productname", "productnumber", "programlisting", "prompt", "property", "pubdate", "publishername", "pubsnumber", "qandadiv", "qandaset", "question", "quote", "refentry", "refentryinfo", "refentrytitle", "referenceinfo", "refmeta", "refmiscinfo", "refpurpose", "refsect1", "refsect1info", "refsect2", "refsect2info", "refsect3", "refsect3info", "refsection", "refsectioninfo", "refsynopsisdiv", "refsynopsisdivinfo", "releaseinfo", "remark", "returnvalue", "revdescription", "revnumber", "revremark", "screen", "screeninfo", "sect1", "sect1info", "sect2", "sect2info", "sect3", "sect3info", "sect4", "sect4info", "sect5", "sect5info", "section", "sectioninfo", "seg", "segtitle", "seriesvolnums", "setindex", "setindexinfo", "setinfo", "sgmltag", "shortaffil", "sidebar", "sidebarinfo", "simpara", "simplesect", "state", "step", "street", "structfield", "structname", "subtitle", "surname", "symbol", "synopsis", "systemitem", "table", "task", "taskprerequisites", "taskrelated", "tasksummary", "td", "term", "termdef", "th", "tip", /*"title",*/ "titleabbrev", "tocback", "tocentry", "tocfront", "token", "type", "ulink", "uri", "userinput", "variablelist", "varname", "volumenum", "warning", "wordasword", "year" + "abbrev", "accel", "ackno", "acronym", "action", "answer", "appendix", + "appendixinfo", "application", "article", "articleinfo", "artpagenums", + "attribution", "authorinitials", "bibliocoverage", "bibliodiv", "biblioentry", + "bibliography", "bibliographyinfo", "biblioid", "bibliomisc", "bibliomixed", + "bibliomset", "bibliorelation", "biblioset", "bibliosource", "blockinfo", + "blockquote", "bookinfo", "bridgehead", "callout", "caution", "chapter", + "chapterinfo", "citation", "citebiblioid", "citetitle", "city", "classname", + "classsynopsisinfo", "code", "collabname", "command", "computeroutput", + "confdates", "confnum", "confsponsor", "conftitle", "constant", + "constraintdef", "contractnum", "contractsponsor", "contrib", "corpauthor", + "corpcredit", "corpname", "country", "database", "date", "dedication", + "edition", "email", "emphasis", "entry", "envar", "errorcode", "errorname", + "errortext", "errortype", "example", "exceptionname", "fax", "figure", + "filename", "firstname", "firstterm", "foreignphrase", "formalpara", + "funcparams", "funcsynopsisinfo", "function", "glossary", "glossaryinfo", + "glossdef", "glossdiv", "glossentry", "glosssee", "glossseealso", "glossterm", + "guibutton", "guiicon", "guilabel", "guimenu", "guimenuitem", "guisubmenu", + "hardware", "highlights", "holder", "honorific", "important", "index", + "indexinfo", "informalexample", "informalfigure", "initializer", "interface", + "interfacename", "invpartnumber", "isbn", "issn", "issuenum", "itemizedlist", + "itermset", "jobtitle", "keycap", "keycode", "keysym", "label", "legalnotice", + "lineage", "lineannotation", /*"link", */"listitem", "literal", + "literallayout", "lotentry", "manvolnum", "markup", "medialabel", "member", + "methodname", "modespec", "modifier", "mousebutton", "msgaud", "msgexplan", + "msglevel", "msgorig", "msgtext", "note", "objectinfo", "olink", "option", + "optional", "orderedlist", "orgdiv", "orgname", "otheraddr", "othername", + "package", "pagenums", "para", "parameter", "partinfo", "partintro", "phone", + "phrase", "pob", "postcode", "preface", "prefaceinfo", "procedure", + "productname", "productnumber", "programlisting", "prompt", "property", + "pubdate", "publishername", "pubsnumber", "qandadiv", "qandaset", "question", + "quote", "refentry", "refentryinfo", "refentrytitle", "referenceinfo", + "refmeta", "refmiscinfo", "refpurpose", "refsect1", "refsect1info", "refsect2", + "refsect2info", "refsect3", "refsect3info", "refsection", "refsectioninfo", + "refsynopsisdiv", "refsynopsisdivinfo", "releaseinfo", "remark", "returnvalue", + "revdescription", "revnumber", "revremark", "screen", "screeninfo", "sect1", + "sect1info", "sect2", "sect2info", "sect3", "sect3info", "sect4", "sect4info", + "sect5", "sect5info", "section", "sectioninfo", "seg", "segtitle", + "seriesvolnums", "setindex", "setindexinfo", "setinfo", "sgmltag", + "shortaffil", "sidebar", "sidebarinfo", "simpara", "simplesect", "state", + "step", "street", "structfield", "structname", "subtitle", "surname", "symbol", + "synopsis", "systemitem", "table", "task", "taskprerequisites", "taskrelated", + "tasksummary", "td", "term", "termdef", "th", "tip", /*"title",*/ + "titleabbrev", "tocback", "tocentry", "tocfront", "token", "type", "ulink", + "uri", "userinput", "variablelist", "varname", "volumenum", "warning", + "wordasword", "year" }; static std::set permitted; @@ -204,8 +248,8 @@ "informaltable", "equation", "example", "figure", "table", "msgset", "procedure", "sidebar", "qandaset", "task", "productionset", "constraintdef", "anchor", "bridgehead", "remark", "highlights", "abstract", "authorblurb", "epigraph" - /*"biblioentry", "bibliomixed", "callout", "glossentry", "listitem", "seg", "seglistitem", "member", - "term", */ + /*"biblioentry", "bibliomixed", "callout", "glossentry", "listitem", "seg", + "seglistitem", "member", "term", */ }; static std::set terminals; @@ -326,7 +370,8 @@ // We have something to index! found_terms.insert(item_index); - if(!debug.empty() && (regex_match(i->term, debug) || regex_match(rtitle, debug) || regex_match(simple_title, debug))) + if(!debug.empty() && (regex_match(i->term, debug) || + regex_match(rtitle, debug) || regex_match(simple_title, debug))) { std::cout << "Debug term found, in block with ID: " << *pid << std::endl; std::cout << "Current section title is: " << rtitle << std::endl; @@ -556,7 +601,7 @@ } else { - std::cerr << "Unrecognosed option " << argv[i] << std::endl; + std::cerr << "Unrecognised option " << argv[i] << std::endl; return 1; } } Index: src/file_scanning.cpp =================================================================== --- src/file_scanning.cpp (revision 68347) +++ src/file_scanning.cpp (working copy) @@ -42,8 +42,8 @@ "(<[^;:{]+>)?[[:space:]]*" // terminate in { or : "(\\{|:[^;\\{()]*\\{)", - - "(?:class|struct)[^;{]+\\\\<\\5\\\\>[^;{]+\\\\{", // Format string to create indexing regex. + // Format string to create indexing regex. + "(?:class|struct)[^;{]+\\\\<\\5\\\\>[^;{]+\\\\{", "\\5", // Format string to create index term. "", // Filter regex for section id's. "" // Filter regex for filenames. @@ -56,7 +56,8 @@ add_file_scanner( "typedef_name", // Index type "typedef[^;{}#]+?(\\w+)\\s*;", // scanner regex - "typedef[^;]+\\\\<\\1\\\\>\\\\s*;", // Format string to create indexing regex. + // Format string to create indexing regex. + "typedef[^;]+\\\\<\\1\\\\>\\\\s*;", "\\1", // Format string to create index term. "", // Filter regex for section id's. "" // Filter regex for filenames. @@ -82,7 +83,8 @@ add_file_scanner( "function_name", // Index type "\\w+\\s+(\\w+)\\s*\\([^\\)]*\\)\\s*[;{]", // scanner regex - "\\\\<\\\\w+\\\\>\\\\s+\\\\<\\1\\\\>\\\\s*\\\\([^;{]*\\\\)\\\\s*[;{]", // Format string to create indexing regex. + // Format string to create indexing regex. + "\\\\<\\\\w+\\\\>\\\\s+\\\\<\\1\\\\>\\\\s*\\\\([^;{]*\\\\)\\\\s*[;{]", "\\1", // Format string to create index term. "", // Filter regex for section id's. "" // Filter regex for filenames. @@ -119,7 +121,8 @@ std::ifstream is(file); load_file(text, is); - for(file_scanner_set_type::iterator pscan = file_scanner_set.begin(); pscan != file_scanner_set.end(); ++pscan) + for(file_scanner_set_type::iterator pscan = file_scanner_set.begin(); + pscan != file_scanner_set.end(); ++pscan) { bool need_debug = false; if(!debug.empty() && regex_match(pscan->type, ::debug)) @@ -170,14 +173,16 @@ // // Merge the search terms: // - const_cast(pos.first->search_text) = "(?:" + pos.first->search_text.str() + ")|(?:" + info.search_text.str() + ")"; + const_cast(pos.first->search_text) = + "(?:" + pos.first->search_text.str() + ")|(?:" + info.search_text.str() + ")"; } if(pos.first->search_id != info.search_id) { // // Merge the ID constraints: // - const_cast(pos.first->search_id) = "(?:" + pos.first->search_id.str() + ")|(?:" + info.search_id.str() + ")"; + const_cast(pos.first->search_id) = + "(?:" + pos.first->search_id.str() + ")|(?:" + info.search_id.str() + ")"; } } } @@ -337,7 +342,8 @@ } else if(regex_match(line, what, define_scanner_parser)) { - add_file_scanner(unquote(what.str(1)), unquote(what.str(2)), unquote(what.str(3)), unquote(what.str(4)), unquote(what.str(5)), unquote(what.str(6))); + add_file_scanner(unquote(what.str(1)), unquote(what.str(2)), unquote(what.str(3)), + unquote(what.str(4)), unquote(what.str(5)), unquote(what.str(6))); } else if(regex_match(line, what, scan_dir_parser)) { @@ -382,7 +388,8 @@ // Erase all entries that have a category in our scanner set, // plus any entry with no category at all: index_terms.erase(info); - for(file_scanner_set_type::iterator pscan = file_scanner_set.begin(); pscan != file_scanner_set.end(); ++pscan) + for(file_scanner_set_type::iterator pscan = file_scanner_set.begin(); + pscan != file_scanner_set.end(); ++pscan) { info.category = (*pscan).type; index_terms.erase(info); @@ -408,7 +415,8 @@ if(s.size()) info.search_text = boost::regex(s, boost::regex::icase|boost::regex::perl); else - info.search_text = boost::regex("\\<" + what.str(1) + "\\>", boost::regex::icase|boost::regex::perl); + info.search_text = boost::regex("\\<" + what.str(1) + "\\>", + boost::regex::icase|boost::regex::perl); s = unquote(what.str(3)); if(s.size()) @@ -423,14 +431,16 @@ // // Merge the search terms: // - const_cast(pos.first->search_text) = "(?:" + pos.first->search_text.str() + ")|(?:" + info.search_text.str() + ")"; + const_cast(pos.first->search_text) + = "(?:" + pos.first->search_text.str() + ")|(?:" + info.search_text.str() + ")"; } if(pos.first->search_id != info.search_id) { // // Merge the ID constraints: // - const_cast(pos.first->search_id) = "(?:" + pos.first->search_id.str() + ")|(?:" + info.search_id.str() + ")"; + const_cast(pos.first->search_id) + = "(?:" + pos.first->search_id.str() + ")|(?:" + info.search_id.str() + ")"; } } } Index: src/auto_index.hpp =================================================================== --- src/auto_index.hpp (revision 68347) +++ src/auto_index.hpp (working copy) @@ -61,9 +61,15 @@ bool preferred; // This entry is the preferred one for this key index_entry() : preferred(false) {} - index_entry(const std::string& k) : key(k), preferred(false) { sort_key = make_upper_key(key); } - index_entry(const std::string& k, const std::string& i) : key(k), id(i), preferred(false) { sort_key = make_upper_key(key); } - index_entry(const std::string& k, const std::string& i, const std::string& c) : key(k), id(i), category(c), preferred(false) { sort_key = make_upper_key(key); } + + index_entry(const std::string& k) : key(k), preferred(false) + { sort_key = make_upper_key(key); } + + index_entry(const std::string& k, const std::string& i) : + key(k), id(i), preferred(false) { sort_key = make_upper_key(key); } + + index_entry(const std::string& k, const std::string& i, const std::string& c) : + key(k), id(i), category(c), preferred(false) { sort_key = make_upper_key(key); } }; @@ -74,7 +80,8 @@ struct id_rewrite_rule { - bool base_on_id; // rewrite the title if "id" matches the section id, otherwise rewrite if title matches "id". + bool base_on_id; // rewrite the title if "id" matches the section id, + // otherwise rewrite if title matches "id". boost::regex id; // regex for the id or title to match std::string new_name; // either literal string or format string for the new name. @@ -115,7 +122,9 @@ extern file_scanner_set_type file_scanner_set; -inline void add_file_scanner(const std::string& type, const std::string& scanner, const std::string& format, const std::string& term_formatter, const std::string& id_filter, const std::string& file_filter) +inline void add_file_scanner(const std::string& type, const std::string& scanner, + const std::string& format, const std::string& term_formatter, + const std::string& id_filter, const std::string& file_filter) { file_scanner s; s.type = type; Index: src/tiny_xml.hpp =================================================================== --- src/tiny_xml.hpp (revision 68347) +++ src/tiny_xml.hpp (working copy) @@ -40,7 +40,7 @@ typedef std::list< attribute > attribute_list; class element - : private boost::noncopyable // because deep copy sematics would be required + : private boost::noncopyable // because deep copy semantics would be required { public: std::string name; Index: src/index_generator.cpp =================================================================== --- src/index_generator.cpp (revision 68347) +++ src/index_generator.cpp (working copy) @@ -23,13 +23,15 @@ // void generate_indexes() { - for(boost::tiny_xml::element_list::const_iterator i = indexes.begin(); i != indexes.end(); ++i) + for(boost::tiny_xml::element_list::const_iterator i = indexes.begin() + ; i != indexes.end(); ++i) { boost::tiny_xml::element_ptr node = *i; const std::string* category = find_attr(node, "type"); bool has_title = false; - for(boost::tiny_xml::element_list::const_iterator k = (*i)->elements.begin(); k != (*i)->elements.end(); ++k) + for(boost::tiny_xml::element_list::const_iterator k = (*i)->elements.begin() + ; k != (*i)->elements.end(); ++k) { if((**k).name == "title") {