The commands used to generate the documentation for a file can be imbedded in the file in a similar manner to the documentation itself. To activate this feature, use the -self option. For example, the documentation for document can be generated by typing:
% Document -self -shell Document
The -self option parses the input file and removes comment characters according to the setting of the source code option. The start_documentation keyword is set to Begin_Self_Document, and the end_documentation keyword is set to End_Self_Document. The -self option then removes any initial ``%'' sign (often used to indicate shell input), and executes each line in turn.
Here is an example self-documentation entry, in a Fortran code segment:
which would execute the following commands:
Document -fortran routine.F > routine.tex latex routine makeindex routine latex routine latex routine dvi routine latex2html -dir routinehtml -nomath -html_version 4.0,math routine
The -self option is equivalent to the -selftest option, and the beginning and ending keywords can be written as Begin_Self_Test and End_Self_Test. This usage underscores that the self-documentation (or self-test) feature is a very powerful feature with many uses - its primary function is simply to couple a script with some input data so that they can be maintained in sync. The function could be