diff options
| author | Andrew Morton <akpm@osdl.org> | 2003-08-14 10:25:14 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.osdl.org> | 2003-08-14 10:25:14 -0700 |
| commit | 6e88ebdf6a74a2de459c07fd5ab0403c30ff9aa3 (patch) | |
| tree | 5165240f684eaf8b0c353b722d5b0342bf7a0f07 /scripts/makeman | |
| parent | b0489fd741f77e6ef00cf8e07f737db00e97f714 (diff) | |
[PATCH] Docbook: Make mandocs output more terse
From: Michael Still <mikal@stillhq.com>
This patch takes into account requests from various LKML members for the
mandocs output to be more terse. Information about the copyright, and
formatting of the man page is moved into a comment at the start of the
groff output.
Sample output can be found at:
http://www.stillhq.com/linux/mandocs/2.6.0-test3-bk1/
Diffstat (limited to 'scripts/makeman')
| -rw-r--r-- | scripts/makeman | 119 |
1 files changed, 116 insertions, 3 deletions
diff --git a/scripts/makeman b/scripts/makeman index 3c6dc5b89f21..07b96e25ebc0 100644 --- a/scripts/makeman +++ b/scripts/makeman @@ -12,7 +12,7 @@ use strict; ## $3 -- the filename which contained the sgmldoc output ## (I need this so I know which manpages to convert) -my($LISTING); +my($LISTING, $GENERATED, $INPUT, $OUTPUT, $front, $mode, $filename); if($ARGV[0] eq ""){ die "Usage: makeman [convert | install] <dir> <file>\n"; @@ -32,8 +32,121 @@ if($ARGV[0] eq "convert"){ s/typedef //; chomp; - print "Processing $_\n"; - system("cd $ARGV[1]; docbook2man $_.sgml; gzip -f $_.9\n"); + $filename = $_; + print "Processing $filename\n"; + + # Open the input file to extract the front matter, generate the man page, + # and open it, and the rearrange everything until it is happy + open INPUT, "< $ARGV[1]/$filename.sgml"; + $front = ""; + $mode = 0; + while(<INPUT>){ + if(/.*ENDFRONTTAG.*/){ + $mode = 0; + } + + if($mode > 0){ + s/<!-- //; + s/ -->//; + s/<bookinfo>//; + s/<\/bookinfo>//; + s/<docinfo>//; + s<\/docinfo>//; + s/^[ \t]*//; + } + + if($mode == 2){ + if(/<para>/){ + } + elsif(/<\/para>/){ + $front = "$front.\\\" \n"; + } + elsif(/<\/legalnotice>/){ + $mode = 1; + } + elsif(/^[ \t]*$/){ + } + else{ + $front = "$front.\\\" $_"; + } + } + + if($mode == 1){ + if(/<title>(.*)<\/title>/){ + $front = "$front.\\\" This documentation was generated from the book titled \"$1\", which is part of the Linux kernel source.\n.\\\" \n"; + } + elsif(/<legalnotice>/){ + $front = "$front.\\\" This documentation comes with the following legal notice:\n.\\\" \n"; + $mode = 2; + } + + elsif(/<author>/){ + $front = "$front.\\\" Documentation by: "; + } + elsif(/<firstname>(.*)<\/firstname>/){ + $front = "$front$1 "; + } + elsif(/<surname>(.*)<\/surname>/){ + $front = "$front$1 "; + } + elsif(/<email>(.*)<\/email>/){ + $front = "$front($1)"; + } + elsif(/\/author>/){ + $front = "$front\n"; + } + + elsif(/<copyright>/){ + $front = "$front.\\\" Documentation copyright: "; + } + elsif(/<holder>(.*)<\/holder>/){ + $front = "$front$1 "; + } + elsif(/<year>(.*)<\/year>/){ + $front = "$front$1 "; + } + elsif(/\/copyright>/){ + $front = "$front\n"; + } + + elsif(/^[ \t]*$/ + || /<affiliation>/ + || /<\/affiliation>/ + || /<address>/ + || /<\/address>/ + || /<authorgroup>/ + || /<\/authorgroup>/ + || /<\/legalnotice>/ + || /<date>/ + || /<\/date>/ + || /<edition>/ + || /<\/edition>/){ + } + else{ + print "Unknown tag in manpage conversion: $_"; + } + } + + if(/.*BEGINFRONTTAG.*/){ + $mode = 1; + } + } + close INPUT; + + system("cd $ARGV[1]; docbook2man $filename.sgml; mv $filename.9 /tmp/$$.9\n"); + open GENERATED, "< /tmp/$$.9"; + open OUTPUT, "> $ARGV[1]/$filename.9"; + + print OUTPUT "$front"; + print OUTPUT ".\\\" For comments on the formatting of this manpage, please contact Michael Still <mikal\@stillhq.com>\n\n"; + while(<GENERATED>){ + print OUTPUT "$_"; + } + close OUTPUT; + close GENERATED; + + system("gzip -f $ARGV[1]/$filename.9\n"); + unlink("/tmp/$filename.9"); } } elsif($ARGV[0] eq "install"){ |
