summaryrefslogtreecommitdiff
path: root/man
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-11-30 10:19:24 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-11-30 10:19:24 -0800
commit7686b7dad5c80d494b993158def220aa8b61ac6e (patch)
tree09074d13fa0f8e76feb697a70657757481190f36 /man
parentec8683da993c3f73f6934769ea12911a293e15b0 (diff)
Updated make_man_page.py to use C89 comments.
See #224. TODO: change this to create the man page directly (not via markdown intermediary) and parse signatures into .Ft, .Fo, .Fa, .Fc, .Fd.
Diffstat (limited to 'man')
-rw-r--r--man/make_man_page.py22
-rw-r--r--man/man3/cmark.316
2 files changed, 19 insertions, 19 deletions
diff --git a/man/make_man_page.py b/man/make_man_page.py
index 19e1271..5ed5b0c 100644
--- a/man/make_man_page.py
+++ b/man/make_man_page.py
@@ -2,9 +2,9 @@
# Creates a man page from a C file.
-# Lines beginning with /// are treated as Markdown.
+# Comments beginning with `/**` are treated as Markdown.
-# Non-blank lines immediately following a /// line are treated
+# Non-blank lines immediately following a Markdown comment are treated
# as function signatures or examples and included verbatim. The
# immediately preceding markdown chunk is printed after the example
# as a comment on it.
@@ -20,7 +20,9 @@ else:
print("Usage: make_man_page.py sourcefile")
exit(1)
-special_comment_re = re.compile('^\/\/\/ ?')
+comment_start_re = re.compile('^\/\*\* ?')
+comment_delim_re = re.compile('^[/ ]\** ?')
+comment_end_re = re.compile('^ \**\/')
blank_re = re.compile('^\s*$')
macro_re = re.compile('CMARK_EXPORT *')
@@ -33,7 +35,11 @@ with open(sourcefile, 'r') as cmarkh:
for line in cmarkh:
# state transition
oldstate = state
- if special_comment_re.match(line):
+ if comment_start_re.match(line):
+ state = 'markdown'
+ elif comment_end_re.match(line) and state == 'markdown':
+ continue
+ elif comment_delim_re.match(line) and state == 'markdown':
state = 'markdown'
elif blank_re.match(line):
state = 'default'
@@ -41,12 +47,12 @@ with open(sourcefile, 'r') as cmarkh:
state = 'signature'
# handle line
- #if oldstate != state and len(mdlines) > 0 and mdlines[-1] != '\n':
- # mdlines.append('\n')
if state == 'markdown':
- chunk.append(re.sub(special_comment_re, '', line))
+ chunk.append(re.sub(comment_delim_re, '', line))
elif state == 'signature':
- sig.append(' ' + re.sub(macro_re, '', line))
+ ln = re.sub(macro_re, '', line)
+ if not re.match(blank_re, ln):
+ sig.append(' ' + ln)
elif oldstate == 'signature' and state != 'signature':
if len(mdlines) > 0 and mdlines[-1] != '\n':
mdlines.append('\n')
diff --git a/man/man3/cmark.3 b/man/man3/cmark.3
index 418d333..ded9860 100644
--- a/man/man3/cmark.3
+++ b/man/man3/cmark.3
@@ -26,7 +26,7 @@ null\-terminated, UTF\-8\-encoded string.
.nf
\f[C]
typedef\ enum\ {
-\ \ \ \ //\ Block
+\ \ \ \ /*\ Block\ */
\ \ \ \ CMARK_NODE_DOCUMENT,
\ \ \ \ CMARK_NODE_BLOCK_QUOTE,
\ \ \ \ CMARK_NODE_LIST,
@@ -62,6 +62,10 @@ cmark_node_new(cmark_node_type\ type);
void
cmark_node_free(cmark_node\ *node);
+
+
+cmark_node*
+cmark_node_next(cmark_node\ *node);
\f[]
.fi
.SH TREE TRAVERSAL
@@ -69,10 +73,6 @@ cmark_node_free(cmark_node\ *node);
.nf
\f[C]
cmark_node*
-cmark_node_next(cmark_node\ *node);
-
-
-cmark_node*
cmark_node_previous(cmark_node\ *node);
@@ -203,23 +203,18 @@ cmark_node_append_child(cmark_node\ *node,\ cmark_node\ *child);
cmark_parser\ *cmark_parser_new();
-
void\ cmark_parser_free(cmark_parser\ *parser);
-
cmark_node\ *cmark_parser_finish(cmark_parser\ *parser);
-
void\ cmark_parser_feed(cmark_parser\ *parser,\ const\ char\ *buffer,\ size_t\ len);
-
cmark_node\ *cmark_parse_document(const\ char\ *buffer,\ size_t\ len);
-
cmark_node\ *cmark_parse_file(FILE\ *f);
\f[]
.fi
@@ -230,7 +225,6 @@ cmark_node\ *cmark_parse_file(FILE\ *f);
char\ *cmark_render_ast(cmark_node\ *root);
-
char\ *cmark_render_html(cmark_node\ *root);
\f[]
.fi