From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [RFC Patch v2 2/2] doc: add target rst2man to build man pages using rst2man
Date: Tue, 28 Jan 2014 12:12:38 -0400 [thread overview]
Message-ID: <1390925558-15873-3-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1390925558-15873-1-git-send-email-david@tethera.net>
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
next prev parent reply other threads:[~2014-01-28 16:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-18 16:00 [RFC Patch] start of sphinx based docs David Bremner
2014-01-19 13:48 ` Tomi Ollila
2014-01-19 18:57 ` David Bremner
2014-01-28 16:12 ` David Bremner
2014-01-28 16:12 ` [RFC Patch v2 1/2] doc: start of sphinx based docs David Bremner
2014-01-28 16:12 ` David Bremner [this message]
2014-01-28 22:54 ` Mark Walters
2014-01-29 2:26 ` Re: David Bremner
2014-02-23 0:16 ` v3 of sphinx docs David Bremner
2014-02-23 0:16 ` [RFC Patch v3 1/3] doc: start of sphinx based docs David Bremner
2014-02-23 0:16 ` [RFC Patch v3 2/3] doc: add target rst2man to build man pages using rst2man David Bremner
2014-02-23 17:42 ` Tomi Ollila
2014-02-23 23:57 ` David Bremner
2014-02-23 0:16 ` [RFC Patch v3 3/3] doc: fix for conversion errors David Bremner
2014-02-24 0:54 ` v3 of sphinx docs Mark Walters
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1390925558-15873-3-git-send-email-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).