Package: tcllib, Version: CVS HEAD
doctools_lang_intro -
doctools language introduction
This document is an informal introduction to version 1 of the doctools markup language based on a multitude of examples. After reading this a writer should be ready to understand the two parts of the formal specification, i.e. the doctools language syntax specification and the doctools language command reference.
Each markup command is a Tcl command surrounded by a matching pair of [ and ]. Inside of these delimiters the usual rules for a Tcl command apply with regard to word quotation, nested commands, continuation lines, etc. I.e.
... [list_begin enumerated] ...
... [call [cmd foo] \\ [arg bar]] ...
... [term {complex concept}] ...
... [opt "[arg key] [arg value]"] ...
[manpage_begin NAME SECTION VERSION] [description] [manpage_end]This also shows us that all doctools documents are split into two parts, the header and the body. Everything coming before [description] belongs to the header, and everything coming after belongs to the body, with the whole document bracketed by the two manpage_* commands. Before and after these opening and closing commands we have only whitespace.
In the remainder of this section we will discuss only the contents of the header, the structure of the body will be discussed in the section Text structure.
The header section can be empty, and otherwise may contain only an arbitrary sequence of the four so-called header commands, plus whitespace. These commands are
Given the above a less minimal example of a document is
[manpage_begin NAME SECTION VERSION] [copyright {YEAR AUTHOR}] [titledesc TITLE] [moddesc MODULE_TITLE] [require PACKAGE VERSION] [require PACKAGE] [description] [manpage_end]Remember that the whitespace is optional. The document
[manpage_begin NAME SECTION VERSION] [copyright {YEAR AUTHOR}][titledesc TITLE][moddesc MODULE_TITLE] [require PACKAGE VERSION][require PACKAGE][description] [manpage_end]has the same meaning as the example before.
On the other hand, if whitespace is present it consists not only of any sequence of characters containing the space character, horizontal and vertical tabs, carriage return, and newline, but it may contain comment markup as well, in the form of the comment command.
[comment { ... }] [manpage_begin NAME SECTION VERSION] [copyright {YEAR AUTHOR}] [titledesc TITLE] [moddesc MODULE_TITLE][comment { ... }] [require PACKAGE VERSION] [require PACKAGE] [description] [manpage_end] [comment { ... }]
Instead of only whitespace the two templating commands include and vset are also allowed, to enable the writer to either set and/or import configuration settings relevant to the document. I.e. it is possible to write
[include FILE] [vset VAR VALUE] [manpage_begin NAME SECTION VERSION] [description] [manpage_end]Even more important, these two commands are allowed anywhere where a markup command is allowed, without regard for any other structure. I.e. for example in the header as well.
[manpage_begin NAME SECTION VERSION] [include FILE] [vset VAR VALUE] [description] [manpage_end]The only restriction include has to obey is that the contents of the included file must be valid at the place of the inclusion. I.e. a file included before manpage_begin may contain only the templating commands vset and include, a file included in the header may contain only header commands, etc.
This section explains the high-level structural commands, with everything else deferred to the following sections.
The simplest way of structuring the body is through the introduction of paragraphs. The command for doing so is para. Each occurrence of this command closes the previous paragraph and automatically opens the next. The first paragraph is automatically opened at the beginning of the body, by description. In the same manner the last paragraph automatically ends at manpage_end.
[manpage_begin NAME SECTION VERSION] [description] ... [para] ... [para] ... [manpage_end]Empty paragraphs are ignored.
A structure coarser than paragraphs are sections, which allow the writer to split a document into larger, and labeled, pieces. The command for doing so is section. Each occurrence of this command closes the previous section and automatically opens the next, including its first paragraph. The first section is automatically opened at the beginning of the body, by description (This section is labeled "DESCRIPTION"). In the same manner the last section automatically ends at manpage_end.
Empty sections are not ignored. We are free to (not) use paragraphs within sections.
[manpage_begin NAME SECTION VERSION] [description] ... [section {Section A}] ... [para] ... [section {Section B}] ... [manpage_end]Between sections and paragraphs we have subsections, to split sections. The command for doing so is subsection. Each occurrence of this command closes the previous subsection and automatically opens the next, including its first paragraph. A subsection is automatically opened at the beginning of the body, by description, and at the beginning of each section. In the same manner the last subsection automatically ends at manpage_end.
Empty subsections are not ignored. We are free to (not) use paragraphs within subsections.
[manpage_begin NAME SECTION VERSION] [description] ... [section {Section A}] ... [subsection {Sub 1}] ... [para] ... [subsection {Sub 2}] ... [section {Section B}] ... [manpage_end]
While most often this is just the unadorned content of the document we do have situations where we wish to highlight parts of it as some type of thing or other, like command arguments, command names, concepts, uris, etc.
For this we have a series of markup commands which take the text to highlight as their single argument. It should be noted that while their predominant use is the highlighting of parts of a paragraph they can also be used to mark up the arguments of list item commands, and of other markup commands.
The commands available to us are
... [call [cmd arg_def] [arg type] [arg name]] [opt [arg mode]]] Text structure. List element. Argument list. Automatically closes the previous list element. Specifies the data-[arg type] of the described argument of a command, its [arg name] and its i/o-[arg mode]. The latter is optional. ...
Our example of their use are the sources of the last sentence in the previous paragraph, with some highlighting added.
... These commands, [cmd lb] and [cmd lb] respectively, are required because our use of [lb] and [rb] to bracket markup commands makes it impossible to directly use [lb] and [rb] within the text. ...
All the cross-reference commands can occur anywhere in the document between manpage_begin and manpage_end. As such the writer can choose whether she wants to have them at the beginning of the body, or at its end, maybe near the place a keyword is actually defined by the main content, or considers them as meta data which should be in the header, etc.
Our example shows the sources for the cross-references of this document, with some highlighting added. Incidentally they are found at the end of the body.
... [see_also doctools_intro] [see_also doctools_lang_syntax] [see_also doctools_lang_cmdref] [keywords markup {semantic markup}] [keywords {doctools markup} {doctools language}] [keywords {doctools syntax} {doctools commands}] [manpage_end]
The first opens an example block, the other closes it, and in between we can write plain text and use all the regular text markup commands. Note that text structure commands are not allowed. This also means that it is not possible to embed examples and lists within an example. On the other hand, we can use templating commands within example blocks to read their contents from a file (Remember section Advanced structure).
The source for the very first example in this document (see section Fundamentals), with some highlighting added, is
[example { ... [list_begin enumerated] ... }]Using example_begin / example_end this would look like
[example_begin] ... [list_begin enumerated] ... [example_end]
After the opening command only whitespace is allowed, until the first list item command opens the first item of the list. Each item is a regular series of paragraphs and is closed by either the next list item command, or the end of the list. If closed by a list item command this command automatically opens the next list item. A consequence of a list item being a series of paragraphs is that all regular text markup can be used within a list item, including examples and other lists.
The list types recognized by list_begin and their associated list item commands are:
... [list_begin definitions] [def [const arg]] ([cmd arg_def]) This opens an argument (declaration) list. It is a specialized form of a definition list where the term is an argument name, with its type and i/o-mode. [def [const itemized]] ([cmd item]) This opens a general itemized list. ... [def [const tkoption]] ([cmd tkoption_def]) This opens a widget option (declaration) list. It is a specialized form of a definition list where the term is the name of a configuration option for a widget, with its name and class in the option database. [list_end] ...Note that a list cannot begin in one (sub)section and end in another. Differently said, (sub)section breaks are not allowed within lists and list items. An example of this illegal construct is
... [list_begin itemized] [item] ... [section {ILLEGAL WITHIN THE LIST}] ... [list_end] ...
To be able to validate a document while writing it, it is also recommended to familiarize oneself with one of the applications for the processing and conversion of doctools documents, i.e. either Tcllib's easy and simple dtplite, or Tclapps' ultra-configurable dtp.
doctools_intro, doctools_lang_syntax, doctools_lang_cmdref, doctools_lang_faq
markup, semantic markup, doctools markup, doctools language, doctools syntax, doctools commands