summaryrefslogtreecommitdiff
path: root/man/make_man_page.py
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-12-13 20:46:16 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-12-13 20:56:30 -0800
commitcc2843b8cb769f0fa60c45a2e0f8f781dff9e845 (patch)
tree167224e0ed1508d24f01eaee3eed755665b67334 /man/make_man_page.py
parent59cc3c9323dc0b7aa1fd5817e12884ef925461d4 (diff)
Write API docs in cmark.h using markdown.
`man/make_man_page.py` now converts using cmark.
Diffstat (limited to 'man/make_man_page.py')
-rw-r--r--man/make_man_page.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/man/make_man_page.py b/man/make_man_page.py
index 01a1c6f..34383fb 100644
--- a/man/make_man_page.py
+++ b/man/make_man_page.py
@@ -12,8 +12,28 @@
# That's about it!
-import sys, re, os
+import sys, re, os, platform
from datetime import date
+from ctypes import CDLL, c_char_p, c_long, c_void_p
+
+sysname = platform.system()
+
+if sysname == 'Darwin':
+ cmark = CDLL("build/src/libcmark.dylib")
+else:
+ cmark = CDLL("build/src/libcmark.so")
+
+parse_document = cmark.cmark_parse_document
+parse_document.restype = c_void_p
+parse_document.argtypes = [c_char_p, c_long]
+
+render_man = cmark.cmark_render_man
+render_man.restype = c_char_p
+render_man.argtypes = [c_void_p]
+
+def md2man(text):
+ return render_man(parse_document(text, len(text)))
+
comment_start_re = re.compile('^\/\*\* ?')
comment_delim_re = re.compile('^[/ ]\** ?')
@@ -87,14 +107,14 @@ with open(sourcefile, 'r') as cmarkh:
mdlines.append('.RE\n\\f[]\n.fi\n')
if len(mdlines) > 0 and mdlines[-1] != '\n':
mdlines.append('\n')
- mdlines.append('.PP\n')
mdlines += chunk
+ mdlines.append('\n')
chunk = []
sig = []
elif oldstate == 'man' and state != 'signature':
if len(mdlines) > 0 and mdlines[-1] != '\n':
mdlines.append('\n')
- mdlines += chunk # add man chunk
+ mdlines += md2man(''.join(chunk)) # add man chunk
chunk = []
mdlines.append('\n')