📄 doctool.txt
字号:
DoctoolDJ Delorie <dj@cygnus.com>These are the instructions for using doctool. Yes, I should havewritten them *in* DocBook, but hey, I was in a hurry.OK, doctool is a program that gathers snippets of a docbook document andputs them all together in the right order. There are threeplaces that it gets snippets from:1. The document that you tell it you want "finished"2. blocks of SGML in *.sgml files3. comments in source codeThe first of these is the template file, which is to say, it's anormal SGML file (sort of). This file is the first one read, andincludes such things as your <book> tags etc. It contains commands todoctool to tell it where to put the other parts.The second, the *.sgml files, contain one or more blocks of SGML.To work with doctool, each of these snippets must begin and endwith matching tags, must have an id="" attribute, and the start/endtags must begin at the beginning of the line. For example:<foo id="frob-45"> stuff goes here</foo><bar id="frob-48"> stuff goes here</bar>In this example, the file contains two snippets, one marked by "foo"and one barked by "bar", with id's "from-45" and "from-48". Note thatI made up the foo and bar tags. You'd usually use a <sect1> tag orsomething useful like that. Stuff outside the blocks is ignored.The third is simply an encapsulation of the second in comments, like this:/* DOCTOOL-START<foo id="frob-45"> stuff goes here</foo>DOCTOOL-END */The DOCTOOL-START and DOCTOOL-END things are special. Doctool usesthose to know which parts of which comments are useful, and whichparts are the useless source code stuff ;-)OK, so now we've got all these snippets of SGML floating around. Whatdo we do with them? Well, inside the template document (#1 in ourlist up there) you'd put text snippets that said "ok, put themhere". Each text snippet looks like this:DOCTOOL-INSERT-frob-Note that the "frob-" part tells doctool to pull in all the snippetswith IDs that start with "frob-", in alphabetical (well, asciibeticalat the moment) order. So, by saying "DOCTOOL-INSERT-frob-" you'd getall the "frob-*" snippets, like "frob-45" and "frob-48".If you just said DOCTOOL-INSERT-frob, it inserts the snippet named"frob" and no others.Note that no snippet will ever be inserted more than once, no matterhow many DOCTOOL-INSERTs you have.There's two other tricks doctool has. If it finds a snippet with an IDlike "int-*" (i.e. int-frob-45) that means that snippet of documentationis for the "internal" version only. The "int-" is discarded, and ifthe -i option is given to doctool, this snippet is treated as if theint- wasn't there. Without the -i, the int-* snippets are ignoredcompletely.If a snippet has "add-" on it, like "add-frob-45", that's an addendum.Each time a snippet named without the add- is found, doctool looks foran addendum with exactly that same name (i.e. frob-45 looks foradd-frob-45). If it finds any, it puts them just before the last lineof the non-add snippet (so that it's *inside* the main snippet'sblock, not after it). Example:<sect1 id="frob-45"> some text</sect1><sect1 id="add-frob-45"> more text</sect1>This would yield:<sect1 id="frob-45"> some text more text</sect1>You should use the same outermost tags as the main snippet, but onlybecause it sets the proper nesting rules for what's enclosed.You can use add- and int- at the same time, but always do add-int- andnot int-add- (i.e. "add-int-frob-45").OK, now for doctool command line options.-m tells doctool to "fix" the Makefile (not makefile) to include theextra dependencies needed by the file you're generating. You need tomanually include dependencies on the Makefile itself and the templatefile; doctool only includes the snippet files (sources etc) that itactually pulled content from. Note: this isn't perfect! Someone cancome along and add a new snippet to a source file, and doctool wouldnever know. Sometimes, it's best to just rebuild the docs all thetime.-i means to include snippets with the "int-" prefix on their IDs. Usewith -b to make internal and public versions from the same sources."-d dir" tells doctool to scan all the files in that directory (andsubdirectories, recursively) for files that might contain snippets ofSGML. These include *.c, *.cc, *.h, and *.sgml. The idea is thatmost of the documentation would be in a *.sgml file named after thesource (i.e. foo.c -> foo.sgml) but some commentary within the sourcemight be useful in the docs as well. SGML files (*.sgml) do not needthe DOCTOOL-START/END tags but the others do.-o sets the output file. Without -o, the file goes to stdout (ick).-s tells doctool to supress a "source directory prefix". What thismeans is that, in the generated output doctool puts comments that saywhere each snippet comes from (for debugging), which includes the fullpath sometimes, but if you use -s, you can tell doctool to cut offthat prefix. For example,/usr/people/dj/src/cygnus/latest/devo/winsup/foo.c might get shortenedto winsup/foo.c if you gave "-s/usr/people/dj/src/cygnus/latest/devo/". Cygnus makefiles couldjust use -s $(srcdir) most of the time.-b changes the ID for the <book> tag. db2html uses the <book> tag'sID as the default subdirectory name and/or html file name to createthe book with. You'd need this to generate two books (internal vspublic) from the same source.The only other thing you'd add to the command line is the ONE templatefile you want to pull in.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -