doctools:...rt::doctoc(3tcl)
β¨ NAME β¨
doctools::toc::import::doctoc β the doctoc import plugin. That's it, that's the whole name, it's giving "I live deep inside a package hierarchy and I've made peace with it." π
This page lives in the Documentation tools manual, section 3tcl. You're in the right place, bestie. π«Ά
πΈ SYNOPSIS πΈ
package require Tcl 8.5 9
package require doctools::toc::import::doctoc ?0.2.1?
package require doctools::toc::parse
package require doctools::toc::structure
package require doctools::msgcat
package require doctools::tcl::parse
package require fileutil
package require logger
package require snit
package require struct::list
package require struct::set
package require struct::stack
package require struct::tree
package require treeql
import string configuration
π DESCRIPTION π
okay so. This package is the doctools table of contents import plugin, and its whole job β its entire personality β is parsing doctoc markup. π
It's an internal package of doctools, made for the higher level management packages that handle tables of contents, especially doctools::toc::import, the import manager.
ngl, you could use it straight from a regular interpreter, but only with contortions, and that is not recommended. The proper way β the main character way β is through the package doctools::toc::import and the import manager objects it hands you. periodt. π
π API π
The API this package serves up satisfies the spec of the doctoc import plugin API version 2. Iconic.
import string configurationβ this command takes the string and parses it asdoctocmarkup that encodes a table of contents, all in the context of the configuration you pass (a dictionary). What you get back is the canonical serialization of that table of contents, in the form laid out down in the ToC serialization format section. π«
π [DOCTOC] NOTATION OF TABLES OF CONTENTS π
So the doctoc format for tables of contents β also called the doctoc markup language β is way too big to fit in one lil section. No cap, it's huge. If you're the interested reader (you are, bestie, look at you), start with this document:
doctoc language introduction
and then roll on from there into the formal specs, i.e. these documents:
doctoc language syntaxanddoctoc language command reference.
That's the path to a thorough understanding of the language. Go off. π
π¦ TOC SERIALIZATION FORMAT π¦
Here's where we specify the format the doctools v2 packages use to serialize tables of contents as immutable values for transport, comparison, etc. etc. π
We distinguish between regular and canonical serializations. A table of contents can have more than one regular serialization, but exactly one of them is the canonical one. One. Only one. The chosen one. β¨
regular serialization
- The serialization of any table of contents is a nested Tcl dictionary.
- This dictionary holds a single key,
doctools::toc, and its value. This value holds the contents of the table of contents. - The contents of the table of contents are a Tcl dictionary holding the title of the table of contents, a label, and its elements. The relevant keys and their values are
titleβ the value is a string containing the title of the table of contents.labelβ the value is a string containing a label for the table of contents.itemsβ the value is a Tcl list holding the elements of the table, in the order they are to be shown.
Each element is a Tcl list holding the type of the item, and its description, in this order. Another way to say it: it's a Tcl dictionary holding a single key, the item type, mapped to the item description.
The two legal item types and their descriptions are
referenceβ this item describes a single entry in the table of contents, referencing a single document. To this end its value is a Tcl dictionary containing an id for the referenced document, a label, and a longer textual description which can be associated with the entry. The relevant keys and their values areidβ the value is a string containing the id of the document associated with the entry.labelβ the value is a string containing a label for this entry. This string also identifies the entry, and no two entries (references and divisions) in the containing list are allowed to have the same label. π€descβ the value is a string containing a longer description for this entry.
divisionβ this item describes a group of entries in the table of contents, inducing a hierarchy of entries. To this end its value is a Tcl dictionary containing a label for the group, an optional id to a document for the whole group, and the list of entries in the group. The relevant keys and their values areidβ the value is a string containing the id of the document associated with the whole group. This key is optional.labelβ the value is a string containing a label for the group. This string also identifies the entry, and no two entries (references and divisions) in the containing list are allowed to have the same label. π€itemsβ the value is a Tcl list holding the elements of the group, in the order they are to be shown. This list has the same structure as the value for the keyworditemsused to describe the whole table of contents, see above. And that closes the recursive definition of the structure, with divisions holding the same type of elements as the whole table of contents, including other divisions. It's turtles all the way down, bestie. π’
canonical serialization
The canonical serialization of a table of contents 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 this table of contents.
- 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.
π BUGS, IDEAS, FEEDBACK π
This document, and the package it describes, will undoubtedly contain bugs and other problems. It's giving "software," honestly. Please report such in the category doctools of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist. And please also report any ideas for enhancements you may have for either the package and/or the documentation. We want the glow-up. π«Ά
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 π
deserialization, doctoc, doctools, import, table of contents, toc
π CATEGORY π
Text formatter plugin
πΈ COPYRIGHT πΈ
Copyright (c) 2009-2019 Andreas Kupries <andreas_kupries@users.sourceforge.net>
and that's the whole page, bestie!! π this one came to you from tcllib, version 0.2.1, and it's the doctoc(3tcl) page β slay, go parse some tables of contents, ily ππ¦β¨
π¦ 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