unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 81ce817603ddac7943cdbd89040f216cc53aad6c 1434 bytes (raw)
name: doc/prerst2man.py 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 
from sys import argv
from datetime import date
from os.path import dirname, isdir
from os import makedirs, system
import re

rst2man = argv[1]
sourcedir = argv[2]
outdir = argv[3]

if not isdir(outdir):
    makedirs(outdir, 0o755)

execfile(sourcedir + "/conf.py")


def header(file, startdocname, command, description, authors, section):
    file.write("""
{0:s}
{1:s}
{2:s}

:Date:   {3:s}
:Version: {4:s}
:Manual section: {5:d}
:Manual group: {6:s}

""".format(
'-' * len(description),
description,
'-' * len(description),
date.today().isoformat(), release, section, project))

blankre = re.compile("^\s*$")
for page in man_pages:
    outdirname = outdir + '/' + dirname(page[0])
    if not isdir(outdirname):
        makedirs(outdirname, 0o755)
    filename = outdir + '/' + page[0] + '.rst'
    outfile = open(filename, '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))
    outfile.close()

    system('set -x; {0} {1} {2}/{3}.{4}'
           .format(rst2man, filename, outdir, page[0], page[4]))

debug log:

solving 81ce817 ...
found 81ce817 in https://yhetil.org/notmuch/2621721db05068dffb65b88cd50d2a5b49e967f5.1405220724.git.wking@tremily.us/ ||
	https://yhetil.org/notmuch/c8b019cf95243e4b47780a19d0bfca5b65c79ecb.1399740604.git.wking@tremily.us/ ||
	https://yhetil.org/notmuch/adce76bb9a0ca728d856da4ecaf6b282e22e7440.1396718720.git.wking@tremily.us/
found 437dea9 in https://yhetil.org/notmuch.git/
preparing index
index prepared:
100644 437dea99b6e520697daff811009b890edd7abb2d	doc/prerst2man.py

applying [1/1] https://yhetil.org/notmuch/2621721db05068dffb65b88cd50d2a5b49e967f5.1405220724.git.wking@tremily.us/
diff --git a/doc/prerst2man.py b/doc/prerst2man.py
index 437dea9..81ce817 100644

Checking patch doc/prerst2man.py...
Applied patch doc/prerst2man.py cleanly.

skipping https://yhetil.org/notmuch/c8b019cf95243e4b47780a19d0bfca5b65c79ecb.1399740604.git.wking@tremily.us/ for 81ce817
skipping https://yhetil.org/notmuch/adce76bb9a0ca728d856da4ecaf6b282e22e7440.1396718720.git.wking@tremily.us/ for 81ce817
index at:
100644 81ce817603ddac7943cdbd89040f216cc53aad6c	doc/prerst2man.py

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

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).