summaryrefslogtreecommitdiff
path: root/macro2m4.py
diff options
context:
space:
mode:
authorPeter Simons <simons@cryp.to>2009-12-23 20:26:41 +0100
committerPeter Simons <simons@cryp.to>2009-12-23 20:26:41 +0100
commitdb3d86cee936204ba5d5fd87cbef8280e283eb5a (patch)
tree2bbb30ee79fe9d0cdbbbfcf169cae97ef6197dd9 /macro2m4.py
parent841960f7b0263114fb5daca65b4574e6de24c3c9 (diff)
downloadautoconf-archive-db3d86cee936204ba5d5fd87cbef8280e283eb5a.tar.gz
macro2m4.py: normalize indention of quoted sections
Macro documentation may contain "quoted" paragraphs that will be typeset in verbatim. Such quoted paragraphs ought to be indented by (at least) one blank. The number of blanks that macro authors used in their submissions varies, though. This patch normalizes all indented sections to 2 blanks.
Diffstat (limited to 'macro2m4.py')
-rwxr-xr-xmacro2m4.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/macro2m4.py b/macro2m4.py
index 30a8659..cfbd40b 100755
--- a/macro2m4.py
+++ b/macro2m4.py
@@ -40,11 +40,23 @@ def formatAuthor(a):
else:
return "# Copyright (c) %(year)s %(name)s" % a
+def countSpaces(line):
+ for i in range(len(line)):
+ if not line[i].isspace():
+ break
+ return i
+
if len(sys.argv) != 3:
raise Exception("invalid command line syntax: %s" % ' '.join(map(repr, sys.argv)))
(m4File,outFile) = sys.argv[1:]
assert outFile != m4File
m = Macro(m4File)
+for i in range(len(m.description)):
+ para = m.description[i]
+ if para[0][0].isspace():
+ spaces = min(map(countSpaces, para))
+ if spaces > 1:
+ m.description[i] = map(lambda l: ' ' + l[spaces:], para)
url = "http://www.nongnu.org/autoconf-archive/%s.html" % m.name
lineLen = max(len(url) + 2, 75)
m.url = "# %s\n# %s\n# %s" % ('=' * lineLen, (' ' * ((lineLen - len(url)) / 2)) + url, '=' * lineLen)
@@ -57,4 +69,5 @@ m.description = '\n#\n'.join(map(formatParagraph, m.description))
m.authors = "\n".join(map(formatAuthor, m.authors))
m.license = '\n#\n'.join(map(formatParagraph, m.license))
m.body = '\n'.join(m.body)
+
writeFile(outFile, tmpl % m.__dict__)