Many people have docutils installed, but not sphinx. Allow these people to build the man pages. --- Makefile | 2 +- doc/rst2man/Makefile | 5 +++++ doc/rst2man/Makefile.local | 28 ++++++++++++++++++++++++++++ doc/rst2man/prerst2man.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 doc/rst2man/Makefile create mode 100644 doc/rst2man/Makefile.local create mode 100644 doc/rst2man/prerst2man.py diff --git a/Makefile b/Makefile index 39f0e62..3c7f0be 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ all: # List all subdirectories here. Each contains its own Makefile.local. # Use of '=', without '+=', seems to be required for out-of-tree # builds to work. -subdirs = compat completion doc emacs lib man parse-time-string performance-test util test +subdirs = compat completion doc doc/rst2man emacs lib man parse-time-string performance-test util test # We make all targets depend on the Makefiles themselves. global_deps = Makefile Makefile.config Makefile.local \ diff --git a/doc/rst2man/Makefile b/doc/rst2man/Makefile new file mode 100644 index 0000000..0a0815d --- /dev/null +++ b/doc/rst2man/Makefile @@ -0,0 +1,5 @@ +all: + $(MAKE) -C ../.. all + +.DEFAULT: + $(MAKE) -C ../.. $@ diff --git a/doc/rst2man/Makefile.local b/doc/rst2man/Makefile.local new file mode 100644 index 0000000..5bb3e43 --- /dev/null +++ b/doc/rst2man/Makefile.local @@ -0,0 +1,28 @@ +# -*- Makefile -*- +dir := doc/rst2man + +prerst2man := python $(dir)/prerst2man.py $(dir)/.. $(dir) + +MANSRC := $(dir)/notmuch.1 $(dir)/notmuch-search.1 $(dir)/notmuch-search-terms.7 + +%.1 : %.rst + rst2man $< > $@ + +%.7: %.rst + rst2man $< > $@ + +# preprocessed source files suitable for rst2man +RST2MANSRC := $(dir)/notmuch.rst $(dir)/notmuch-search.rst $(dir)/notmuch-search-terms.rst + +# actual source files + +RSTSRC := $(patsubst ${dir}/%,$(dir)/../%,${RST2MANSRC}) + +RSTMANSRC := $(patsubst %.rst,%.1,${RST2MANSRC}) + +rst2man: ${MANSRC} + +${RST2MANSRC}: ${RSTSRC} + $(prerst2man) + +CLEAN := ${CLEAN} ${RST2MANSRC} ${MANSRC} diff --git a/doc/rst2man/prerst2man.py b/doc/rst2man/prerst2man.py new file mode 100644 index 0000000..4222f11 --- /dev/null +++ b/doc/rst2man/prerst2man.py @@ -0,0 +1,46 @@ +from sys import argv +from datetime import date +import re + +sourcedir=argv[1] +outdir=argv[2] + +execfile(sourcedir+"/conf.py"); + +def header(file,startdocname, command, description, authors, section): + file.write(""" +--------------------------------------------- +{:s} +--------------------------------------------- + +:Date: {:s} +:Version: {:s} +:Manual section: {:d} +:Manual group: {:s} + +""".format(description,date.today().isoformat(),release,section,project)) + +blankre = re.compile("^\s*$") +for page in man_pages: + outfile = open(outdir+"/"+page[0]+'.rst','w') + infile = open(sourcedir+"/"+page[0]+".rst",'r') + + + # this is a crude hack. We look for the first blank line, and + # insert the rst2man header there. + # + # XXX consider really parsing input + + count=0 + lines = infile.readlines() + for line in lines: + outfile.write(line); + if (blankre.match(line)): + break + count = count + 1 + + del lines[0:count+1] + + header(outfile,*page) + + outfile.write("".join(lines)) -- 1.8.5.2