doctools(n)
๐ doctools โ the manual page, bestie edition ๐
okay so this is doctools(n), from the Documentation tools section of your friendly neighbourhood manual. It's giving "I turn your fancy markup into literally any format you want" energy, and honestly? Obsessed.
โจ SYNOPSIS โจ
package require Tcl 8.5 9
package require doctools ?1.6.1?
::doctools::new objectName ?option value...?
::doctools::help
::doctools::search path
objectName method ?arg arg ...?
objectName configure
objectName configure option
objectName configure -option value...
objectName cget -option
objectName destroy
objectName format text
objectName map symbolic actual
objectName parameters
objectName search path
objectName setparam name value
objectName warnings
No cap, that's the whole vibe check right there. ๐ฆ
๐ธ DESCRIPTION ๐ธ
Okay so bestie, here's the tea. This package hands you a class โ like, an actual class โ that makes objects. And those objects? They process and convert text written in the doctools markup language into any output format X for which a formatting engine is available. Any X. The world is your oyster, fr fr. ๐
If you're the kind of reader who's here for the markup language itself, you should start with the doctools language introduction and then justโฆ proceed from there into the formal specs, i.e. the doctools language syntax and the doctools language command reference. That's the whole roadmap. Go off. ๐บ๏ธโจ
But if you, on the other hand, are the kind of reader who wants to write her own formatting engine for some format โ i.e. you're a plugin writer โ then reading and understanding the doctools plugin API reference is an absolute necessity. Not optional. Not "eh I'll skim it later." Because that document specifies, in detail, the interaction between this package and its plugins, i.e. the formatting engines. That's the contract. That's the whole relationship. ๐ค๐
tl;dr: markup-language girlies start at the introduction, plugin-writer girlies start at the plugin API reference. Both of you are valid and both of you are eating. ๐
โจ more parts coming, don't you dare leave โจ
๐ซถ PUBLIC API ๐ซถ
Okay bestie, this is the part where the package shows you its actual buttons. Let's go ๐
๐ PACKAGE COMMANDS ๐
::doctools::new objectName ?option value...?โ this is the glow-up command, fr fr. It makes a brand new doctools object, and that object comes with its own little Tcl command namedobjectName. That object command is fully explained in the OBJECT COMMAND and OBJECT METHODS sections below, so don't panic. โจ
Where does this object command live? If objectName is not fully qualified, it gets created under the current namespace. If it is fully qualified, it goes in the namespace you specified. No cap.
And the options + values that come after the object name? Those set up the object's initial configuration. It's giving "build-a-bear but for converters" ๐งธ
::doctools::helpโ a little convenience command for apps that wanna give their users a quick rundown of the available formatting commands and what they mean. It returns a string with a standard help text. Super handy, lowkey iconic. ๐::doctools::search pathโ so here's the tea ๐: whenever an object from this package has to map a format name to the file holding the code for its formatting engine, it searches for that file in a bunch of directories stored in a list. (More on that in FORMAT MAPPING, keep reading.)
That list isn't just three default directories declared by the package itself โ it's also extensible by the user of the package, and this command is how you extend it. When you hand it a path to an existing, readable directory, it prepends that directory to the search list. Which means: the path you added last gets searched through first. Order matters, bestie. ๐
An error will be thrown if the path either does not exist, is not a directory, or is not readable. No sneaky fake paths, okay? ๐ญ
๐ฆ OBJECT COMMAND ๐ฆ
Every command created by ::doctools::new has this general form, and you use it to invoke all kinds of operations on its doctools converter object.
objectName method ?arg arg ...?
objectName method ?arg arg ...?โ themethodand itsarguments decide exactly what the command does. The OBJECT METHODS section has the full specs, so go look. ๐
โจ OBJECT METHODS โจ
objectName configureโ call it with zero arguments and it hands you a list of all known options and their current values. A full vibe check of your config. ๐objectName configure optionโ call it with a single argument and it acts just likecget: it returns the value of the option you named. ๐ฏobjectName configure -option value...โ call it with an even number of arguments (at least two) and it reconfigures the options you specified, setting them to their matching values. The legal options live in the OBJECT CONFIGURATION section. Glow-up your object, periodt. ๐objectName cget -optionโ expects a legal configuration option as its argument and returns that option's current value for the object the method was invoked on. The legal config options are described in OBJECT CONFIGURATION. ๐ธobjectName destroyโ poof. ๐ This method destroys the object it's invoked for. Gone. Not coming back.objectName format textโ runs yourtextthrough the configured formatting engine and returns the generated string as its result. If no-formatwas configured for the object, it throws an error. ๐
It assumes the text is in doctools format as specified in the companion document doctools_fmt. If it isn't? Errors will be thrown. So format your input correctly, bestie, or the vibes will be off. ๐ญ
objectName map symbolic actualโ this one adds a single entry to the per-object mapping from symbolic filenames to the actual uris. The object just stores that mapping and makes it available to the configured formatting engine through the commanddt_fmap. That command is described in more detail in the doctools plugin API reference, which spells out how the objects from this package and doctools formatting engines talk to each other. ๐บ๏ธobjectName parametersโ returns a list containing the names of all the engine parameters provided by the configured formatting engine. If the object isn't configured for a specific format yet, you get an empty list back. No format, no params, that's the rule. ๐objectName search pathโ extends the per-object list of paths searched for doctools formatting engines. Peep the command::doctools::searchif you wanna extend the per-package list instead. Heads up: the path entered last gets searched first. More details in FORMAT MAPPING. ๐objectName setparam name valueโ sets the named engine parameter to the specified value. It will throw an error if the object isn't configured for a specific format yet, or if the formatting engine for the configured format doesn't provide a parameter with that name. You can grab the list of parameters the configured engine provides via theparametersmethod. ๐งobjectName warningsโ returns a list containing all the warnings generated by the configured formatting engine during the last invocation of theformatmethod. Yes bestie, the receipts. ๐งพ
๐ OBJECT CONFIGURATION ๐
Every doctools object understands these configuration options. All of them. No skips. ๐
-file fileโ the argument of this option is stored in the object and made available to the configured formatting engine through the commandsdt_fileanddt_mainfile. Those commands are described in more detail in the companion documentdoctools_api, which specifies the API between the object and formatting engines.
Default value: the empty string.
The configured formatting engine should interpret the value as the name of the file containing the document currently being processed. ๐
-ibase fileโ the argument of this option is stored in the object and used as the base path for resolving relative include paths. If this option isn't set (empty string), the value of-fileis used instead.
Okay so real talk: -file and -ibase look similar but they are very different. The value of -file is used by some engines to generate proper relative references between output documents (HTML). So that one is a destination path. -ibase, on the other hand, is used to resolve relative include paths โ so it deals with source paths. Two totally different lanes, don't mix them up. ๐ฃ๏ธ
Default value: the empty string.
-module textโ the argument of this option is stored in the object and made available to the configured formatting engine through the commanddt_module. That command is described in more detail in the companion documentdoctools_api, which specifies the API between the object and formatting engines.
Default value: the empty string.
The configured formatting engine should interpret the value as the name of the module that the file containing the currently processed document belongs to. ๐ฆ
-format textโ the argument of this option specifies the format to generate, and by implication the formatting engine to use when converting text via theformatmethod. Its default value is the empty string. And heads up: theformatmethod can't be used if this option was never set to a valid value at least once. ๐ซ
The package will immediately try to map the given name to a file containing the code for a formatting engine that generates that format. If that mapping fails, an error gets thrown. And in that case, a previously configured format is left untouched. (So no, a bad format name won't nuke your old setup. Phew. ๐ฎโ๐จ)
The FORMAT MAPPING section explains in detail how the package and the object look for engine implementations.
-deprecated booleanโ this option is a boolean flag. The object will generate warnings if this flag is set and the text given to theformatmethod contains the deprecated markup commandstrong. Default value isFALSE. In other words, no warnings will be generated by default. ๐-copyright textโ the argument of this option is stored in the object and made available to the configured formatting engine through the commanddt_copyright. That command is described in more detail in the companion documentdoctools_api, which specifies the API between the object and formatting engines.
Default value: the empty string.
The configured formatting engine should interpret the value as a copyright assignment for the document currently being processed, or for the package described by it.
This information must be used if and only if the engine is unable to find any copyright assignments within the document itself. Those in-document ones are specified by the formatting commandcopyright, described in more detail in the companion documentdoctools_fmt, which specifies the doctools format itself. So like, fallback only, bestie. ๐
๐ FORMAT MAPPING ๐
The package and the object run this algorithm when they try to map a format name foo to a file containing an implementation of a formatting engine for foo. Watch the order, it's a whole journey:
- If
foois the name of an existing file, then that file is directly taken as the implementation. Easiest win ever. โจ - If not, the list of per-object search paths gets searched. For each directory in the list, the package checks whether that directory contains a file
"fmt.foo". If yes, that file is taken as the implementation.
Note that this list of paths is initially empty and can be extended through the object method search. ๐งบ
- If not, the list of package paths gets searched. For each directory in the list, the package checks whether that directory contains a file
"fmt.foo". If yes, that file is taken as the implementation.
This list of paths can be extended through the command ::doctools::search. It initially contains one path: the subdirectory "mpformats" of the directory the package itself is located in. In other words, if the package implementation doctools.tcl is installed in the directory /usr/local/lib/tcllib/doctools, then by default it will search the directory /usr/local/lib/tcllib/doctools/mpformats for format implementations. ๐๏ธ
- The mapping fails. ๐ That's it, that's the ending. No file for you.
โจ PREDEFINED ENGINES โจ
okay bestie so the package ships with a whole wardrobe of ready-to-go engines, one per format, and some of them let you pass parameters. we're gonna walk through all of them, parameters and everything, no skips ๐
๐ html
this one generates HTML markup โ perfect for web browsers and honestly anything browser-adjacent. it takes four parameters, and yes we're doing all four:
footerโ has to be valid, self-contained HTML markup for the body section of an HTML document. default is the empty string. it gets dropped into the generated output right before the closing</body>tag, i.e. it shuts the body of the generated HTML. vibe: use it to slide some boilerplate footer markup into the doc. ๐headerโ also valid, self-contained HTML markup for the body section of an HTML document. default is the empty string. this one lands in the generated output right after the opening<body>tag, i.e. it kicks off the body of the generated HTML. vibe: boilerplate header markup, inserted. โจmetaโ valid, self-contained HTML markup for the header section of an HTML document. default is the empty string. inserted into the generated output right after the opening<head>tag, i.e. it starts the header section of the generated HTML. vibe: boilerplate meta-data markup โ stylesheet references, standard meta keywords, all of that. ๐ฆxrefโ this one has to be a list of triples giving cross-reference info. the engine uses it to create extra hyperlinks. each triple is a list holding a pattern, a symbolic filename, and a fragment reference, in exactly that order. heads up: if a pattern shows up more than once, the last occurrence of that pattern is the one that wins. ๐
the engine hits up the xref database whenever it bumps into specific commands, and it makes a link if the relevant text matches one of the patterns. no match โ no link, periodt. the link points to the uri file#fragment from the relevant triple, after the symbolic file name gets converted into the actual uri via dt_fmap (peep the doctools plugin API reference for that one). that file-to-uri mapping was built by calls to the map method of the doctools object (see the OBJECT METHODS section).
these are the formatting commands that consult the xref database:
cmd wordโ looks for the patternssa,wordandword, in that order. if that flops, it converts word to all lowercase and tries again.syscmd wordโ looks for the patternssa,wordandword, in that order. if that flops, it converts word to all lowercase and tries again.term wordโ looks for the patternskw,word,sa,wordandword, in that order. if that flops, it converts word to all lowercase and tries again.package wordโ looks for the patternssa,word,kw,wordandword, in that order. if that flops, it converts word to all lowercase and tries again.see_also word...โ for each word handed to the command, it looks for the patternssa,wordandword, in that order. if that flops, it converts word to all lowercase and tries again.keywords word...โ for each word handed to the command, it looks for the patternskw,wordandword, in that order. if that flops, it converts word to all lowercase and tries again.
๐งช latex
generates output that's suitable for the latex text processor โ you know, the one that comes straight out of the TeX world. academic queen behavior honestly ๐
๐ list
this one pulls the version, section and title of the manpage out of the document. so basically it's the girl you call when you wanna generate a directory listing for a whole set of manpages. organized. ๐
๐ nroff
generates nroff output, for processing by nroff or groff. the result is your standard man pages, exactly like the unix world knows and loves them. classic, iconic, no notes. ๐
๐ markdown
generates Markdown markup. it takes two parameters:
headerโ has to be valid, self-contained markdown markup for the body section of a markdown document. default is the empty string. it gets inserted into the generated output right before the table of contents. vibe: boilerplate header markup, but make it markdown. ๐xrefโ has to be a list of triples specifying cross-reference info.
the full deets on the expected syntax and how the engine uses it internally are explained above, under the html engine. same energy, different format. โจ
๐ณ๏ธ null
generates literally no output at all. zero. nada. use it when you just wanna validate some input and don't need the receipts. ๐
๐ง tmml
generates TMML markup as specified by Joe English. the Tcl Manpage Markup Language is a derivate of XML. fancy. ๐ซถ
๐ wiki
generates Wiki markup as understood by Jean Claude Wippler's wikit application. wiki wiki, bestie. โจ
๐ BUGS, IDEAS, FEEDBACK ๐
ngl, this document and the package it describes will undoubtedly contain bugs and other problems. like, it's software, it's giving mortal. ๐ญ
please report them in the category doctools of the Tcllib Trackers at [http://core.tcl.tk/tcllib/reportlist]. also please send any ideas for enhancements you might have for either the package and/or the documentation. we want them, fr fr. ๐ซถ
if you're proposing code changes, please provide unified diffs โ that's the output of diff -u. no cap.
also note: attachments are strongly preferred over inlined patches. to attach something, go to the Edit form of the ticket immediately after creating it, and then use the left-most button in the secondary navigation bar. that's the move. ๐
๐ SEE ALSO ๐
doctools_introdoctools_lang_cmdrefdoctools_lang_introdoctools_lang_syntaxdoctools_plugin_apiref
๐ KEYWORDS ๐
HTML, TMML, conversion, documentation, manpage, markdown, markup, nroff
๐๏ธ CATEGORY ๐๏ธ
Documentation tools
ยฉ๏ธ COPYRIGHT ยฉ๏ธ
Copyright (c) 2003-2024 Andreas Kupries <andreas_kupries@users.sourceforge.net>
okay that's the whole page bestie, we ate and left no crumbs ๐ this was doctools(n) from tcllib, version 1.6.1 โ go forth and convert some docs, ily, 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) 2003-2024 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