summaryrefslogtreecommitdiff
path: root/man/make_man_page.py
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-11-29 19:24:46 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-11-29 19:25:58 -0800
commitd76f07909ff44a36b0ea6e993484ad9e9fd6ff11 (patch)
tree88e2b3973452a5c02c3e70f0dce54d310a06a750 /man/make_man_page.py
parentc1d5685baa7d53d8a41160b487681498c3c79993 (diff)
Use make_man_page.py + pandoc to create cmark.3 man page from cmark.h.
See #224.
Diffstat (limited to 'man/make_man_page.py')
-rw-r--r--man/make_man_page.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/man/make_man_page.py b/man/make_man_page.py
index ed52381..19e1271 100644
--- a/man/make_man_page.py
+++ b/man/make_man_page.py
@@ -14,14 +14,21 @@
import sys
import re
-special_comment_re = re.compile('^\/\/\/ ?');
-blank_re = re.compile('^\s*$');
+if len(sys.argv) > 1:
+ sourcefile = sys.argv[1]
+else:
+ print("Usage: make_man_page.py sourcefile")
+ exit(1)
+
+special_comment_re = re.compile('^\/\/\/ ?')
+blank_re = re.compile('^\s*$')
+macro_re = re.compile('CMARK_EXPORT *')
mdlines = []
chunk = []
sig = []
-with open('../src/cmark.h', 'r') as cmarkh:
+with open(sourcefile, 'r') as cmarkh:
state = 'default'
for line in cmarkh:
# state transition
@@ -39,7 +46,7 @@ with open('../src/cmark.h', 'r') as cmarkh:
if state == 'markdown':
chunk.append(re.sub(special_comment_re, '', line))
elif state == 'signature':
- sig.append(' ' + line)
+ sig.append(' ' + re.sub(macro_re, '', line))
elif oldstate == 'signature' and state != 'signature':
if len(mdlines) > 0 and mdlines[-1] != '\n':
mdlines.append('\n')