summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-12-12 23:19:34 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-12-12 23:20:36 -0800
commit3d0110a36054a9af1532d52f2671360fa1c802a3 (patch)
tree5cc5fbdff5f05dc11688716f4568f1e02aa32b04
parentb598b52a4acdc2332be3d34e30237d1b93b7dd03 (diff)
Rudimentary documentation for cmark_walk.
-rw-r--r--man/man3/cmark.39
-rw-r--r--src/cmark.h10
2 files changed, 18 insertions, 1 deletions
diff --git a/man/man3/cmark.3 b/man/man3/cmark.3
index 5d04380..30165a1 100644
--- a/man/man3/cmark.3
+++ b/man/man3/cmark.3
@@ -274,6 +274,15 @@ typedef enum {
\fIint\fR \fBcmark_walk\fR(\fIcmark_node *root\fR, \fIcmark_node_handler handler\fR, \fIvoid *state\fR)
.PP
+Walks the tree starting from root, applying handler to each node.
+Nodes that can have children are visited twice, once on the way in
+and once on the way out. handler is a function that takes a node
+pointer, an integer direction (1 for entering, 0 for leaving),
+and a pointer to a state structure that can be consulted and
+updated by the handler. The handler should return 1 on success,
+0 on failure. cmark_walk returns 1 if it traversed the entire
+tree, 0 if it quit early in response to a 0 status from the
+handler.
.SH AUTHORS
diff --git a/src/cmark.h b/src/cmark.h
index 12d0c01..224ef3a 100644
--- a/src/cmark.h
+++ b/src/cmark.h
@@ -308,7 +308,15 @@ char *cmark_render_ast(cmark_node *root);
CMARK_EXPORT
char *cmark_render_html(cmark_node *root);
-/**
+/** Walks the tree starting from root, applying handler to each node.
+ * Nodes that can have children are visited twice, once on the way in
+ * and once on the way out. handler is a function that takes a node
+ * pointer, an integer direction (1 for entering, 0 for leaving),
+ * and a pointer to a state structure that can be consulted and
+ * updated by the handler. The handler should return 1 on success,
+ * 0 on failure. cmark_walk returns 1 if it traversed the entire
+ * tree, 0 if it quit early in response to a 0 status from the
+ * handler.
*/
CMARK_EXPORT
int cmark_walk(cmark_node *root, cmark_node_handler handler, void *state);