doctools::idx::export - Exporting keyword indices
This package provides a class to manage the plugins for the export of keyword indices to other formats, i.e. their conversion to, for example docidx, HTML, etc.
This is one of the three public pillars the management of keyword indices resides on. The other two pillars are
For information about the Concepts of keyword indices, and their parts, see the same-named section. For information about the data structure which is the major input to the manager objects provided by this package see the section Keyword index serialization format.
The plugin system of our class is based on the package pluginmgr, and configured to look for plugins using
the environment variable DOCTOOLS_IDX_EXPORT_PLUGINS,
the environment variable DOCTOOLS_IDX_PLUGINS,
the environment variable DOCTOOLS_PLUGINS,
the path "~/.doctools/idx/export/plugin"
the path "~/.doctools/idx/plugin"
the path "~/.doctools/plugin"
the path "~/.doctools/idx/export/plugins"
the path "~/.doctools/idx/plugins"
the path "~/.doctools/plugins"
the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\IDX\EXPORT\PLUGINS"
the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\IDX\PLUGINS"
the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\PLUGINS"
The last three are used only when the package is run on a machine using Windows(tm) operating system.
The whole system is delivered with six predefined export plugins, namely
See docidx export plugin for details.
See html export plugin for details.
See json export plugin for details.
See nroff export plugin for details.
See text export plugin for details.
See wiki export plugin for details.
Readers wishing to write their own export plugin for some format, i.e. plugin writers reading and understanding the section containing the Export plugin API v2 reference is an absolute necessity, as it specifies the interaction between this package and its plugins in detail.
A keyword index consists of a (possibly empty) set of keywords.
Each keyword in the set is identified by its name.
Each keyword has a (possibly empty) set of references.
A reference can be associated with more than one keyword.
A reference not associated with at least one keyword is not possible however.
Each reference is identified by its target, specified as either an url or symbolic filename, depending on the type of reference (url, or manpage).
The type of a reference (url, or manpage) depends only on the reference itself, and not the keywords it is associated with.
In addition to a type each reference has a descriptive label as well. This label depends only on the reference itself, and not the keywords it is associated with.
A few notes
Manpage references are intended to be used for references to the documents the index is made for. Their target is a symbolic file name identifying the document, and export plugins may replace symbolic with actual file names, if specified.
Url references are intended on the othre hand are inteded to be used for links to anything else, like websites. Their target is an url.
While url and manpage references share a namespace for their identifiers, this should be no problem, given that manpage identifiers are symbolic filenames and as such they should never look like urls, the identifiers for url references.
This command creates a new export manager object with an associated Tcl command whose name is objectName. This object command is explained in full detail in the sections Object command and Object methods. The object command will be created under the current namespace if the objectName is not fully qualified, and in the specified namespace otherwise.
All objects created by the ::doctools::idx::export command have the following general form:
The method method and its arg'uments determine the exact behavior of the command. See section Object methods for the detailed specifications.
This method destroys the object it is invoked for.
This method takes the canonical serialization of a keyword index stored in serial and converts it to the specified format, using the export plugin for the format. An error is thrown if no plugin could be found for the format. The string generated by the conversion process is returned as the result of this method.
If no format is specified the method defaults to docidx.
The specification of what a canonical serialization is can be found in the section Keyword index serialization format.
The plugin has to conform to the interface specified in section Export plugin API v2 reference.
This method is a convenient wrapper around the export serial method described by the previous item. It expects that object is an object command supporting a serialize method returning the canonical serialization of a keyword index. It invokes that method, feeds the result into export serial and returns the resulting string as its own result.
This method returns a list containing the names of all configuration variables currently known to the object.
This method returns a dictionary containing the names and values of all configuration variables currently known to the object.
This method sets the configuration variable name to the specified value and returns the new value of the variable.
If no value is specified it simply returns the current value, without changing it.
Note that while the user can set the predefined configuration variables user and format doing so will have no effect, these values will be internally overriden when invoking an import plugin.
This method unsets all configuration variables matching the specified glob patterns. If no pattern is specified it will unset all currently defined configuration variables.
Plugins are what this package uses to manage the support for any output format beyond the Keyword index serialization format. Here we specify the API the objects created by this package use to interact with their plugins.
A plugin for this package has to follow the rules listed below:
A plugin is a package.
The name of a plugin package has the form doctools::idx::export::FOO, where FOO is the name of the format the plugin will generate output for. This name is also the argument to provide to the various export methods of export manager objects to get a string encoding a keyword index in that format.
The plugin can expect that the package doctools::idx::export::plugin is present, as indicator that it was invoked from a genuine plugin manager.
A plugin has to provide one command, with the signature shown below.
Whenever an export manager of doctools::idx has to generate output for an index it will invoke this command.
This argument will contain the canonical serialization of the index for which to generate the output. The specification of what a canonical serialization is can be found in the section Keyword index serialization format.
This argument will contain the current configuration to apply to the generation, as a dictionary mapping from variable names to values.
The following configuration variables have a predefined meaning all plugins have to obey, although they can ignore this information at their discretion. Any other other configuration variables recognized by a plugin will be described in the manpage for that plugin.
This variable is expected to contain the name of the user owning the process invoking the plugin.
This variable is expected to contain the name of the format whose plugin is invoked.
This variable, if defined by the user of the index object is expected to contain the name of the input file for which the plugin is generating its output for.
This variable, if defined by the user of the index object is expected to contain a dictionary mapping from symbolic file names used in the references of type manpage to actual paths (or urls). A plugin has to be able to handle the possibility that a symbolic name is without entry in this mapping.
A single usage cycle of a plugin consists of the invokations of the command export. This call has to leave the plugin in a state where another usage cycle can be run without problems.
Here we specify the format used by the doctools v2 packages to serialize keyword indices as immutable values for transport, comparison, etc.
We distinguish between regular and canonical serializations. While a keyword index may have more than one regular serialization only exactly one of them will be canonical.
An index serialization is a nested Tcl dictionary.
This dictionary holds a single key, doctools::idx, and its value. This value holds the contents of the index.
The contents of the index are a Tcl dictionary holding the title of the index, a label, and the keywords and references. The relevant keys and their values are
The value is a string containing the title of the index.
The value is a string containing a label for the index.
The value is a Tcl dictionary, using the keywords known to the index as keys. The associated values are lists containing the identifiers of the references associated with that particular keyword.
Any reference identifier used in these lists has to exist as a key in the references dictionary, see the next item for its definition.
The value is a Tcl dictionary, using the identifiers for the references known to the index as keys. The associated values are 2-element lists containing the type and label of the reference, in this order.
Any key here has to be associated with at least one keyword, i.e. occur in at least one of the reference lists which are the values in the keywords dictionary, see previous item for its definition.
The type of a reference can be one of two values,
The identifier of the reference is interpreted as symbolic file name, refering to one of the documents the index was made for.
The identifier of the reference is interpreted as an url, refering to some external location, like a website, etc.
The canonical serialization of a keyword index has the format as specified in the previous item, and then additionally satisfies the constraints below, which make it unique among all the possible serializations of the keyword index.
The keys found in all the nested Tcl dictionaries are sorted in ascending dictionary order, as generated by Tcl's builtin command lsort -increasing -dict.
The references listed for each keyword of the index, if any, are listed in ascending dictionary order of their labels, as generated by Tcl's builtin command lsort -increasing -dict.
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category doctools of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.
HTML, conversion, docidx, documentation, export, formatting, generation, index, json, keyword index, manpage, markup, nroff, plugin, reference, tcler's wiki, text, url, wiki
Documentation tools
Copyright © 2009 Andreas Kupries <andreas_kupries@users.sourceforge.net>