Skip to contentSkip to conversation

docbook: Added support for generating man files

PATCH In review Sam Ravnborg 4 participants 9 messages Jul 18, 2003 – Jul 19, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 docbook: Added support for generating man files

Hi Linus - please apply. Only docbook relevant changes.

Originally by Michael Still <[email protected]>

This patch adds two new targets to the docbook makefile -- mandocs, and installmandocs. The targets require two new perl scripts in the scripts/ directory, but in return we get a series of man pages for kernel functions, which are installed in man section 9. This is a good thing, as many programmers expect documentation to be available with man, and hunting through various PS or PDF documents to find the documentation for the function you want can be quite frustrating.

The man pages are just extracted from the various existing DocBook SGML documents, which are generated by kernel-doc. You also need to have docbook2man installed on your machine.

Please note the formatting is not perfect, but I will tweak other stuff later with further patches -- this is just an initial implementation.

Sample output (HTMLised) can be found at
http://www.stillhq.com/linux/mandocs/2.5.68/ and
http://www.stillhq.com/linux/mandocs/2.5.70/

#1 lore raw

Hi Linus - please apply. Only docbook relevant changes [with patch this time].

Originally by Michael Still <[email protected]>

This patch adds two new targets to the docbook makefile -- mandocs, and installmandocs. The targets require two new perl scripts in the scripts/ directory, but in return we get a series of man pages for kernel functions, which are installed in man section 9. This is a good thing, as many programmers expect documentation to be available with man, and hunting through various PS or PDF documents to find the documentation for the function you want can be quite frustrating.

The man pages are just extracted from the various existing DocBook SGML documents, which are generated by kernel-doc. You also need to have docbook2man installed on your machine.

Please note the formatting is not perfect, but I will tweak other stuff later with further patches -- this is just an initial implementation.

Sample output (HTMLised) can be found at
http://www.stillhq.com/linux/mandocs/2.5.68/ and
http://www.stillhq.com/linux/mandocs/2.5.70/

 CREDITS                        |    8 ++
 Documentation/DocBook/Makefile |   30 +++++++++-
 Makefile                       |    4 -
 scripts/makeman                |   46 ++++++++++++++++
 scripts/split-man              |  112 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 193 insertions(+), 7 deletions(-)
CREDITS +8 -0
diff -Nru a/CREDITS b/CREDITS
@@ -2981,6 +2981,14 @@
 S: Sunyvale, CA 94086
 S: USA
 
+N: Michael Still
+E: [email protected]
+W: http://www.stillhq.com
+D: Various janitorial patches
+D: mandocs and mandocs_install build targets
+S: (Email me and ask)
+S: Australia
+
 N: Henrik Storner
 E: [email protected]
 W: http://www.image.dk/~storner/
Documentation/DocBook/Makefile +25 -5
diff -Nru a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
@@ -20,10 +20,11 @@
 # file.tmpl --> file.sgml +--> file.ps  (psdocs)
 #                         +--> file.pdf  (pdfdocs)
 #                         +--> DIR=file  (htmldocs)
+#                         +--> man/      (mandocs)
 
 ###
 # The targets that may be used.
-.PHONY:	sgmldocs psdocs pdfdocs htmldocs clean mrproper
+.PHONY:	sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs
 
 BOOKS := $(addprefix $(obj)/,$(DOCBOOKS))
 sgmldocs: $(BOOKS)
@@ -37,10 +38,18 @@
 HTML := $(patsubst %.sgml, %.html, $(BOOKS))
 htmldocs: $(HTML)
 
+MAN := $(patsubst %.sgml, %.9, $(BOOKS))
+mandocs: $(MAN)
+
+installmandocs: mandocs
+	$(MAKEMAN) install Documentation/DocBook/man
+
 ###
 #External programs used
 KERNELDOC = scripts/kernel-doc
 DOCPROC   = scripts/docproc
+SPLITMAN  = $(PERL) $(srctree)/scripts/split-man
+MAKEMAN   = $(PERL) $(srctree)/scripts/makeman
 
 ###
 # DOCPROC is used for two purposes:
@@ -128,6 +137,13 @@
             cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi
 
 ###
+# Rule to generate man files - output is placed in the man subdirectory
+
+%.9:	%.sgml
+	$(SPLITMAN) $< $(objtree)/Documentation/DocBook/man "$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)"
+	$(MAKEMAN) convert $(objtree)/Documentation/DocBook/man $<
+
+###
 # Rules to generate postscripts and PNG imgages from .fig format files
 quiet_cmd_fig2eps = FIG2EPS $@
       cmd_fig2eps = fig2dev -Leps $< $@
@@ -157,10 +173,10 @@
 # Help targets as used by the top-level makefile
 dochelp:
 	@echo  '  Linux kernel internal documentation in different formats:'
