doctools:...rt::doctoc(3tcl)
π doctools:...rt::doctoc β the doctoc export plugin, bestie edition π
okay so real quick, this page lives in the Documentation tools manual, and it's a 3tcl one. Buckle up, we're exporting tables of contents and it's lowkey iconic.
β¨ NAME β¨
doctools::toc::export::doctoc β the doctoc export plugin. that's it, that's the name, no notes π
β¨ SYNOPSIS β¨
package require Tcl 8.5 9
package require doctools::toc::export::doctoc ?0.2.2?
export serial configuration
πΈ DESCRIPTION πΈ
so this package? it implements the doctools table of contents export plugin for generating doctoc markup. yes queen, it makes doctoc markup. slay.
this is an internal package of doctools, for use by the higher level management packages that handle tables of contents β especially doctools::toc::export, the export manager. iykyk.
ngl, using it from a regular interpreter is possible... but only with contortions π and it's not recommended. like, not me trying to be your hater, it's just true. the proper way to use this functionality is through the package doctools::toc::export and the export manager objects it provides. periodt.
π API π
the API this package provides satisfies the specification of the doctoc export plugin API version 2. she's certified β
export serial configurationβ this command takes the canonical serialization of a table of contents (as specified in the ToC serialization format section, bestie, keep reading) contained in serial, plus the configuration which is a dictionary, and generates doctoc markup encoding the table. the created string is then returned as the result of the command. chef's kiss π«Ά
π¦ [DOCTOC] NOTATION OF TABLES OF CONTENTS π¦
okay so the doctoc format for tables of contents β also called the doctoc markup language β is too large to be covered in a single section π it's giving main character energy in the worst way.
the interested reader should start with the document:
[1]doctoc language introduction
and then proceed from there to the formal specifications, i.e. the documents:
[1]doctoc language syntax and[2]doctoc language command reference.
...to get a thorough understanding of the language. go off, do your homework, i believe in you π
π CONFIGURATION π
the doctoc export plugin recognizes the following configuration variables and changes its behaviour as they specify. she's flexible, she's adaptable, we love her.
string userβ this standard configuration variable contains the name of the user running the process which invoked the export plugin. the plugin puts this information into the provenance comment at the beginning of the generated document. little credit where credit is due β¨string fileβ this standard configuration variable contains the name of the file the table of contents came from. > careful bestie: this variable may not be set, or it may contain the empty string. the plugin puts this information β but only if defined, i.e. set and not the empty string β into the provenance comment at the beginning of the generated document.boolean newlinesβ if this flag is set, the plugin will break the generated doctoc code across lines, with each markup command on a separate line. if this flag is not set (that's the default), the whole document gets written on a single line, with minimum spacing between all elements. one line. no breathing room. efficient πboolean indentedβ if this flag is set, the plugin will indent the markup commands according to the structure of tables of contents. to make this work it also implies thatnewlinesis set. this effect is independent of the value foralignedhowever. if this flag is not set (the default), the output is formatted as per the value ofnewlines, and no indenting is done.boolean alignedβ if this flag is set, the generator ensures that the arguments for theitemcommands in a division are aligned vertically for a nice table effect. to make this work this also implies thatnewlinesis set. this effect is independent of the value forindentedhowever. if this flag is not set (the default), the output is formatted as per the values ofnewlinesandindented, and no alignment is done.
heads up: this plugin ignores the standard configuration variablesformatandmap, and their values. she simply does not see them. not her business. π
π 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. (yes, for comparing. she's got range.)
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. there can only be 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. an alternative description would be that it is 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 are:idβ 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. no duplicates, we don't do that here π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 are:idβ 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. this closes the recusrive 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 π’
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 π not me being humble, it's just the truth. please report such in the category doctools of the Tcllib Trackers at http://core.tcl.tk/tcllib/reportlist. please also report any ideas for enhancements you may have for either package and/or documentation. we want your thoughts, 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. (yes, the left-most one. go get it β¨)
β KEYWORDS β
doctoc, doctools, export, serialization, 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 shipped as part of tcllib, version 0.2.2, and it's a doctools:...rt::doctoc(3tcl) situation. go forth and export those tables of contents. slay, periodt, bye πβ¨
π¦ 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