5.10 Index-generating Markup
Keywords: doc

##
5.10 Index-generating Markup

Effective index generation for technical documents can be very difficult, especially for someone familiar with the topic but not the creation of indexes. Much of the difficulty arises in the area of terminology: including the terms an expert would use for a concept is not sufficient. Coming up with the terms that a novice would look up is fairly difficult for an author who, typically, is an expert in the area she is writing on.

The truly difficult aspects of index generation are not areas with which the documentation tools can help. However, ease of producing the index once content decisions are made is within the scope of the tools. Markup is provided which the processing software is able to use to generate a variety of kinds of index entry with minimal effort. Additionally, many of the environments described in section , ``Information Units,'' will generate appropriate entries into the general and module indexes.

The following macro can be used to control the generation of index data, and should be used in the document preamble:

`\makemodindex`
  This should be used in the document preamble if a ``Module Index'' is desired for a document containing reference material on many modules. This causes a data file `libjobname.idx` to be created from the `\declaremodule` macros. This file can be processed by the makeindex program to generate a file which can be `\input` into the document at the desired location of the module index.

There are a number of macros that are useful for adding index entries for particular concepts, many of which are specific to programming languages or even Python.

`\bifuncindex` `{`name`}`
  Add an index entry referring to a built-in function named name; parentheses should not be included after name.

`\exindex` `{`exception`}`
  Add a reference to an exception named exception. The exception may be either string- or class-based.

`\kwindex` `{`keyword`}`
  Add a reference to a language keyword (not a keyword parameter in a function or method call).

`\obindex` `{`object type`}`
  Add an index entry for a built-in object type.

`\opindex` `{`operator`}`
  Add a reference to an operator, such as "`+`".

`\refmodindex` `[`key`]``{`module`}`
  Add an index entry for module module; if module contains an underscore, the optional parameter key should be provided as the same string with underscores removed. An index entry ``module (module)'' will be generated. This is intended for use with non-standard modules implemented in Python.

`\refexmodindex` `[`key`]``{`module`}`
  As for `\refmodindex`, but the index entry will be ``module (extension module).'' This is intended for use with non-standard modules not implemented in Python.

`\refbimodindex` `[`key`]``{`module`}`
  As for `\refmodindex`, but the index entry will be ``module (built-in module).'' This is intended for use with standard modules not implemented in Python.

`\refstmodindex` `[`key`]``{`module`}`
  As for `\refmodindex`, but the index entry will be ``module (standard module).'' This is intended for use with standard modules implemented in Python.

`\stindex` `{`statement`}`
  Add an index entry for a statement type, such as `print` or `try`/`finally`.

  XXX Need better examples of difference from `\kwindex`.

Additional macros are provided which are useful for conveniently creating general index entries which should appear at many places in the index by rotating a list of words. These are simple macros that simply use `\index` to build some number of index entries. Index entries build using these macros contain both primary and secondary text.

`\indexii` `{`word1`}``{`word2`}`
  Build two index entries. This is exactly equivalent to using `\index{word1!word2}` and `\index{word2!word1}`.

`\indexiii` `{`word1`}``{`word2`}``{`word3`}`
  Build three index entries. This is exactly equivalent to using `\index{word1!word2 word3}`, `\index{word2!word3, word1}`, and `\index{word3!word1 word2}`.

`\indexiv` `{`word1`}``{`word2`}``{`word3`}``{`word4`}`
  Build four index entries. This is exactly equivalent to using `\index{word1!word2 word3 word4}`, `\index{word2!word3 word4, word1}`, `\index{word3!word4, word1 word2}`, and `\index{word4!word1 word2 word3}`.