The Doc and Shortvrb Packages∗
Total Page:16
File Type:pdf, Size:1020Kb
The doc and shortvrb Packages∗ Frank Mittelbachy June 15, 2021 This file is maintained byA theLTEX Project team. Bug reports can be opened (category latex) at https://latex-project.org/bugs.html. Abstract This package contains the definitions that are necessary to format the documentation of package files. The package was developed in Mainz in cooperation with the Royal Military College of Science. This is an update which documents various changes and new features in doc and integrates the features of newdoc. Contents 1 Introduction3 2.10 Changing the default val- 1.1 Using the doc package..4 ues of style parameters.. 10 2.11 Short input of verbatim 2 The User Interface4 text pieces......... 10 2.1 The driver file.......4 2.12 Additional bells and 2.2 General conventions...5 whistles.......... 10 2.3 Describing the usage of 2.13 Basic usage summary.. 13 new macros........6 2.14 Acknowledgements.... 14 2.4 Describing the definition of new macros.......6 3 The Description of Macros 14 2.5 Formatting the margins.6 3.1 Options supported by doc 15 2.6 Using a special escape 3.2 Macros surrounding the character.........7 ‘definition parts'..... 15 2.7 Cross-referencing all 3.3 Macros for the `docu- macros used........7 mentation parts'..... 22 2.8 Producing the actual in- 3.4 Formatting the margin.. 27 dex entries.........8 3.5 Creating index entries by 2.9 Setting the index entries.9 scanning `macrocode'... 27 ∗This file has version number v2.1n dated 2021/05/28. yFurther commentary added at Royal Military College of Science by B. Hamilton Kelly; English translation of parts of the original German commentary provided by Andrew Mills; fairly substantial additions, particularly from newdoc, and documentation of post-v1.5q features added at v1.7a by Dave Love (SERC Daresbury Lab). Extraction of shortvrb package added by Joachim Schrod (TU Darmstadt). 1 3.6 Macros for scanning 3.12 Providing a checksum macro names....... 29 and character table.... 50 3.7 The index exclude list.. 33 3.13 Attaching line numbers 3.8 Macros for generating in- to code lines........ 52 dex entries......... 35 3.14 Layout Parameters for 3.9 Redefining the index en- documenting package files 53 vironment......... 38 3.10 Dealing with the change 3.15 Changing the \catcode history........... 42 of %............ 54 3.11 Bells and whistles..... 45 3.16 GetFileInfo........ 54 Preface to version 1.7 This version of doc.dtx documents Checksum/character table support changes which have occurred since the for ensuring the integrity of dis- last published version [5] but which have tributions is added; been present in distributed versions of becomes ; doc.sty for some time. It also inte- \printindex \PrintIndex grates the (undocumented) features of multicol.sty is no longer necessary the distributed newdoc.sty. to use doc or print the docu- The following changes and additions mentation (although it is recom- have been made to the user interface mended); since the published version [5]. See §2 for more details. `Docstrip' modules are recognised and formatted specially. Driver mechanism \DocInput is now used in the driver file to input As well as adding some completely possibly multiple independent doc new stuff, the opportunity has been files and doc no longer has to be taken to add some commentary to the the last package. \IndexListing code formerly in newdoc.sty and that is replaced by \IndexInput; added after version 1.5k of doc.sty. Since (as noted in the sections con- Indexing is controlled by \PageIndex cerned) this commentary wasn't writ- and \CodelineIndex, one of ten by Frank Mittelbach but the code which must be specified to pro- was, it is probably not true in this case duce an index|there is no longer that \if the code and comments disagree a \makeindex in the default both are probably wrong"! \DocstyleParms; The macro environment now takes Bugs as argument the macro name with There are some known bugs in this ver- the backslash; sion: Verbatim text Newlines are now for- • The \DoNotIndex command bidden inside \verb and com- doesn't work for some single char- mands \MakeShortVerb and acter commands most noticeable \DeleteShortVerb are provided \%. for verbatim shorthand; • The `General changes' glossary \par can now be used in \DoNotIndex; entry would come out after macro 2 names with a leading ! and possi- Wish list bly a leading "; • Hooks to allow \DescribeMacro • If you have an old version of make- and \DescribeEnv to write out index long \changes entries will to a special file information about come out strangely and you may the package's `exported' defini- find the section header amalga- tions which they describe. This mated with the first changes en- could subsequently be included in try. Try to get an up-to-date one the docstripped .sty file in a (see p.9); suitable form for use by smart editors in command completion, • Because the accompanying make- spelling checking etc., based on index style files support the in- the packages used in a document. consistent attribute specifications This would need agreement on a of older and newer versions make- `suitable form'. index always complains about three `unknown specifier’s when • Indexing of the modules used in sorting the index and changes en- docstrip's %< directives. I'm not tries. sure how to index directives con- • If \MakeShortVerb and taining module combinations; \DeleteShortVerb are used with single character arguments, e.g., • Writing out bibliographic infor- mation about the package; {|} instead of {\|} chaos may happen. • Allow turning off use of the spe- (Some `features' are documented be- cial font for, say, the next guarded low.) block. 1 Introduction The TEX macros which are described tion was born with the development of here allow definitions and documenta- the TEX program; it was crystallized tion to be held in one and the same file. in Pascal with the Web system. The This has the advantage that normally advantages of this method are plain to very complicated instructions are made see (it's easy to make comparisons [2]). simpler to understand by comments in- Since this development, systems similar side the definition. In addition to this, to Web have been developed for other updates are easier and only one source programming languages. But for one file needs to be changed. On the other of the most complicated programming hand, because of this, the package files languages (TEX) the documentation has are considerably longer: thus TEX takes however been neglected. The TEX world longer to load them. If this is a prob- seems to be divided between:| lem, there is an easy remedy: one needs only to run the docstrip.tex program • a couple of \wizards", who pro- that removes nearly all lines that begin duce many lines of completely un- with a percent sign. readable code “off the cuff", and The idea of integrated documenta- • many users who are amazed that 3 it works just how they want it to ing point, but because from this start- do. Or rather, who despair that ing point it was the quickest to develop.2 certain macros refuse to do what As a result of this design decision, I had is expected of them. to move away from the concept of mod- I do not think that the Web sys- ularization; this was certainly a step tem is the reference work; on the con- backward. trary, it is a prototype which suffices I would be happy if this article could for the development of programs within spark off discussion overE T X docu- mentation. I can only advise anyone the TEX world. It is sufficient, but not totally sufficient.1 As a result who thinks that they can cope with- of Web, new programming perspec- out documentation to \Stop Time" un- tives have been demonstrated; unfortu- til he or she completely understands the nately, though, they haven't been de- AMS-TEX source code. veloped further for other programming languages. 1.1 Using the doc package The method of documentation of TEX macros which I have introduced Just like any other package, invoke it by here should also only be taken as a first requesting it with a \usepackage com- sketch. It is designed explicitly to run mand in the preamble. Doc's use of under LATEX alone. Not because I was of \reversemarginpars may make it in- the opinion that this was the best start- compatible with some classes. 2 The User Interface 2.1 The driver file If one is going to document a set of macros with the doc package one has to prepare a special driver file which produces the formatted document. This driver file has the following characteristics: \documentclass[hoptionsi]{hdocument-classi} \usepackage{doc} hpreamblei \begin{document} hspecial input commandsi \end{document} The hdocument-classi might be any document class, I normally use article. In the hpreamblei one should place declarations which manipulate the behavior of the doc package like \DisableCrossrefs or \OnlyDescription. \DocInput Finally the hspecial input commandsi part should contain one or more \IndexInput \DocInputhfile namei and/or \IndexInputhfile namei commands. The \DocInput command is used for files prepared for the doc package whereas \IndexInput can be used for all kinds of macro files. See page 11 for more details of \IndexInput. Multiple \DocInputs can be used with a number of included files 1I know that this will be seen differently by a few people, but this product should notbe seen as the finished product, at least as far as applications concerningE T X are concerned. The long-standing debate over `multiple change files’ shows this well.