-	@echo  '  sgmldocs (SGML), psdocs (Postscript), pdfdocs (PDF), htmldocs (HTML)'
+	@echo  '  sgmldocs (SGML), psdocs (Postscript), pdfdocs (PDF)'
+	@echo  '  htmldocs (HTML), mandocs (man pages, use installmandocs to install)'
 
 ###
-# clean and mrproper as used by the top-level makefile 
 # Temporary files left by various tools
 clean-files := $(DOCBOOKS) \
 	$(patsubst %.sgml, %.dvi,  $(DOCBOOKS)) \
@@ -171,10 +187,14 @@
 	$(patsubst %.sgml, %.ps,   $(DOCBOOKS)) \
 	$(patsubst %.sgml, %.pdf,  $(DOCBOOKS)) \
 	$(patsubst %.sgml, %.html, $(DOCBOOKS)) \
-	$(patsubst %.fig,%.eps, $(IMG-parportbook)) \
-	$(patsubst %.fig,%.png, $(IMG-parportbook)) \
+	$(patsubst %.sgml, %.9,    $(DOCBOOKS)) \
+	$(patsubst %.fig,%.eps,    $(IMG-parportbook)) \
+	$(patsubst %.fig,%.png,    $(IMG-parportbook)) \
 	$(C-procfs-example)
 
 ifneq ($(wildcard $(patsubst %.html,%,$(HTML))),)
 clean-rule := rm -rf $(wildcard $(patsubst %.html,%,$(HTML)))
 endif
+
+#man put files in man subdir - traverse down
+subdir- := man/
Makefile +2 -2
diff -Nru a/Makefile b/Makefile
@@ -236,7 +236,7 @@
 noconfig_targets := xconfig gconfig menuconfig config oldconfig randconfig \
 		    defconfig allyesconfig allnoconfig allmodconfig \
 		    clean mrproper distclean rpm \
-		    help tags TAGS cscope sgmldocs psdocs pdfdocs htmldocs \
+		    help tags TAGS cscope %docs \
 		    checkconfig checkhelp checkincludes
 
 RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \) -prune -o
@@ -830,7 +830,7 @@
 
 # Documentation targets
 # ---------------------------------------------------------------------------
-sgmldocs psdocs pdfdocs htmldocs: scripts/docproc FORCE
+%docs: scripts/docproc FORCE
 	$(Q)$(MAKE) $(build)=Documentation/DocBook $@
 
 # Scripts to check various things for consistency
scripts/makeman new file +46 -0

46 lines not on this page · raw message

scripts/split-man new file +112 -0

112 lines not on this page · raw message

#2 lore raw
Quoted 5 lines · Sam Ravnborg

Hi Linus - please apply. Only docbook relevant changes [with patch this time].

Originally by Michael Still <[email protected]>

This patch adds two new targets to the docbook makefile -- mandocs, and

IS there any chance it could incorporate the GPL by a slightly smaller reference or even a link for the HTML one, it looks great except that 90% of the manual page is a GPL each time 8)

#3 lore raw

On 18 Jul 2003, Alan Cox wrote:

Hey,

thanks to Sam, Andries and yourself for showing an interest in the patch.

Quoted 10 lines · Sam Ravnborg
Quoted 5 lines

Hi Linus - please apply. Only docbook relevant changes [with patch this time].

Originally by Michael Still <[email protected]>

This patch adds two new targets to the docbook makefile -- mandocs, and

IS there any chance it could incorporate the GPL by a slightly smaller reference or even a link for the HTML one, it looks great except that 90% of the manual page is a GPL each time 8)

Well, the only part which comes from this patch is:

<para>
If you have comments on the formatting of this manpage, then please contact Michael Still (mikal\@stillhq.com).
</para>

<para>
This documentation was generated with kernel version $ARGV[2]. </para>

I can shorten this if people would like.

The GPL bit people have commented on is actually extracted from the front matter of the SGML file being converted inside <legalnotice></legalnotice>. Therefore, if the SGML kerneldoc output we already have includes the GPL, then so does the man page. I have not imposed new license conditions on the documentation.

If people are comfortable with dropping the legal notice, or perhaps inserting a line saying "refer to file X for the license on this documentation", then I'll do that and send a new patch.

Cheers,
Mikal

Signature · 3 lines
Michael Still ([email protected]) | Stage 1: Steal underpants
http://www.stillhq.com            | Stage 2: ????
UTC + 10                          | Stage 3: Profit
#4 lore raw
Quoted 8 lines · Michael Still
Quoted 3 lines

IS there any chance it could incorporate the GPL by a slightly smaller reference or even a link for the HTML one, it looks great except that 90% of the manual page is a GPL each time 8)

Well, the only part which comes from this patch is:
... Michael Still (mikal\@stillhq.com) ...
... This documentation was generated with kernel version $ARGV[2]. ... I can shorten this if people would like.

Commenting on the man page (nroff) version:

Please put the mikal\@stillhq.com in a comment.
Please leave the kernel version.

Quoted 9 lines

