doctools::idx::export(3tcl)
β¨ NAME β¨
doctools::idx::export β exporting keyword indices π
okay so picture this: you've got a keyword index, right? And you need it in a different format. This is the package that makes that happen. No cap.
π¦ SYNOPSIS π¦
package require doctools::idx::export ?0.2.2?
package require Tcl 8.5 9
package require struct::map
package require doctools::idx::structure
package require snit
package require pluginmgr
::doctools::idx::export objectName
objectName method ?arg arg ...?
objectName destroy
objectName export serial serial ?format?
objectName export object object ?format?
objectName config names
objectName config get
objectName config set name ?value?
objectName config unset pattern...
export serial configuration
πΈ DESCRIPTION πΈ
Bestie. This package hands you a class that manages all the plugins for exporting keyword indices into other formats β like converting them to docidx, HTML, whatever your heart desires. β¨
This is one of the three public pillars that keyword index management sits on top of. The other two pillars are:
- Importing keyword indices, and
- Holding keyword indices
Wanna know about the Concepts of keyword indices and all their little parts? Peep the same-named section. Wanna know about the data structure that's the major input to the manager objects this package gives you? That's the Keyword index serialization format section, babes.
Our class's plugin system is built on the package pluginmgr, and it's configured to go looking 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"
π psst β those last three? They only get used when the package is running on a machine with the Windows(tm) operating system. So like, if that's not you, don't even worry about it.
The whole system ships with six predefined export plugins, and they are:
docidxβ Seedocidxexport plugin for details.htmlβ Seehtmlexport plugin for details.jsonβ Seejsonexport plugin for details.nroffβ Seenroffexport plugin for details.textβ Seetextexport plugin for details.wikiβ Seewikiexport plugin for details.
And hey β if you're the type who wants to write their own export plugin for some format? (plugin writers, I see you π) Then reading and actually understanding the section with the Export plugin API v2 reference is an absolute necessity, fr fr. That section spells out exactly how this package and its plugins talk to each other. Every detail. Periodt.
π§ CONCEPTS π§
- 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 meant for pointing at the documents the index is actually made for. Their target is a symbolic file name identifying the document β and export plugins are allowed to swap that symbolic name for an actual file name, if specified.
- Url references, on the other hand, are meant for links to literally anything else, like websites. Their target is an url.
- So url and manpage references share a namespace for their identifiers β but that should be zero problem, because manpage identifiers are symbolic filenames and as such they should never look like urls, which is what the identifiers for url references are. π
π API π
π PACKAGE COMMANDS π
::doctools::idx::export objectNameβ This command creates a brand new export manager object, with a Tcl command attached to it whose name is objectName. That object command gets explained in full detail over in the sections Object command and Object methods. And heads up: the object command gets created under the current namespace if objectName isn't fully qualified β otherwise it lands in the namespace you specified. Slay.
π OBJECT COMMAND π
Every single object made by the ::doctools::idx::export command has this general form:
objectName method ?arg arg ...?β The method method and its arg'uments are what determine exactly how the command behaves. See the section Object methods for the detailed specs, bestie.
β¨ OBJECT METHODS β¨
objectName destroyβ This method destroys the object it's invoked for. bye bitch πobjectName export serial serial ?format?β 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 that format. If no plugin could be found for the format? An error is thrown. π The string that the conversion process spits out is returned as the result of this method.
If you don't specify a format, the method defaults to docidx.
The specification of what a canonical serialization actually is lives in the section Keyword index serialization format.
And the plugin has to conform to the interface specified in the section Export plugin API v2 reference. No exceptions.
objectName export object object ?format?β This one is a convenient little wrapper around theexport serialmethod described right above. β¨ It expects object to be an object command that supports aserializemethod returning the canonical serialization of a keyword index. It invokes that method, feeds the result straight intoexport serial, and returns the resulting string as its own result. Efficiency queen.objectName config namesβ Returns a list containing the names of all the configuration variables the object currently knows about.objectName config getβ Returns a dictionary containing the names and values of all the configuration variables the object currently knows about.objectName config set name ?value?β Sets the configuration variable name to the specified value, and returns the new value of the variable.
If you don't pass a value, it just returns the current value without changing anything. chill like that.
β οΈ Nota bene: even though the user can set the predefined configuration variablesuserandformat, doing so will have no effect β those values get internally overridden when invoking an import plugin. Don't waste your energy, babe.
objectName config unset pattern...β Unsets all configuration variables matching the specified glob patterns. If you don't pass any pattern, it'll unset all currently defined configuration variables. Clean slate energy π
π EXPORT PLUGIN API V2 REFERENCE π
okay so plugins are literally the whole vibe this package uses to manage the support for any output format beyond the Keyword index serialization format. bestie, here's the API that the objects created by this package use to interact with their plugins. no cap.
A plugin for this package has to follow the rules listed below, fr fr:
- A plugin is a package. periodt. π
- The name of a plugin package has the form
doctools::idx::export::FOO, whereFOOis 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. slay. - The plugin can expect that the package
doctools::idx::export::pluginis present, as indicator that it was invoked from a genuine plugin manager. iconic. - A plugin has to provide one command, with the signature shown below.
export serial configuration
Whenever an export manager of doctools::idx has to generate output for an index it will invoke this command. it's giving main character energy, ngl.
string serialβ 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. iykyk.dictionary configurationβ 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. (yes, "other other" β i'm just keeping it real. π)
userβ This variable is expected to contain the name of the user owning the process invoking the plugin.formatβ This variable is expected to contain the name of the format whose plugin is invoked.fileβ 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.mapβ 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 typemanpageto actual paths (or urls). A plugin has to be able to handle the possibility that a symbolic name is without entry in this mapping. lowkey important.
- 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. no stress. π«Ά
π KEYWORD INDEX SERIALIZATION FORMAT π
Here we specify the format used by the doctools v2 packages to serialize keyword indices as immutable values for transport, comparison, etc. obsessed.
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. the way that works is giving β¨uniqueβ¨.
π¦ regular serialization
- 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:
titleβ The value is a string containing the title of the index.labelβ The value is a string containing a label for the index.keywordsβ 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.
referencesβ 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:
manpageβ The identifier of the reference is interpreted as symbolic file name, referring to one of the documents the index was made for.urlβ The identifier of the reference is interpreted as an url, referring to some external location, like a website, etc.
π canonical serialization
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. it's literally the one and only. π
- 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.
π BUGS, IDEAS, FEEDBACK π
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 [http://core.tcl.tk/tcllib/reportlist]. Please also report any ideas for enhancements you may have for either package and/or documentation. we're all ears, bestie.
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. it's giving helpful. β¨
π·οΈ KEYWORDS π·οΈ
HTML, conversion, docidx, documentation, export, formatting, generation, index, json, keyword index, manpage, markup, nroff, plugin, reference, tcler's wiki, text, url, wiki
π CATEGORY π
Documentation tools
Β©οΈ COPYRIGHT Β©οΈ
Copyright (c) 2009-2019 Andreas Kupries <andreas_kupries@users.sourceforge.net>
Stay slay, bestie π This was tcllib version 0.2.2, page doctools::idx::export(3tcl). Catch you on the flip side! β¨
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- Copyright (c) 2009-2019 Andreas Kupries <andreas_kupries@users\&.sourceforge\&.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms