doctools::t...port::doctoc(n)
π doctools::toc::export::doctoc(n) β the doctoc export plugin, explained bestie-style π
okay so you opened the manual page for doctools::toc::export::doctoc, a lil Tcllib thing. sit down, grab a strawberry π, and let's get into it. it's an export plugin. for tables of contents. it's giving β¨niche but iconicβ¨.
β¨ NAME β¨
doctools::toc::export::doctoc β bestie, it's the doctoc export plugin π
πΈ SYNOPSIS πΈ
here's the whole vibe in code form, no edits, no notes:
package require Tcl 8.5 9
package require doctools::toc::export::doctoc ?0.2.2?
export serial configuration
like yes, that's it. that's the whole entrance. π¦
π DESCRIPTION π
so this package is the one that implements the doctools table of contents export plugin β specifically the one that generates doctoc markup. that's its whole job. its main character moment. π
and like β important disclaimer β this is an internal package of doctools. it exists for the higher level management packages that handle tables of contents, especially doctools::toc::export, the export manager. iykyk.
can you use it from a regular interpreter? technically yes. should you? bestie... it requires contortions π and it is not recommended. the proper way to use this functionality is through the package doctools::toc::export and the export manager objects it provides. do it the right way, ok? π«Ά
π§ API π§
the API this package provides satisfies the spec of the doctoc export plugin API version 2. fancy. periodt.
export serial configurationβ this command takes the canonical serialization of a table of contents (the whole spec is down in the section ToC serialization format, keep scrolling bestie), and that serialization lives in serial, plus the configuration, which is a dictionary. it generates doctoc markup that encodes the table. then the created string is returned as the result of the command. so: in goes the serialized toc, out comes doctoc markup. slay. β¨
π [DOCTOC] NOTATION OF TABLES OF CONTENTS π
the doctoc format for tables of contents β also called the doctoc markup language β is too large to fit in a single section. like, no cap, it does not fit. π
so if you're the interested reader, start with this document:
- doctoc language introduction
and then proceed from there to the formal specifications, i.e. these documents:
- doctoc language syntax and
- doctoc language command reference.
do that and you'll get a thorough understanding of the language. it's a journey. a beautiful one. π¦
π CONFIGURATION π
the doctoc export plugin recognizes these configuration variables and changes its behaviour as they specify. here we go, one by one:
string userβ this standard configuration variable holds the name of the user running the process that invoked the export plugin. the plugin puts this info into the provenance comment at the beginning of the generated document. so like, credit where credit is due. πstring fileβ this standard configuration variable holds the name of the file the table of contents came from. note: this variable may not be set, or it may contain the empty string. the plugin puts this information into the provenance comment at the beginning of the generated document β but only if it's defined, i.e. set and not the empty string. conditional king. π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 (which is the default), the whole document gets written on a single line, with minimum spacing between all elements. one long line, no breaks, she's compact. πboolean indentedβ if this flag is set, the plugin will indent the markup commands according to the structure of tables of contents. heads up: to make this work it also implies thatnewlinesis set. and 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. nesting goes brrr but only if you ask. πΈboolean alignedβ if this flag is set, the generator makes sure the arguments for theitemcommands in a division are aligned vertically for a nice table effect. heads up again: to make this work it also implies thatnewlinesis set. and 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. aesthetically pleasing columns, we love to see it. β¨
also, real talk: this plugin ignores the standard configuration variablesformat, andmap, and their values. it just does. don't fight it. π
π TOC SERIALIZATION FORMAT π
here we specify the format the doctools v2 packages use to serialize tables of contents as immutable values β for transport, comparison, etc. very serious business.
we distinguish between regular and canonical serializations. a table of contents may have more than one regular serialization, but 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. that 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'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 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, periodt.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. again: no duplicates.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 divisions 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.
sorted = canonical = iconic. β¨
π«Ά BUGS, IDEAS, FEEDBACK π«Ά
ngl, this document and the package it describes will undoubtedly contain bugs and other problems. it's not a maybe, it's a when. π please report them in the category doctools of the Tcllib Trackers [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 ideas. we need the ideas. π§
when proposing code changes, please provide unified diffs, i.e the output of diff -u.
and 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. that's the move. π
β 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, you ate it π this lil number came to you from tcllib, version 0.2.2, filed under doctools::t...port::doctoc(n). go forth and export your tables of contents the proper way, mwah πβ¨π¦
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- 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