man docidx_api () - Specification of the Interface to Index Formatting Engines

NAME

docidx_api - Specification of the Interface to Index Formatting Engines

SYNOPSIS

idx_numpasses idx_initialize idx_setup n idx_postprocess text idx_shutdown idx_listvariables idx_varset varname text fmt_plain_text text fmt_comment text fmt_index_begin text title fmt_index_end fmt_key text fmt_manpage file text fmt_url url text dt_format dt_fmap symfname dt_source file ex_cappend ex_cget ex_cis ex_cname ex_cpop ex_cpush ex_cset ex_lb ex_rb

DESCRIPTION

This document specifies version 1 of the interface an index formatting engine has to comply with to be usable by the package doctools::idx. The specification of the docidx format all index formatting engines have to process can be found in the companion document docidx_fmt.

API

EXPORTED COMMANDS

Each index formatting engine has to provide a number of commands through which objects created by the package doctools::idx will upon the functionality of the engine. These commands are described here.

Management commands
idx_numpasses
This command is called by a docidx object immediately after it has loaded the engine. No other command of the engine will be called before it. It has to return the number of passes this engine requires to fully process the input document. This value has to be an integer number greater or equal to one.
idx_initialize
This command is called at the beginning of every conversion run, as the first command of that run. Note that a run is not a pass, but may consist of multiple passes. See idx_numpasses. The command has to initialize the general state of the index formatting engine, beyond the initialization done during the load.
idx_setup n
This command is called at the beginning of each pass over the input in a run. Its argument is the number of the pass which has begun. Passes are counted from 1 upward. The command has to set up the internal state of the index formatting engine for this particular pass.
idx_postprocess text
This command is called immediately after the last pass in a run. Its argument is the result of the conversion generated by that pass. It is provided to allow the engine to perform any global last-ditch modifications of the generated document. The text returned by this command will be the final result of the conversion. An engine for a format which requires no postprocessing can simply return the argument without change.
idx_shutdown
This command is called at the end of every conversion run. It is the last command called in a run. It has to clean up of all the run-specific state in the index formatting engine. After the call the engine has to be in a state which allows the initiation of another run without fear that information from the last run is leaked into this new run.
idx_listvariables
This command is called by a docidx object after it has loaded the engine (after idx_numpasses). It has to return a list containing the names of the engine parameters provided by the engine. This list can be empty.
idx_varset varname text
This command is called whenever the docidx object wishes to set an engine parameter to a particular value. The parameter to change is specified by varname, the value to set in text. The command has to throw an error if an unknown varname is used. Only the names returned by idx_listvariables are considered known. The values of all engine parameters have to persist between passes and runs.
Formatting commands
The commands listed in this section are responsible for the conversion of the input into the wanted output. Their names are the names of the associated markup command, with prefix fmt_ added to them. Not all markup commands have associated formatting commands. The two exceptions are vset and include. These markup commands are processed by the docidx object itself. A detailed documentation of the markup commands can be found in the companion document docidx_fmt. It is the formal specification of the docidx format. Note: The formatting commands can expect that they are only called in an order allowed by the format specification.
fmt_plain_text text
This command has no associated markup command. It is called for any plain text encountered by the processor in the input. It has to perform any special processing required for plain text. The text returned as its result is added to the output. If no special processing is required it has to simply return its argument without change.
fmt_comment text
This command has to format the text as a comment and return the formatted string. It has to return the empty string if the output format has no way of formatting comments.
fmt_index_begin text title
This command has to format the label text and the associated title string as the start of the generated index and return the formatted string.
fmt_index_end
This command has to generate the end of the generated index and return the formatted string.
fmt_key text
This commands has to format the keyword text at the beginning of a list of documents and other entities which belong to it and return the formatted string.
fmt_manpage file text
This command has to format a document reference and return the formatted string. The document referenced by the entry is specified through its symbolic name file, whereas the label to use for the link is provided by text. Use the command dt_fmap to convert the symbolic name to the actual link. It is described in section IMPORTED ENVIRONMENT.
fmt_url url text
This is the second command to describe an index element. It has to format an url reference and return the formatted string. The label to use is provided by text, like for fmt_manpage. The place to link to is however not given through a symbolic name, but the exact uri to use in the output.

IMPORTED ENVIRONMENT

The implementation of an index formatting engine can make the following assumptions about the environment it is executed in:

[1]
That it has full access to its own safe interpreter. In other words, the engine cannot damage the other parts of the processor, nor can it damage the filesystem.
[2]
That the following commands are provided by the docidx object controlling the engine:
Doctools commands
dt_format
This command returns the name of the format currently executing.
dt_fmap symfname
This command returns the actual name to use in the output in place of the symbolic filename symfname. It will return the unchanged input if no mapping was found for symfname.
dt_source file
This command allows the index formatting engine to load additional tcl code. Only files which are either in the same directory as the file containing the engine, or below it, can be loaded. Trying to load a file outside of this directory causes an error.
Expander commands
All of the commands below are methods of the expander object (without the prefix ex_) handling the current input. This gives the engine limited access to the state of the expander. Their arguments and results are described in the documentation for the package expander.
ex_cappend
ex_cget
ex_cis
ex_cname
ex_cpop
ex_cpush
ex_cset
ex_lb
ex_rb
Other commands
The file "_idx_common.tcl" contains default implementations of fmt_plaint_text and all the idx_ commands listed in section EXPORTED COMMANDS. It resides in the subdirectory "mpformats" containing all the predefined formats. This means that all external formats (i.e. not provided by the package doctools::idx) cannot use it immediately, but have to have a copy at their location.

SEE ALSO

docidx, docidx_fmt

KEYWORDS

HTML, LaTeX, TMML, generic markup, index, keyword index, keywords, markup, nroff

COPYRIGHT

Copyright (c) 2003-2004 Andreas Kupries <andreas_kupries@users.sourceforge.net>