From 725a79c1e0beb71d7af6826e83135ae93eb577c6 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Wed, 26 Feb 2014 07:53:00 +2000 Subject: [PATCH] [RFC PATCH v4 2/3] doc: add target rst2man to build man pages using rst2man --- f8/503b7ecb33f0c5cca5c54d6e956a54f4f2ad8d | 204 ++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 f8/503b7ecb33f0c5cca5c54d6e956a54f4f2ad8d diff --git a/f8/503b7ecb33f0c5cca5c54d6e956a54f4f2ad8d b/f8/503b7ecb33f0c5cca5c54d6e956a54f4f2ad8d new file mode 100644 index 000000000..d5d9835ab --- /dev/null +++ b/f8/503b7ecb33f0c5cca5c54d6e956a54f4f2ad8d @@ -0,0 +1,204 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 75757429E4F + for ; Tue, 25 Feb 2014 03:53:36 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id dYtCeUw7yyYc for ; + Tue, 25 Feb 2014 03:53:32 -0800 (PST) +Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155]) + (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 33F0B429E45 + for ; Tue, 25 Feb 2014 03:53:32 -0800 (PST) +Received: from remotemail by yantan.tethera.net with local (Exim 4.80) + (envelope-from ) + id 1WIGZm-0007xV-Cx; Tue, 25 Feb 2014 07:53:30 -0400 +Received: (nullmailer pid 17602 invoked by uid 1000); Tue, 25 Feb 2014 + 11:53:23 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [RFC PATCH v4 2/3] doc: add target rst2man to build man pages using + rst2man +Date: Tue, 25 Feb 2014 07:53:00 -0400 +Message-Id: <1393329181-17404-3-git-send-email-david@tethera.net> +X-Mailer: git-send-email 1.8.5.3 +In-Reply-To: <1393329181-17404-1-git-send-email-david@tethera.net> +References: <1393329181-17404-1-git-send-email-david@tethera.net> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 25 Feb 2014 11:53:36 -0000 + +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 + -- 2.26.2