From: W. Trevor King Date: Sat, 10 May 2014 04:51:42 +0000 (-0700) Subject: doc/prerst2x.py: Adjust to handle any output format, not just man pages X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=acb1c6dc1128eaefe0a8def82da7800727716139;p=notmuch.git doc/prerst2x.py: Adjust to handle any output format, not just man pages For example, with these changes we can build HTML output using: $ prerst2x.py rst2html ${SRCDIR} ${OUTDIR} html The extension adjustment ensures that the output filenames from the above command match what we currently generate with sphinx-html. --- diff --git a/doc/Makefile.local b/doc/Makefile.local index d96cdd55..5fb526b9 100644 --- a/doc/Makefile.local +++ b/doc/Makefile.local @@ -7,7 +7,7 @@ SPHINXOPTS := -q SPHINXBUILD = sphinx-build DOCBUILDDIR := $(dir)/_build -prerst2man := python $(srcdir)/$(dir)/prerst2man.py +prerst2x := python $(srcdir)/$(dir)/prerst2x.py mkdocdeps := python $(srcdir)/$(dir)/mkdocdeps.py # Internal variables. @@ -49,7 +49,7 @@ ifeq ($(HAVE_SPHINX),1) mv $(DOCBUILDDIR)/man/*.$${section} $(DOCBUILDDIR)/man/man$${section}; \ done else ifeq ($(HAVE_RST2MAN),1) - $(prerst2man) "$(RST2MAN)" $(srcdir)/doc $(DOCBUILDDIR)/man + $(prerst2x) "$(RST2MAN)" $(srcdir)/doc $(DOCBUILDDIR)/man else @echo "Fatal: build dependency fail." @false diff --git a/doc/prerst2man.py b/doc/prerst2x.py similarity index 82% rename from doc/prerst2man.py rename to doc/prerst2x.py index 7d78e9b0..4f9213f0 100644 --- a/doc/prerst2man.py +++ b/doc/prerst2x.py @@ -4,9 +4,13 @@ from os.path import dirname, isdir from os import makedirs, system import re -rst2man = sys.argv[1] +rst2x = sys.argv[1] sourcedir = sys.argv[2] outdir = sys.argv[3] +try: + extension = sys.argv[4] +except IndexError: + extension = '' sys.path.insert(0, sourcedir) import conf @@ -43,7 +47,7 @@ for page in conf.man_pages: 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. + # insert the rst2x header there. # # XXX consider really parsing input @@ -62,5 +66,10 @@ for page in conf.man_pages: outfile.write("".join(lines)) outfile.close() + if extension: + ext = extension + else: + ext = page[4] # man page section + system('set -x; {0} {1} {2}/{3}.{4}' - .format(rst2man, filename, outdir, page[0], page[4])) + .format(rst2x, filename, outdir, page[0], ext))