doctools::t...port::doctoc(n)
π doctools::toc::import::doctoc β the doctoc import plugin π
okay bestie, welcome to the manual page for doctools::toc::import::doctoc, part of the tcllib docs, living in section n of the manual. it's giving niche but iconic, fr fr. π
β¨ NAME β¨
doctools::toc::import::doctoc β the doctoc import plugin. that's it, that's the name, periodt. π
πΈ 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
and then the actual command:
import string configuration
look at all those package requires β it's a whole squad, a friend group, a roster. π
π DESCRIPTION π
so this package is the doctools table of contents import plugin for parsing doctoc markup. that's the whole job. that's the assignment and it ate. π₯
it's an internal package of doctools, bestie β it exists for the higher-level management packages that handle tables of contents, especially doctools::toc::import, the import manager. it's not out here trying to be a main character on its own, it's supporting cast. but like, essential supporting cast. π€
okay so, real talk: technically you can use it straight from a regular interpreter, but only with contortions, and it is not recommended. the proper way to get at this functionality is through the package doctools::toc::import and the import manager objects it hands you. don't do the weird thing. do the nice thing. π«Ά
π API π
the API this package provides satisfies the spec of the doctoc import plugin API version 2. π
import string configurationβ this command grabs string and parses it as doctoc markup that encodes a table of contents, all in the context of the given configuration (which is a dictionary, btw). what you get back is the canonical serialization of that table of contents, in the exact form described down in the section ToC serialization format. that's the whole vibe. β¨
π¦ [DOCTOC] NOTATION OF TABLES OF CONTENTS π¦
the doctoc format for tables of contents β aka the doctoc markup language β is way too big to fit in a single section, no cap. if you're interested (and you should be, it's lowkey fascinating), start here:
- doctoc language introduction
and then go from there to the formal specs, i.e. these documents:
- doctoc language syntax and
- doctoc language command reference.
read those and you'll have a thorough understanding of the language. that's the study plan, bestie, go off. π
π TOC SERIALIZATION FORMAT π
okay so here's where we spell out the format the doctools v2 packages use to serialize tables of contents as immutable values β for transport, for comparison, etc. immutability is the moment. π§
we distinguish between regular and canonical serializations. a table of contents can have more than one regular serialization, but exactly one of them is canonical. the chosen one. the main character. β
β¨ 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. here are the relevant keys and their values:
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're meant to be shown. π«
each element is a Tcl list holding the type of the item and its description, in that order. another way to put 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. for that, its value is a Tcl dictionary containing an id for the referenced document, a label, and a longer textual description that 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. so no twinning. π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. for that, 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. same rule as before, it applies recursively, iykyk.itemsβ the value is a Tcl list holding the elements of the group, in the order they're meant 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 recursive 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. unique = iconic. π
- 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. obviously. it's software. π please report such things 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 glow-up, fr fr. β¨
when proposing code changes, please provide unified diffs, i.e. the output of diff -u. that's the format, don't freestyle it. π«Ά
also note: attachments are strongly preferred over inlined patches. you can attach stuff 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 whole procedure, go forth. π
π₯ KEYWORDS π₯
deserialization, doctoc, doctools, import, table of contents, toc
πΈ CATEGORY πΈ
Text formatter plugin β that's the category, that's the lane, and it stays in it. π
π COPYRIGHT π
Copyright (c) 2009-2019 Andreas Kupries <andreas_kupries@users.sourceforge.net>
and that's the page, bestie!! π«Ά this whole thing is from tcllib, version 0.2.1, for doctools::t...port::doctoc(n) β go read your tables of contents, slay, and remember: no two labels in the same list, ever. bye 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