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 13A7B429E45 for ; Tue, 25 Feb 2014 12:24:28 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 kSy1RAh28Geg for ; Tue, 25 Feb 2014 12:24:19 -0800 (PST) Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com [74.125.83.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D7BB2429E43 for ; Tue, 25 Feb 2014 12:24:18 -0800 (PST) Received: by mail-ee0-f53.google.com with SMTP id c13so1330404eek.12 for ; Tue, 25 Feb 2014 12:24:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type; bh=l1UErZuhfXOfXJowoTTkJyebNxQrP0K3+DOC9KLzSpM=; b=JvfPyMPheBshav2VRuVl8OzS89HvI/FPLbYEZA5Gp44IOTpvxpp/07jKZTWg9TwpuC 1dXwQCQjdYaq4K/WP15mC8gkcVazmqANY+/DDHhbKFR0eN+TO7KkZIpyIhfVwpjlMaLu tTkd3z2xDDBUTxh1uhuaqaoJzi1MNrq9/rk+p74t27Um7fl7QBP/avsW5Lygx9lfB4+K HEu1W+1vt8uZIx+deHEYUNc+pKP9u96XX/Q+kc5bO2o3sYiYMmbWTMBoruqbyI1taaL5 etmy0FnwuvEFWzd7hhbGfkUIO9mR6MTEP0NqxLWkpww42CbD/K7zm+k74114uHxpZ2CJ dNNg== X-Gm-Message-State: ALoCoQnWsSLGbFtWdGJyra3yqXwY0QmYhGyBMuLIjMONqaWtLIiSG9Xzg7j2BVhYO08USsSRHxeV X-Received: by 10.14.175.129 with SMTP id z1mr1834188eel.97.1393359856075; Tue, 25 Feb 2014 12:24:16 -0800 (PST) Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. [88.195.111.91]) by mx.google.com with ESMTPSA id k41sm80332527een.19.2014.02.25.12.24.14 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 25 Feb 2014 12:24:15 -0800 (PST) From: Jani Nikula To: David Bremner , notmuch@notmuchmail.org Subject: Re: [RFC PATCH v4 2/3] doc: add target rst2man to build man pages using rst2man In-Reply-To: <1393329181-17404-3-git-send-email-david@tethera.net> References: <1393329181-17404-1-git-send-email-david@tethera.net> <1393329181-17404-3-git-send-email-david@tethera.net> User-Agent: Notmuch/0.17+100~g8bf655b52f07 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Tue, 25 Feb 2014 22:24:13 +0200 Message-ID: <871tyr0wlu.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain 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 20:24:28 -0000 On Tue, 25 Feb 2014, David Bremner wrote: > Many people have docutils installed, but not sphinx. Allow these > people to build the man pages. Some bikeshedding... :) I think I'd prefer sphinx and docutils to be checked in the configure script (preferring sphinx over rst2man if available, obviously) and combining the doc build process so that a simple 'make doc' or similar does the right thing. With that, it would be nice if the rst2man stuff didn't have to be in another subdirectory. That said, I believe all of this can be a follow-up patch. BR, Jani. > --- > 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 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch