From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [RFC Patch v3 2/3] doc: add target rst2man to build man pages using rst2man
Date: Sat, 22 Feb 2014 20:16:14 -0400 [thread overview]
Message-ID: <1393114575-8756-3-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1393114575-8756-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/conf.py | 2 +-
doc/rst2man/Makefile | 5 +++++
doc/rst2man/Makefile.local | 37 ++++++++++++++++++++++++++++++++
doc/rst2man/prerst2man.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 97 insertions(+), 2 deletions(-)
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/conf.py b/doc/conf.py
index d80b2af..9180d86 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -21,7 +21,7 @@ release = '0.17'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
-exclude_patterns = ['_build']
+exclude_patterns = ['_build','rst2man']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
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..bc821fe
--- /dev/null
+++ b/doc/rst2man/Makefile.local
@@ -0,0 +1,37 @@
+# -*- Makefile -*-
+dir := doc/rst2man
+
+prerst2man := python $(dir)/prerst2man.py $(dir)/.. $(dir)
+
+%.1 :%.rst
+ rst2man $< > $@
+
+%.5 :%.rst
+ rst2man $< > $@
+
+%.7: %.rst
+ rst2man $< > $@
+
+# actual source files
+RST1SRC := $(wildcard doc/man1/*.rst)
+RST5SRC := $(wildcard doc/man5/*.rst)
+RST7SRC := $(wildcard doc/man7/*.rst)
+
+RST2MAN1SRC := $(patsubst doc/man1/%,doc/rst2man/man1/%,$(RST1SRC))
+RST2MAN5SRC := $(patsubst doc/man5/%,doc/rst2man/man5/%,$(RST5SRC))
+RST2MAN7SRC := $(patsubst doc/man7/%,doc/rst2man/man7/%,$(RST7SRC))
+
+RST2MANSRC := ${RST2MAN1SRC} ${RST2MAN5SRC} ${RST2MAN7SRC}
+
+MAN1SRC := $(patsubst $(dir)/man1/%.rst,$(dir)/man1/%.1,${RST2MAN1SRC})
+MAN5SRC := $(patsubst $(dir)/man5/%.rst,$(dir)/man5/%.5,${RST2MAN5SRC})
+MAN7SRC := $(patsubst $(dir)/man7/%.rst,$(dir)/man7/%.7,${RST2MAN7SRC})
+MANSRC := ${MAN1SRC} ${MAN5SRC} ${MAN7SRC}
+
+rst2man: ${MANSRC}
+
+${RST2MANSRC}: ${RSTSRC}
+ mkdir -p doc/rst2man/man1 doc/rst2man/man5 doc/rst2man/man7
+ $(prerst2man)
+
+CLEAN := ${CLEAN} ${RST2MANSRC} ${MANSRC}
diff --git a/doc/rst2man/prerst2man.py b/doc/rst2man/prerst2man.py
new file mode 100644
index 0000000..797dd20
--- /dev/null
+++ b/doc/rst2man/prerst2man.py
@@ -0,0 +1,53 @@
+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}
+{:s}
+{:s}
+
+:Date: {:s}
+:Version: {:s}
+:Manual section: {:d}
+:Manual group: {:s}
+
+""".format(
+'-' * len(description),
+description,
+'-' * len(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.3
next prev parent reply other threads:[~2014-02-23 0:16 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 ` [RFC Patch v2 2/2] doc: add target rst2man to build man pages using rst2man David Bremner
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 ` David Bremner [this message]
2014-02-23 17:42 ` [RFC Patch v3 2/3] doc: add target rst2man to build man pages using rst2man 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=1393114575-8756-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).