2 from datetime import date
3 from os.path import dirname, isdir
4 from os import makedirs, system
11 makedirs(outdir, 0755)
13 execfile(sourcedir + "/conf.py")
16 def header(file, startdocname, command, description, authors, section):
24 :Manual section: {5:d}
28 '-' * len(description),
30 '-' * len(description),
31 date.today().isoformat(), release, section, project))
33 blankre = re.compile("^\s*$")
34 for page in man_pages:
35 outdirname = outdir + '/' + dirname(page[0])
36 if not isdir(outdirname):
37 makedirs(outdirname, 0755)
38 filename = outdir + '/' + page[0] + '.rst'
39 outfile = open(filename, 'w')
40 infile = open(sourcedir + '/' + page[0] + '.rst', 'r')
42 # this is a crude hack. We look for the first blank line, and
43 # insert the rst2man header there.
45 # XXX consider really parsing input
48 lines = infile.readlines()
51 if (blankre.match(line)):
55 del lines[0:count + 1]
57 header(outfile, *page)
59 outfile.write("".join(lines))
62 os.system('set -x; rst2man {0} {1}/{2}.{3}'
63 .format(filename, outdir, page[0],page[4]))