Tcl Library Source Code


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


doctools::toc - Holding tables of contents

Table Of Contents


package require doctools::toc ?2?
package require Tcl 8.5 9
package require doctools::toc::structure
package require struct::tree
package require snit

::doctools::toc objectName
objectName method ?arg arg ...?
objectName destroy
objectName + reference id label docid desc
objectName + division id label ?docid?
objectName remove id
objectName up id
objectName next id
objectName prev id
objectName child id label ?...?
objectName element ?...?
objectName children id
objectName type id
objectName full-label id
objectName elabel id ?newlabel?
objectName description id ?newdesc?
objectName document id ?newdocid?
objectName title
objectName title text
objectName label
objectName label text
objectName importer
objectName importer object
objectName exporter
objectName exporter object
objectName deserialize = data ?format?
objectName deserialize += data ?format?
objectName serialize ?format?


This package provides a class to contain and programmatically manipulate tables of contents.

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

  1. Exporting tables of contents, and

  2. Importing 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 used to encode tables of contents as values see the section ToC serialization format. This is the only format directly known to this class. Conversions from and to any other format are handled by export and import manager objects. These may be attached to a container, but do not have to be, it is merely a convenience.


  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.


Package commands

Object command

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

Object methods

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.


HTML, TMML, conversion, doctoc markup, documentation, formatting, generation, json, latex, markup, nroff, parsing, plugin, reference, table, table of contents, tcler's wiki, text, wiki


Documentation tools


Copyright © 2009 Andreas Kupries