From d76f07909ff44a36b0ea6e993484ad9e9fd6ff11 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 29 Nov 2014 19:24:46 -0800 Subject: Use make_man_page.py + pandoc to create cmark.3 man page from cmark.h. See #224. --- man/make_man_page.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'man/make_man_page.py') 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') -- cgit v1.2.3