1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736
|
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin doctools_api n 1.0]
[copyright {2002-2004 Andreas Kupries <andreas_kupries@users.sourceforge.net>}]
[moddesc {Documentation tools}]
[titledesc {Specification of the Interface to Doctools Formatting Engines}]
[description]
[para]
This document specifies version 1 of the interface a doctools
formatting engine has to comply with to be usable by the package
[package doctools].
The specification of the [term doctools] format all doctools
formatting engines have to process can be found in the companion
document [term doctools_fmt].
[section API]
[subsection {EXPORTED COMMANDS}]
Each doctools formatting engine has to provide a number of commands
through which objects created by the package [package doctools] will
upon the functionality of the engine. These commands are described
here.
[list_begin definitions]
[lst_item [emph {Management commands}]]
[list_begin definitions]
[call [cmd fmt_numpasses]]
This command is called by a doctools object immediately after it has
loaded the engine. No other command of the engine will be called
before it. It has to return the number of passes this engine requires
to fully process the input document. This value has to be an integer
number greater or equal to one.
[call [cmd fmt_initialize]]
This command is called at the beginning of every conversion run, as
the first command of that run. Note that a run is not a pass, but may
consist of multiple passes. See [cmd fmt_numpasses]. The command has
to initialize the general state of the doctools formatting engine,
beyond the initialization done during the load.
[call [cmd fmt_setup] [arg n]]
This command is called at the beginning of each pass over the input in
a run. Its argument is the number of the pass which has begun. Passes
are counted from [const 1] upward. The command has to set up the
internal state of the doctools formatting engine for this particular
pass.
[call [cmd fmt_postprocess] [arg text]]
This command is called immediately after the last pass in a run. Its
argument is the result of the conversion generated by that pass. It is
provided to allow the engine to perform any global last-ditch
modifications of the generated document. The text returned by this
command will be the final result of the conversion.
[nl]
An engine for a format which requires no postprocessing can simply
return the argument without change.
[call [cmd fmt_shutdown]]
This command is called at the end of every conversion run. It is the
last command called in a run. It has to clean up of all the
run-specific state in the doctools formatting engine. After the call
the engine has to be in a state which allows the initiation of another
run without fear that information from the last run is leaked into
this new run.
[call [cmd fmt_listvariables]]
This command is called by a doctools object after it has loaded the
engine (after [cmd fmt_numpasses]). It has to return a list containing
the names of the engine parameters provided by the engine. This list
can be empty.
[call [cmd fmt_varset] [arg varname] [arg text]]
This command is called whenever the doctools object wishes to set an
engine parameter to a particular value. The parameter to change is
specified by [arg varname], the value to set in [arg text].
[nl]
The command has to throw an error if an unknown [arg varname] is
used. Only the names returned by [cmd fmt_listvariables] are
considered known.
[nl]
The values of all engine parameters have to persist between passes and
runs.
[list_end]
[lst_item [emph {Formatting commands}]]
The commands listed in this section are responsible for the conversion
of the input into the wanted output.
Their names are the names of the associated markup command, with
prefix [const fmt_] added to them.
Not all markup commands have associated formatting commands. The two
exceptions are [cmd vset] and [cmd include]. These markup commands are
processed by the doctools object itself.
[nl]
A detailed documentation of the markup commands can be found in the
companion document [term doctools_fmt]. It is the formal specification
of the [term doctools] format.
[nl]
[emph Note]: The formatting commands can expect that they are only
called in an order allowed by the format specification.
[list_begin definitions]
[call [cmd fmt_plain_text] [arg text]]
This command has no associated markup command. It is called for any
plain text encountered by the processor in the input. It has to
perform any special processing required for plain text. The text
returned as its result is added to the output. If no special
processing is required it has to simply return its argument without
change.
[call [cmd fmt_comment] [arg text]]
This command has to format the [arg text] as a comment and return the
formatted string. It has to return the empty string if the output
format has no way of formatting comments.
[call [cmd fmt_manpage_begin] [arg command] [arg section] [arg version]]
This command has to format the [arg command] name, the [arg section]
the manpage resides in, and the [arg version] of the module as the
start of the generated manpage and return the formatted string.
[call [cmd fmt_manpage_end]]
This command has to generate the end of the generated manpage and
return the formatted string.
[call [cmd fmt_moddesc] [arg desc]]
This command remembers its argument [arg desc] as a short description
of the module the manpage resides in. It may or may not return a
formatted string.
[call [cmd fmt_titledesc] [arg desc]]
This command remembers its argument [arg desc] as the title of the
manpage. It may or may not return a formatted string. If this command
was omitted the argument of [cmd moddesc] has to be be used for the
title as well.
[call [cmd fmt_copyright] [arg text]]
This command remembers its argument [arg text] as declaration of a
copyright assignment for the manpage. When invoked more than once the
assignments have to be accumulated. It may or may not return a
formatted string.
[nl]
Assignments provided by this command have priority over information
supplied by an doctools processing application.
[call [cmd fmt_description]]
This command separates the header part of the manpage from the main
body. It may or may not return a formatted string.
[call [cmd fmt_require] [arg pkg] [opt [arg version]]]
This command remembers its arguments as name and version of a package
which is required by an application or other library to use the
described package. It may or may not return a formatted string.
[call [cmd fmt_section] [arg name]]
This command partitions the body of the manpage into named
sections. Note that the command [cmd description] at the beginning of
the manpage body implicitly started a section named "DESCRIPTION". A
section command has to close the last [cmd para]graph coming before it
and also open the first paragraph of the new section. It may or may
not return a formatted string.
[call [cmd fmt_subsection] [arg name]]
This command partitions the body of a [term section] into named
sub-sections.
A subsection command has to close the last [cmd para]graph coming
before it and also opens the first paragraph of the new section. It
may or may not return a formatted string.
[call [cmd fmt_para]]
This command partitions the text in a section or sub-section into
paragraphs. Each invokation has to close the paragraph coming before
it and open a new paragraph for the text coming after. It may or may
not return a formatted string.
[call [cmd fmt_see_also] [arg args]]
This command defines direct cross-references to other documents. Each
argument is a label identifying the referenced document. If this
command is used multiple times all the arguments have to accumulate.
It may or may not return a formatted string.
[call [cmd fmt_keywords] [arg args]]
This command defines the keywords applying to this document. Each
argument is a single keyword. If this command is used multiple times
all the arguments have to accumulate. It may or may not return a
formatted string.
[call [cmd fmt_arg] [arg text]]
This command declares that the argument [arg text] is the name of a
command argument. It has to return a formatted string.
[call [cmd fmt_cmd] [arg text]]
This command declares that the argument [arg text] is the name of a
command. It has to return a formatted string.
[call [cmd fmt_opt] [arg text]]
This command declares that the argument [arg text] is something
optional. It has to return a formatted string.
[call [cmd fmt_emph] [arg text]]
This command emphasizes the [arg text]. It has to return a formatted
string.
[call [cmd fmt_strong] [arg text]]
This command emphasizes the [arg text]. Same as [cmd emph]. Usage of
this command is discouraged. The command is deprecated and present
only for backward compatibility. It has to return a formatted string.
[call [cmd fmt_sectref] [arg text] [opt [arg label]]]
This command declares that the argument [arg text] is the name of a
section somewhere else in the document, and the current location
should refer to it. It has to return a formatted string.
If a [arg label] is specified then it has to be used in the returned
text. Otherwise the section title [arg text] is used.
[call [cmd fmt_syscmd] [arg text]]
This command declares that the argument [arg text] is the name of a
system command. It has to return a formatted string.
[call [cmd fmt_method] [arg text]]
This command declares that the argument [arg text] is the name of an
object method. It has to return a formatted string.
[call [cmd fmt_namespace] [arg text]]
This command declares that the argument [arg text] is the name of a
namespace. It has to return a formatted string.
[call [cmd fmt_option] [arg text]]
This command declares that the argument [arg text] is the name of an
option. It has to return a formatted string.
[call [cmd fmt_widget] [arg text]]
This command declares that the argument [arg text] is the name of a
widget. It has to return a formatted string.
[call [cmd fmt_fun] [arg text]]
This command declares that the argument [arg text] is the name of a
function. It has to return a formatted string.
[call [cmd fmt_type] [arg text]]
This command declares that the argument [arg text] is the name of a
data type. It has to return a formatted string.
[call [cmd fmt_package] [arg text]]
This command declares that the argument [arg text] is the name of a
package. It has to return a formatted string.
[call [cmd fmt_class] [arg text]]
This command declares that the argument [arg text] is the name of a
class. It has to return a formatted string.
[call [cmd fmt_var] [arg text]]
This command declares that the argument [arg text] is the name of a
variable. It has to return a formatted string.
[call [cmd fmt_file] [arg text]]
This command declares that the argument [arg text] is a file. It has
to return a formatted string.
[call [cmd fmt_uri] [arg text] [opt [arg text]]]
This command declares that the argument [arg text] is an uri. The
second argument, if it is present, is the human-readable description
of the uri. In other words, the label for the link. Without a labeling
text the uri is used as its own label. It has to return a formatted
string.
[call [cmd fmt_term] [arg text]]
This command declares that the argument [arg text] contains some
unspecific terminology. It has to return a formatted string.
[call [cmd fmt_const] [arg text]]
This command declares that the argument [arg text] is a constant
value. It has to return a formatted string.
[call [cmd fmt_nl]]
This command signals vertical space to separate blocks of text. It
may or may not return a formatted string.
[comment {
FUTURE: This is the same as para, but restricted to use inside of
list elements. Whereas para's are restricted to usage outside list
elements. Given that both do the same this separation is stupid.
Doctools V2 will have only one command, 'para', useable everywhere.
The formatting engine has to switch outputs, if truly necessary.
}]
[call [cmd fmt_example_begin]]
This command begins an example block. Subsequent text belongs to the
example. Line breaks, spaces, and tabs have to be preserved literally.
It may or may not return a formatted string.
[call [cmd fmt_example_end]]
This command closes the example block. It may or may not return a
formatted string.
[call [cmd fmt_list_begin] [arg what]]
This command starts new list. The value of the argument [arg what]
determines what type of list is opened. This also defines what command
has to be used to start an item in the new list. The allowed types
(and their associated item commands) are explained in the format
specification, i.e. [term doctools_fmt]. It may or may not return a
formatted string.
[call [cmd fmt_list_end]]
This command ends the list opened by the last [cmd list_begin]. It
may or may not return a formatted string.
[call [cmd fmt_bullet]]
This command starts a new list item in a bulletted list. The previous
item has to be closed automatically. It may or may not return a
formatted string.
[call [cmd fmt_enum]]
This command starts a new list item in an enumerated list. The
previous item has to be closed automatically. It may or may not
return a formatted string.
[call [cmd fmt_lst_item] [arg text]]
This command starts a new list item in a definition list. The argument
is the term to be defined. The previous item has to be closed
automatically. It may or may not return a formatted string.
[call [cmd fmt_call] [arg args]]
This command starts a new list item in a definition list, but the term
defined by it is a command and its arguments. The previous item is
automatically closed. The first argument is the name of the described
command, and everything after that are descriptions of the command
arguments. It may or may not return a formatted string.
[call [cmd fmt_arg_def] [arg type] [arg name] [opt [arg mode]]]
This command starts a new list item in an argument list. The previous
item has to be closed automatically. Specifies the data-[arg type] of
the described argument, its [arg name] and its i/o-[arg mode]. The
latter is optional. It may or may not return a formatted string.
[call [cmd fmt_opt_def] [arg name] [opt [arg arg]]]
This command starts a new list item in an option list. The previous
item has to be closed automatically. Specifies the [arg name] of the
option and its arguments ([arg arg]). The latter is a list, and can be
left out. It may or may not return a formatted string.
[call [cmd fmt_cmd_def] [arg command]]
This command starts a new list item in a command list. The previous
item has to be closed automatically.
Specifies the name of the [arg command]. It may or may not return a
formatted string.
[call [cmd fmt_tkoption_def] [arg name] [arg dbname] [arg dbclass]]
This command starts a new list item in a widget option list. The
previous item has to be closed automatically.
Specifies the [arg name] of the option, i.e. the name used in scripts,
the name used by the option database ([arg dbname]), and the class
(type) of the option ([arg dbclass]). It may or may not return a
formatted string.
[call [cmd fmt_usage] [arg args]]
This command is like [cmd call], except that a formatting engine must
not generate output at the location of the command. In other words,
this command is [emph silent]. The data it defines may appear in a
different section of the output, for example a table of contents, or
synopsis, depending on the formatting engine and its output format.
It may or may not return a formatted string.
[list_end]
[list_end]
[para]
[subsection {IMPORTED ENVIRONMENT}]
The implementation of a doctools formatting engine can make the
following assumptions about the environment it is executed in:
[list_begin enum]
[enum]
That it has full access to its own safe interpreter. In other words,
the engine cannot damage the other parts of the processor, nor can it
damage the filesystem.
[enum]
That the following commands are provided by the doctools object
controlling the engine:
[list_begin definitions]
[lst_item {Doctools commands}]
[list_begin definitions]
[call [cmd dt_copyright]]
This command returns a string containing the copyright information the
doctools object was configured with (option [option -copyright]).
[call [cmd dt_file]]
This command returns the full name of the file currently processed by
the engine.
[call [cmd dt_fileid]]
This command returns the name of the file currently processed by the
engine, without path, nor extension.
[call [cmd dt_fmap] [arg symfname]]
This command returns the actual name to use in the output in place of
the symbolic filename [arg symfname]. It will return the unchanged
input if no mapping was found for [arg symfname].
[call [cmd dt_format]]
This command returns the name of the format currently executing.
[call [cmd dt_lnesting]]
This command returns the number of lists currently open.
[call [cmd dt_module]]
This command returns the name of the module the file currently
processed belongs to.
[call [cmd dt_source] [arg file]]
This command allows the doctools formatting engine to load additional
tcl code.
Only files which are either in the same directory as the file
containing the engine, or below it, can be loaded. Trying to load a
file outside of this directory causes an error.
[call [cmd dt_user]]
This command returns the name of the current user as known to the tcl
interpreter the doctools object controlling the engine resides in.
[list_end]
[lst_item "Expander commands"]
All of the commands below are methods of the expander object (without
the prefix [const ex_]) handling the current input. This gives the
engine limited access to the state of the expander.
Their arguments and results are described in the documentation for the
package [package expander].
[list_begin definitions]
[call [cmd ex_cappend]]
[call [cmd ex_cget]]
[call [cmd ex_cis]]
[call [cmd ex_cname]]
[call [cmd ex_cpop]]
[call [cmd ex_cpush]]
[call [cmd ex_cset]]
[call [cmd ex_lb]]
[call [cmd ex_rb]]
[list_end]
[lst_item {Other commands}]
The file [file _common.tcl] contains default implementations
of [cmd fmt_plaint_text] and all the [const fmt_] commands
listed in section [sectref {EXPORTED COMMANDS}].
It resides in the subdirectory [file mpformats] containing all the
predefined formats. This means that all external formats (i.e. not
provided by the package [package doctools]) cannot use it immediately,
but have to have a copy at their location.
Additional commands provided by this file are:
[list_begin definitions]
[call [cmd c_inpass]]
This command returns the id of the pass currently executing.
[call [cmd c_begin]]
This command signals that processing of the text
after [cmd manpage_begin] has begun.
[call [cmd c_begun]]
This command checks the flag set by [cmd c_begin].
[call [cmd c_set_module] [arg text]]
This command remembers [arg text] as module information.
[call [cmd c_get_module]]
This command retrieves the module information
stored by [cmd c_set_module].
[call [cmd c_set_title] [arg text]]
This command remembers [arg text] as title.
[call [cmd c_get_title]]
This command retrieves the title stored by [cmd c_set_title].
[call [cmd c_provenance]]
This command returns a string describing how the input was processed.
[call [cmd c_pass] [arg {pass proc arguments body}]]
This command defines a procedure which is valid when pass [arg pass]
of the engine is executed.
[call [cmd c_holdBuffers] [arg args]]
This command defines one or more buffers for holding data between
passes.
[call [cmd c_hold] [arg {buffer entry}]]
This command adds an entry to the specified buffer.
The buffer has to be defined by an earlier invocation of the command
[cmd c_holdBuffers].
[call [cmd c_held] [arg buffer]]
This command retrieves the contents of the specified buffer. The
buffer is empty afterwards. All entries in the buffer are joined by
newlines.
[call [cmd c_cnext]]
This command increments the counter and return its current value.
[call [cmd c_cinit]]
This command pushes the current counter on the stack and reinitialize
the counter to zero.
[call [cmd c_creset]]
This command reinitializes the counter with the value on the counter
stack and removes that value from the stack.
[call [cmd NOP] [arg args]]
This command does nothing.
It can be used in conjunction with [cmd c_pass] to visibly declare in
which passes a formatting command has nothing to do.
[call [cmd NYI] [opt [arg message]]]
This command throws the error
"[arg message] [const {Not yet implemented}]".
[call [cmd c_sectionId] [arg name]]
This command remembers the name of the section for later
cross-referencing.
[call [cmd c_possibleReference] [arg {text gi}]]
This command checks if a section is available for [arg text]. This
command is currently tuned for use by engines like HTML and TMML.
[list_end]
[list_end]
[list_end]
[see_also doctools_fmt doctools]
[keywords markup {generic markup} manpage document TMML HTML nroff LaTeX]
[manpage_end]
|