The GPL bit people have commented on is actually extracted from the front matter of the SGML file being converted inside <legalnotice></legalnotice>. Therefore, if the SGML kerneldoc output we already have includes the GPL, then so does the man page. I have not imposed new license conditions on the documentation.

If people are comfortable with dropping the legal notice, or perhaps inserting a line saying "refer to file X for the license on this documentation", then I'll do that and send a new patch.

Please put all legalities in comments - behind .\" we do not have to read them, but they are there if anyone cares.

Andries

#5 lore raw
Quoted 2 lines · Andries Brouwer

Please put all legalities in comments - behind .\" we do not have to read them, but they are there if anyone cares.

Ok. After having done some more poking, I can't see a way of doing this with docbook2man -- there doesn't appear to be any way of emitting comments. There strike me as two options here: write a script to convert SGML to man pages, or perhaps just insert a single sentence into the "About this Document" section which explains where to look for copyright information.

Any thoughts?

Cheers,
Mikal

Signature · 3 lines
Michael Still ([email protected]) | Stage 1: Steal underpants
http://www.stillhq.com            | Stage 2: ????
UTC + 10                          | Stage 3: Profit
#6 lore raw
Quoted 5 lines · Michael Still
Quoted 2 lines · Andries Brouwer

Please put all legalities in comments - behind .\" we do not have to read them, but they are there if anyone cares.

Quoted 8 lines

Ok. After having done some more poking, I can't see a way of doing this with docbook2man -- there doesn't appear to be any way of emitting comments. There strike me as two options here: write a script to convert SGML to man pages, or perhaps just insert a single sentence into the "About this Document" section which explains where to look for copyright information.

Any thoughts?

You do this in two steps: first construct an sgml document, then invoke docbook2man.

So, first you have to figure out what the proper docbook markup is for such material. According to me it is <docinfo>...</docinfo>, to be placed inside <refentry> before <refmeta>.
So you do that - example script fragments appended below.

Next, the docbook2man stage. My presently installed docbook2man says

# IGNORE.
sgml('<DOCINFO>', sub { push_output('nul'); });
sgml('</DOCINFO>', sub { pop_output(); });

That is, it does not produce any output for a docinfo section. I consider that a bug in docbook2man - it should output nroff comments. Probably this bug will be fixed sooner or later.
(I'll cc Steve Cheng who is listed as maintainer.)
In the meantime I do not worry too much about this missing copyright.

By the way, you start copying at <legalnotice>, but I consider that the least interesting part. The fact that these docs were written by Alan Cox is much more interesting. In other words, it might be a good idea to enlarge this <docinfo> section a bit.

Andries

In split-man:

  elsif($mode == 2){
    if(/<refmeta>/){
      $refdata = "$refdata\n<docinfo>\n$front\n$blurb\n</docinfo>\n"
    }
    $refdata = "$refdata$_";
  }

Here $front is the original one - do not delete <legalnotice>. And $blurb is your text:

<authorblurb><para>
If you have comments on the formatting of this manpage, then please contact Michael Still (mikal\@stillhq.com).
</para></authorblurb>

#7 lore raw
Quoted 4 lines · Andries Brouwer

On Sat, Jul 19, 2003 at 12:47:31PM +1000, Michael Still wrote:

You do this in two steps: first construct an sgml document, then invoke docbook2man.

Which is what I currently do.

Quoted 4 lines

So, first you have to figure out what the proper docbook markup is for such material. According to me it is <docinfo>...</docinfo>, to be placed inside <refentry> before <refmeta>.
So you do that - example script fragments appended below.

I tried this...

Quoted 7 lines

Next, the docbook2man stage. My presently installed docbook2man says

# IGNORE.
sgml('<DOCINFO>', sub { push_output('nul'); });
sgml('</DOCINFO>', sub { pop_output(); });

That is, it does not produce any output for a docinfo section.

...and hit this. Another option is that we could ship a tweaked version of docbook2man with the kernel sources, and call that copy. That could then turn docinfo's into comments -- this was what I was getting at with my previous message.

Quoted 1 line

In the meantime I do not worry too much about this missing copyright.

Okie, that's fair enough.

Quoted 4 lines

By the way, you start copying at <legalnotice>, but I consider that the least interesting part. The fact that these docs were written by Alan Cox is much more interesting. In other words, it might be a good idea to enlarge this <docinfo> section a bit.

Cool. I like your comments. I've got people coming over for dinner tonight, but I'll see what I can do about whipping up a new patch.

Cheers,
Mikal

Signature · 3 lines
Michael Still ([email protected]) | Stage 1: Steal underpants
http://www.stillhq.com            | Stage 2: ????
UTC + 10                          | Stage 3: Profit
#8 lore raw
Quoted 5 lines · Michael Still

...and hit this. Another option is that we could ship a tweaked version of docbook2man with the kernel sources, and call that copy. That could then turn docinfo's into comments -- this was what I was getting at with my previous message.

No, we do want to start adding tailored programs as part of the kernel source.

Sam