doctools:...rt::doctoc(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ 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 as doctoc markup 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:

  1. doctoc language introduction

and then roll on from there into the formal specs, i.e. these documents:

  1. doctoc language syntax and
  2. doctoc 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

  1. The serialization of any table of contents is a nested Tcl dictionary.
  2. This dictionary holds a single key, doctools::toc, and its value. This value holds the contents of the table of contents.
  3. 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 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. 😀
    • 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 keyword items used 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.

  1. 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 (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