Tcl Library Source Code

Documentation
Login


[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]

NAME

doctools::toc::export - Exporting tables of contents

Table Of Contents

SYNOPSIS

package require doctools::toc::export ?0.2.1?
package require Tcl 8.4
package require struct::map
package require doctools::toc::structure
package require snit
package require pluginmgr

::doctools::toc::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

This package provides a class to manage the plugins for the export of tables of contents to other formats, i.e. their conversion to, for example doctoc, HTML, etc.

This is one of the three public pillars the management of tables of contents resides on. The other two pillars are

  1. Importing tables of contents, and

  2. Holding tables of contents

For information about the Concepts of tables of contents, 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 ToC serialization format.

The plugin system of our class is based on the package pluginmgr, and configured to look for plugins using

  1. the environment variable DOCTOOLS_TOC_EXPORT_PLUGINS,

  2. the environment variable DOCTOOLS_TOC_PLUGINS,

  3. the environment variable DOCTOOLS_PLUGINS,

  4. the path "~/.doctools/toc/export/plugin"

  5. the path "~/.doctools/toc/plugin"

  6. the path "~/.doctools/plugin"

  7. the path "~/.doctools/toc/export/plugins"

  8. the path "~/.doctools/toc/plugins"

  9. the path "~/.doctools/plugins"

  10. the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\TOC\EXPORT\PLUGINS"

  11. the registry entry "HKEY_CURRENT_USER\SOFTWARE\DOCTOOLS\TOC\PLUGINS"

  12. 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

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.

Concepts

  1. A table of contents consists of a (possibly empty) list of elements.

  2. Each element in the list is identified by its label.

  3. Each element is either a reference, or a division.

  4. Each reference has an associated document, identified by a symbolic id, and a textual description.

  5. Each division may have an associated document, identified by a symbolic id.

  6. Each division consists consists of a (possibly empty) list of elements, with each element following the rules as specified in item 2 and above.

A few notes

  1. The above rules span up a tree of elements, with references as the leaf nodes, and divisions as the inner nodes, and each element representing an entry in the whole table of contents.

  2. The identifying labels of any element E are unique within their division (or toc), and the full label of any element E is the list of labels for all nodes on the unique path from the root of the tree to E, including E.

API

Package commands

Object command

All objects created by the ::doctools::toc::export command have the following general form:

Object methods

Export plugin API v2 reference

Plugins are what this package uses to manage the support for any output format beyond the ToC 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:

  1. A plugin is a package.

  2. The name of a plugin package has the form doctools::toc::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 table of contents in that format.

  3. The plugin can expect that the package doctools::toc::export::plugin is present, as indicator that it was invoked from a genuine plugin manager.

  4. A plugin has to provide one command, with the signature shown below.

    • export serial configuration

      Whenever an export manager of doctools::toc has to generate output for a table of contents it will invoke this command.

      • string serial

        This argument will contain the canonical serialization of the table of contents for which to generate the output. The specification of what a canonical serialization is can be found in the section ToC serialization format.

      • 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.

        • 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 table 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 table object is expected to contain a dictionary mapping from symbolic document ids used in the table entries to actual paths (or urls). A plugin has to be able to handle the possibility that a document id is without entry in this mapping.

  5. 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.

ToC serialization format

Here we specify the format used by the doctools v2 packages to serialize tables of contents as immutable values for transport, comparison, etc.

We distinguish between regular and canonical serializations. While a table of contents may have more than one regular serialization only exactly one of them will be canonical.

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. Please also report any ideas for enhancements you may have for either package and/or documentation.

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.

KEYWORDS

HTML, conversion, doctoc, documentation, export, formatting, generation, json, manpage, markup, nroff, plugin, reference, table, table of contents, tcler's wiki, text, url, wiki

CATEGORY

Documentation tools

COPYRIGHT

Copyright © 2009-2019 Andreas Kupries