1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
|
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin docidx_api n 1.0]
[copyright {2003-2004 Andreas Kupries <andreas_kupries@users.sourceforge.net>}]
[moddesc {Documentation tools}]
[titledesc {Specification of the Interface to Index Formatting Engines}]
[description]
[para]
This document specifies version 1 of the interface an index formatting
engine has to comply with to be usable by the package
[package doctools::idx].
The specification of the [term docidx] format all index formatting
engines have to process can be found in the companion document
[term docidx_fmt].
[section API]
[subsection {EXPORTED COMMANDS}]
Each index formatting engine has to provide a number of commands
through which objects created by the package [package doctools::idx]
will upon the functionality of the engine. These commands are
described here.
[list_begin definitions]
[lst_item [emph {Management commands}]]
[list_begin definitions]
[call [cmd 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.
[call [cmd 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 [cmd idx_numpasses]. The command has
to initialize the general state of the index formatting engine, beyond
the initialization done during the load.
[call [cmd idx_setup] [arg 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 [const 1] upward. The command has to set up the
internal state of the index formatting engine for this particular
pass.
[call [cmd idx_postprocess] [arg 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.
[nl]
An engine for a format which requires no postprocessing can simply
return the argument without change.
[call [cmd 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.
[call [cmd idx_listvariables]]
This command is called by a docidx object after it has loaded the
engine (after [cmd idx_numpasses]). It has to return a list containing
the names of the engine parameters provided by the engine. This list
can be empty.
[call [cmd idx_varset] [arg varname] [arg 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 [arg varname], the value to set in [arg text].
[nl]
The command has to throw an error if an unknown [arg varname] is
used. Only the names returned by [cmd idx_listvariables] are
considered known.
[nl]
The values of all engine parameters have to persist between passes and
runs.
[list_end]
[nl]
[lst_item [emph {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 [const fmt_] added to them.
Not all markup commands have associated formatting commands. The two
exceptions are [cmd vset] and [cmd include]. These markup commands are
processed by the docidx object itself.
[nl]
A detailed documentation of the markup commands can be found in the
companion document [term docidx_fmt]. It is the formal specification
of the [term docidx] format.
[nl]
[emph Note]: The formatting commands can expect that they are only
called in an order allowed by the format specification.
[list_begin definitions]
[call [cmd fmt_plain_text] [arg 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.
[call [cmd fmt_comment] [arg text]]
This command has to format the [arg 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.
[call [cmd fmt_index_begin] [arg text] [arg title]]
This command has to format the label [arg text] and the associated
[arg title] string as the start of the generated index and return
the formatted string.
[call [cmd fmt_index_end]]
This command has to generate the end of the generated index and return
the formatted string.
[call [cmd fmt_key] [arg text]]
This commands has to format the keyword [arg text] at the beginning of
a list of documents and other entities which belong to it and return
the formatted string.
[call [cmd fmt_manpage] [arg file] [arg 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 [arg file], whereas the label to use for the link is provided by
[arg text].
Use the command [cmd dt_fmap] to convert the symbolic name to the
actual link.
It is described in section [sectref {IMPORTED ENVIRONMENT}].
[call [cmd fmt_url] [arg url] [arg 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 [arg text], like for [cmd fmt_manpage]. The place
to link to is however not given through a symbolic name, but the exact
uri to use in the output.
[list_end]
[list_end]
[para]
[subsection {IMPORTED ENVIRONMENT}]
The implementation of an index formatting engine can make the
following assumptions about the environment it is executed in:
[list_begin enum]
[enum]
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.
[enum]
That the following commands are provided by the docidx object
controlling the engine:
[list_begin definitions]
[lst_item {Doctools commands}]
[list_begin definitions]
[call [cmd dt_format]]
This command returns the name of the format currently executing.
[call [cmd dt_fmap] [arg symfname]]
This command returns the actual name to use in the output in place of
the symbolic filename [arg symfname]. It will return the unchanged
input if no mapping was found for [arg symfname].
[call [cmd dt_source] [arg 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.
[list_end]
[nl]
[lst_item {Expander commands}]
All of the commands below are methods of the expander object (without
the prefix [const 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 [package expander].
[list_begin definitions]
[call [cmd ex_cappend]]
[call [cmd ex_cget]]
[call [cmd ex_cis]]
[call [cmd ex_cname]]
[call [cmd ex_cpop]]
[call [cmd ex_cpush]]
[call [cmd ex_cset]]
[call [cmd ex_lb]]
[call [cmd ex_rb]]
[list_end]
[nl]
[lst_item {Other commands}]
The file [file _idx_common.tcl] contains default implementations of
[cmd fmt_plaint_text] and all the [const idx_] commands listed in
section [sectref {EXPORTED COMMANDS}].
It resides in the subdirectory [file mpformats] containing all the
predefined formats. This means that all external formats (i.e. not
provided by the package [package doctools::idx]) cannot use it
immediately, but have to have a copy at their location.
[list_end]
[list_end]
[see_also docidx_fmt docidx]
[keywords markup {generic markup} index keywords {keyword index} TMML HTML nroff LaTeX]
[manpage_end]
|