aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Waitz <tali@admingilde.org>2005-05-01 11:59:27 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-01 11:59:27 -0400
commit8b0c2d989cc60db1767481386ca912e99807eddb (patch)
treed4987614a6171ce7eee3fa63023ce5ed4c45f8f7
parentac9296f95228f50d112e6caec3b461fd816de084 (diff)
[PATCH] DocBook: Use xmlto to process the DocBook files.
xmlto uses standared XSLT templates to generate manpages, (x)html pages, and XML FO files which can be processed with passivetex. This is much faster than using jadetex for everything. This patch also reduces the number of kernel-specific scripts that are needed to generate documentation. Signed-off-by: Martin Waitz <tali@admingilde.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--Documentation/Changes8
-rw-r--r--Documentation/DocBook/Makefile42
-rwxr-xr-xscripts/kernel-doc32
-rwxr-xr-xscripts/makeman185
-rwxr-xr-xscripts/split-man112
5 files changed, 53 insertions, 326 deletions
diff --git a/Documentation/Changes b/Documentation/Changes
index caa6a5529b6b..57542bc25edd 100644
--- a/Documentation/Changes
+++ b/Documentation/Changes
@@ -357,14 +357,14 @@ Quota-tools
357---------- 357----------
358o <http://sourceforge.net/projects/linuxquota/> 358o <http://sourceforge.net/projects/linuxquota/>
359 359
360Jade
361----
362o <ftp://ftp.jclark.com/pub/jade/jade-1.2.1.tar.gz>
363
364DocBook Stylesheets 360DocBook Stylesheets
365------------------- 361-------------------
366o <http://nwalsh.com/docbook/dsssl/> 362o <http://nwalsh.com/docbook/dsssl/>
367 363
364XMLTO XSLT Frontend
365-------------------
366o <http://cyberelk.net/tim/xmlto/>
367
368Intel P6 microcode 368Intel P6 microcode
369------------------ 369------------------
370o <http://www.urbanmyth.org/microcode/> 370o <http://www.urbanmyth.org/microcode/>
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 393082c7a3a2..a2441fa99c3f 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -41,14 +41,15 @@ MAN := $(patsubst %.xml, %.9, $(BOOKS))
41mandocs: $(MAN) 41mandocs: $(MAN)
42 42
43installmandocs: mandocs 43installmandocs: mandocs
44 $(MAKEMAN) install Documentation/DocBook/man 44 mkdir -p /usr/local/man/man9/
45 install Documentation/DocBook/man/*.9.gz /usr/local/man/man9/
45 46
46### 47###
47#External programs used 48#External programs used
48KERNELDOC = scripts/kernel-doc 49KERNELDOC = scripts/kernel-doc
49DOCPROC = scripts/basic/docproc 50DOCPROC = scripts/basic/docproc
50SPLITMAN = $(PERL) $(srctree)/scripts/split-man 51
51MAKEMAN = $(PERL) $(srctree)/scripts/makeman 52#XMLTOFLAGS = --skip-validation
52 53
53### 54###
54# DOCPROC is used for two purposes: 55# DOCPROC is used for two purposes:
@@ -95,29 +96,29 @@ $(obj)/procfs-guide.xml: $(C-procfs-example2)
95# Rules to generate postscript, PDF and HTML 96# Rules to generate postscript, PDF and HTML
96# db2html creates a directory. Generate a html file used for timestamp 97# db2html creates a directory. Generate a html file used for timestamp
97 98
98quiet_cmd_db2ps = DB2PS $@ 99quiet_cmd_db2ps = XMLTO $@
99 cmd_db2ps = db2ps -o $(dir $@) $< 100 cmd_db2ps = xmlto ps $(XMLTOFLAGS) -o $(dir $@) $<
100%.ps : %.xml 101%.ps : %.xml
101 @(which db2ps > /dev/null 2>&1) || \ 102 @(which xmlto > /dev/null 2>&1) || \
102 (echo "*** You need to install DocBook stylesheets ***"; \ 103 (echo "*** You need to install DocBook stylesheets ***"; \
103 exit 1) 104 exit 1)
104 $(call cmd,db2ps) 105 $(call cmd,db2ps)
105 106
106quiet_cmd_db2pdf = DB2PDF $@ 107quiet_cmd_db2pdf = XMLTO $@
107 cmd_db2pdf = db2pdf -o $(dir $@) $< 108 cmd_db2pdf = xmlto pdf $(XMLTOFLAGS) -o $(dir $@) $<
108%.pdf : %.xml 109%.pdf : %.xml
109 @(which db2pdf > /dev/null 2>&1) || \ 110 @(which xmlto > /dev/null 2>&1) || \
110 (echo "*** You need to install DocBook stylesheets ***"; \ 111 (echo "*** You need to install DocBook stylesheets ***"; \
111 exit 1) 112 exit 1)
112 $(call cmd,db2pdf) 113 $(call cmd,db2pdf)
113 114
114quiet_cmd_db2html = DB2HTML $@ 115quiet_cmd_db2html = XMLTO $@
115 cmd_db2html = db2html -o $(patsubst %.html,%,$@) $< && \ 116 cmd_db2html = xmlto xhtml $(XMLTOFLAGS) -o $(patsubst %.html,%,$@) $< && \
116 echo '<a HREF="$(patsubst %.html,%,$(notdir $@))/book1.html"> \ 117 echo '<a HREF="$(patsubst %.html,%,$(notdir $@))/book1.html"> \
117 Goto $(patsubst %.html,%,$(notdir $@))</a><p>' > $@ 118 Goto $(patsubst %.html,%,$(notdir $@))</a><p>' > $@
118 119
119%.html: %.xml 120%.html: %.xml
120 @(which db2html > /dev/null 2>&1) || \ 121 @(which xmlto > /dev/null 2>&1) || \
121 (echo "*** You need to install DocBook stylesheets ***"; \ 122 (echo "*** You need to install DocBook stylesheets ***"; \
122 exit 1) 123 exit 1)
123 @rm -rf $@ $(patsubst %.html,%,$@) 124 @rm -rf $@ $(patsubst %.html,%,$@)
@@ -125,15 +126,14 @@ quiet_cmd_db2html = DB2HTML $@
125 @if [ ! -z "$(PNG-$(basename $(notdir $@)))" ]; then \ 126 @if [ ! -z "$(PNG-$(basename $(notdir $@)))" ]; then \
126 cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi 127 cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi
127 128
128### 129quiet_cmd_db2man = XMLTO $@
129# Rule to generate man files - output is placed in the man subdirectory 130 cmd_db2man = if grep -q refentry $<; then xmlto man $(XMLTOFLAGS) -o $(obj)/man $< ; gzip -f $(obj)/man/*.9; fi
130 131%.9 : %.xml
131%.9: %.xml 132 @(which xmlto > /dev/null 2>&1) || \
132ifneq ($(KBUILD_SRC),) 133 (echo "*** You need to install DocBook stylesheets ***"; \
133 $(Q)mkdir -p $(objtree)/Documentation/DocBook/man 134 exit 1)
134endif 135 $(call cmd,db2man)
135 $(SPLITMAN) $< $(objtree)/Documentation/DocBook/man "$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)" 136 @touch $@
136 $(MAKEMAN) convert $(objtree)/Documentation/DocBook/man $<
137 137
138### 138###
139# Rules to generate postscripts and PNG imgages from .fig format files 139# Rules to generate postscripts and PNG imgages from .fig format files
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 62bf9fe50677..0835dc2a8aa9 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -581,8 +581,14 @@ sub output_function_xml(%) {
581 $id =~ s/[^A-Za-z0-9]/-/g; 581 $id =~ s/[^A-Za-z0-9]/-/g;
582 582
583 print "<refentry>\n"; 583 print "<refentry>\n";
584 print "<refentryinfo>\n";
585 print " <title>LINUX</title>\n";
586 print " <productname>Kernel Hackers Manual</productname>\n";
587 print " <date>$man_date</date>\n";
588 print "</refentryinfo>\n";
584 print "<refmeta>\n"; 589 print "<refmeta>\n";
585 print "<refentrytitle><phrase id=\"$id\">".$args{'function'}."</phrase></refentrytitle>\n"; 590 print " <refentrytitle><phrase id=\"$id\">".$args{'function'}."</phrase></refentrytitle>\n";
591 print " <manvolnum>9</manvolnum>\n";
586 print "</refmeta>\n"; 592 print "</refmeta>\n";
587 print "<refnamediv>\n"; 593 print "<refnamediv>\n";
588 print " <refname>".$args{'function'}."</refname>\n"; 594 print " <refname>".$args{'function'}."</refname>\n";
@@ -651,8 +657,14 @@ sub output_struct_xml(%) {
651 $id =~ s/[^A-Za-z0-9]/-/g; 657 $id =~ s/[^A-Za-z0-9]/-/g;
652 658
653 print "<refentry>\n"; 659 print "<refentry>\n";
660 print "<refentryinfo>\n";
661 print " <title>LINUX</title>\n";
662 print " <productname>Kernel Hackers Manual</productname>\n";
663 print " <date>$man_date</date>\n";
664 print "</refentryinfo>\n";
654 print "<refmeta>\n"; 665 print "<refmeta>\n";
655 print "<refentrytitle><phrase id=\"$id\">".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n"; 666 print " <refentrytitle><phrase id=\"$id\">".$args{'type'}." ".$args{'struct'}."</phrase></refentrytitle>\n";
667 print " <manvolnum>9</manvolnum>\n";
656 print "</refmeta>\n"; 668 print "</refmeta>\n";
657 print "<refnamediv>\n"; 669 print "<refnamediv>\n";
658 print " <refname>".$args{'type'}." ".$args{'struct'}."</refname>\n"; 670 print " <refname>".$args{'type'}." ".$args{'struct'}."</refname>\n";
@@ -729,8 +741,14 @@ sub output_enum_xml(%) {
729 $id =~ s/[^A-Za-z0-9]/-/g; 741 $id =~ s/[^A-Za-z0-9]/-/g;
730 742
731 print "<refentry>\n"; 743 print "<refentry>\n";
744 print "<refentryinfo>\n";
745 print " <title>LINUX</title>\n";
746 print " <productname>Kernel Hackers Manual</productname>\n";
747 print " <date>$man_date</date>\n";
748 print "</refentryinfo>\n";
732 print "<refmeta>\n"; 749 print "<refmeta>\n";
733 print "<refentrytitle><phrase id=\"$id\">enum ".$args{'enum'}."</phrase></refentrytitle>\n"; 750 print " <refentrytitle><phrase id=\"$id\">enum ".$args{'enum'}."</phrase></refentrytitle>\n";
751 print " <manvolnum>9</manvolnum>\n";
734 print "</refmeta>\n"; 752 print "</refmeta>\n";
735 print "<refnamediv>\n"; 753 print "<refnamediv>\n";
736 print " <refname>enum ".$args{'enum'}."</refname>\n"; 754 print " <refname>enum ".$args{'enum'}."</refname>\n";
@@ -789,8 +807,14 @@ sub output_typedef_xml(%) {
789 $id =~ s/[^A-Za-z0-9]/-/g; 807 $id =~ s/[^A-Za-z0-9]/-/g;
790 808
791 print "<refentry>\n"; 809 print "<refentry>\n";
810 print "<refentryinfo>\n";
811 print " <title>LINUX</title>\n";
812 print " <productname>Kernel Hackers Manual</productname>\n";
813 print " <date>$man_date</date>\n";
814 print "</refentryinfo>\n";
792 print "<refmeta>\n"; 815 print "<refmeta>\n";
793 print "<refentrytitle><phrase id=\"$id\">typedef ".$args{'typedef'}."</phrase></refentrytitle>\n"; 816 print " <refentrytitle><phrase id=\"$id\">typedef ".$args{'typedef'}."</phrase></refentrytitle>\n";
817 print " <manvolnum>9</manvolnum>\n";
794 print "</refmeta>\n"; 818 print "</refmeta>\n";
795 print "<refnamediv>\n"; 819 print "<refnamediv>\n";
796 print " <refname>typedef ".$args{'typedef'}."</refname>\n"; 820 print " <refname>typedef ".$args{'typedef'}."</refname>\n";
diff --git a/scripts/makeman b/scripts/makeman
deleted file mode 100755
index db3af647ee17..000000000000
--- a/scripts/makeman
+++ /dev/null
@@ -1,185 +0,0 @@
1#!/usr/bin/perl
2
3use strict;
4
5## Copyright (C) Michael Still (mikal@stillhq.com)
6## Released under the terms of the GNU GPL
7##
8## A script to make or install the manpages extracted by split-man
9##
10## Arguements: $1 -- the word "convert" or "install"
11## $2 -- the directory containing the SGML files for the manpages
12## $3 -- the filename which contained the sgmldoc output
13## (I need this so I know which manpages to convert)
14
15my($LISTING, $GENERATED, $INPUT, $OUTPUT, $front, $mode, $filename, $tmpdir);
16
17if($ARGV[0] eq ""){
18 die "Usage: makeman [convert | install] <dir> <file>\n";
19}
20
21if( ! -d "$ARGV[1]" ){
22 die "Output directory \"$ARGV[1]\" does not exist\n";
23}
24
25if($ENV{"TMPDIR"} ne ""){
26 $tmpdir = $ENV{"TMPDIR"};
27}
28else{
29 $tmpdir = "/tmp";
30}
31
32if($ARGV[0] eq "convert"){
33 open LISTING, "grep \"<refentrytitle>\" $ARGV[2] |";
34 while(<LISTING>){
35 s/<\/.*$//;
36 s/^.*>//;
37 s/\.sgml//;
38 s/struct //;
39 s/typedef //;
40
41 chomp;
42 $filename = $_;
43 print "Processing $filename\n";
44
45 # Open the input file to extract the front matter, generate the man page,
46 # and open it, and the rearrange everything until it is happy
47 open INPUT, "< $ARGV[1]/$filename.sgml";
48 $front = "";
49 $mode = 0;
50
51 # The modes used here are:
52 # mode = 0
53 # <!-- BEGINFRONTTAG -->
54 # <!-- <bookinfo> mode = 1
55 # <!-- <legalnotice> mode = 2
56 # <!-- ...GPL or whatever...
57 # <!-- </legalnotice> mode = 4
58 # <!-- </bookinfo> mode = 3
59 # <!-- ENDFRONTTAG -->
60 #
61 # ...doco...
62
63 # I know that some of the if statements in this while loop are in a funny
64 # order, but that is deliberate...
65 while(<INPUT>){
66 if($mode > 0){
67 s/<!-- //;
68 s/ -->//;
69 s/<docinfo>//i;
70 s<\/docinfo>//i;
71 s/^[ \t]*//i;
72 }
73
74 if($mode == 2){
75 if(/<para>/i){
76 }
77 elsif(/<\/para>/i){
78 $front = "$front.\\\" \n";
79 }
80 elsif(/<\/legalnotice>/i){
81 $mode = 4;
82 }
83 elsif(/^[ \t]*$/){
84 }
85 else{
86 $front = "$front.\\\" $_";
87 }
88 }
89
90 if($mode == 1){
91 if(/<title>(.*)<\/title>/i){
92 $front = "$front.\\\" This documentation was generated from the book titled \"$1\", which is part of the Linux kernel source.\n.\\\" \n";
93 }
94 elsif(/<legalnotice>/i){
95 $front = "$front.\\\" This documentation comes with the following legal notice:\n.\\\" \n";
96 $mode = 2;
97 }
98
99 elsif(/<author>/i){
100 $front = "$front.\\\" Documentation by: ";
101 }
102 elsif(/<firstname>(.*)<\/firstname>/i){
103 $front = "$front$1 ";
104 }
105 elsif(/<surname>(.*)<\/surname>/i){
106 $front = "$front$1 ";
107 }
108 elsif(/<email>(.*)<\/email>/i){
109 $front = "$front($1)";
110 }
111 elsif(/\/author>/i){
112 $front = "$front\n";
113 }
114
115 elsif(/<copyright>/i){
116 $front = "$front.\\\" Documentation copyright: ";
117 }
118 elsif(/<holder>(.*)<\/holder>/i){
119 $front = "$front$1 ";
120 }
121 elsif(/<year>(.*)<\/year>/i){
122 $front = "$front$1 ";
123 }
124 elsif(/\/copyright>/i){
125 $front = "$front\n";
126 }
127
128 elsif(/^[ \t]*$/
129 || /<affiliation>/i
130 || /<\/affiliation>/i
131 || /<address>/i
132 || /<\/address>/i
133 || /<authorgroup>/i
134 || /<\/authorgroup>/i
135 || /<\/legalnotice>/i
136 || /<date>/i
137 || /<\/date>/i
138 || /<edition>/i
139 || /<\/edition>/i
140 || /<pubdate>/i
141 || /<\/pubdate>/i){
142 }
143 else{
144 print "Unknown tag in manpage conversion: $_";
145 }
146 }
147
148 if($mode == 0){
149 if(/<bookinfo>/i){
150 $mode = 1;
151 }
152 }
153
154 if($mode == 4){
155 if(/<\/bookinfo>/i){
156 $mode = 3;
157 }
158 }
159 }
160 close INPUT;
161
162 system("cd $ARGV[1]; docbook2man $filename.sgml; mv $filename.9 $tmpdir/$$.9\n");
163 open GENERATED, "< $tmpdir/$$.9";
164 open OUTPUT, "> $ARGV[1]/$filename.9";
165
166 print OUTPUT "$front";
167 print OUTPUT ".\\\" For comments on the formatting of this manpage, please contact Michael Still <mikal\@stillhq.com>\n\n";
168 while(<GENERATED>){
169 print OUTPUT "$_";
170 }
171 close OUTPUT;
172 close GENERATED;
173
174 system("gzip -f $ARGV[1]/$filename.9\n");
175 unlink("$tmpdir/$$.9");
176 }
177}
178elsif($ARGV[0] eq "install"){
179 system("mkdir -p /usr/local/man/man9/; install $ARGV[1]/*.9.gz /usr/local/man/man9/");
180}
181else{
182 die "Usage: makeman [convert | install] <dir> <file>\n";
183}
184
185print "Done\n";
diff --git a/scripts/split-man b/scripts/split-man
deleted file mode 100755
index 03897fe6a75d..000000000000
--- a/scripts/split-man
+++ /dev/null
@@ -1,112 +0,0 @@
1#!/usr/bin/perl
2
3use strict;
4
5## Copyright (C) Michael Still (mikal@stillhq.com)
6## Released under the terms of the GNU GPL
7##
8## Hoon through the specified DocBook SGML file, and split out the
9## man pages. These can then be processed into groff format, and
10## installed if desired...
11##
12## Arguements: $1 -- the name of the sgml file
13## $2 -- the directory to put the generated SGML files in
14## $3 -- kernel version
15
16my($SGML, $REF, $front, $refdata, $mode, $filename);
17
18if(($ARGV[0] eq "") || ($ARGV[1] eq "") || ($ARGV[2] eq "")){
19 die "Usage: split-man <sgml file> <output dir> <kernel version>\n";
20}
21
22open SGML, "< $ARGV[0]" or die "Could not open input file \"$ARGV[0]\"\n";
23if( ! -d "$ARGV[1]" ){
24 die "Output directory \"$ARGV[1]\" does not exist\n";
25}
26
27# Possible modes:
28# 0: Looking for input I care about
29# 1: Inside book front matter
30# 2: Inside a refentry
31# 3: Inside a refentry, and we know the filename
32
33$mode = 0;
34$refdata = "";
35$front = "";
36while(<SGML>){
37 # Starting modes
38 if(/<bookinfo>/ || /<docinfo>/){
39 $mode = 1;
40 }
41 elsif(/<refentry>/){
42 $mode = 2;
43 }
44 elsif(/<refentrytitle><phrase[^>]*>([^<]*)<.*$/){
45 $mode = 3;
46 $filename = $1;
47
48 $filename =~ s/struct //;
49 $filename =~ s/typedef //;
50
51 print "Found manpage for $filename\n";
52 open REF, "> $ARGV[1]/$filename.sgml" or
53 die "Couldn't open output file \"$ARGV[1]/$filename.sgml\": $!\n";
54 print REF <<EOF;
55<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
56
57<!-- BEGINFRONTTAG: The following is front matter for the parent book -->
58$front
59<!-- ENDFRONTTAG: End front matter -->
60
61$refdata
62EOF
63 $refdata = "";
64 }
65
66 # Extraction
67 if($mode == 1){
68 chomp $_;
69 $front = "$front<!-- $_ -->\n";
70 }
71 elsif($mode == 2){
72 $refdata = "$refdata$_";
73 }
74 elsif($mode == 3){
75 # There are some fixups which need to be applied
76 if(/<\/refmeta>/){
77 print REF "<manvolnum>9</manvolnum>\n";
78 }
79 if(/<\/refentry>/){
80 print REF <<EOF;
81<refsect1><title>About this document</title>
82<para>
83This documentation was generated with kernel version $ARGV[2].
84</para>
85</refsect1>
86EOF
87 }
88
89 # For some reason, we title the synopsis twice in the main DocBook
90 if(! /<title>Synopsis<\/title>/){
91 if(/<refentrytitle>/){
92 s/struct //;
93 s/typedef //;
94 }
95
96 print REF "$_";
97 }
98 }
99
100 # Ending modes
101 if(/<\/bookinfo>/ || /<\/docinfo>/){
102 $mode = 0;
103 }
104 elsif(/<\/refentry>/){
105 $mode = 0;
106 close REF;
107 }
108}
109
110# And make sure we don't process this unnessesarily
111$ARGV[0] =~ s/\.sgml/.9/;
112`touch $ARGV[0]`;