[hawkmoth] [PATCH 2/2] hawkmoth: add support for variadic function documentation

  • From: Jani Nikula <jani@xxxxxxxxxx>
  • To: hawkmoth@xxxxxxxxxxxxx
  • Date: Sat, 26 Jan 2019 12:42:35 +0200

Much simpler than expected.
---
 hawkmoth/hawkmoth.py            | 4 +++-
 test/example-70-function.c      | 8 ++++++++
 test/example-70-function.stdout | 8 ++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/hawkmoth/hawkmoth.py b/hawkmoth/hawkmoth.py
index f6d3867d289b..5f2509b8b1c9 100644
--- a/hawkmoth/hawkmoth.py
+++ b/hawkmoth/hawkmoth.py
@@ -204,13 +204,15 @@ def _recursive_parse(comments, cursor, nest, compat):
         # FIXME: check args against comment
         # FIXME: children may contain extra stuff if the return type is a
         # typedef, for example
-        # FIXME: handle ... params
         args = []
         for c in cursor.get_children():
             if c.kind == CursorKind.PARM_DECL:
                 args.append('{ttype} {arg}'.format(ttype=c.type.spelling,
                                                    arg=c.spelling))
 
+        if cursor.type.is_function_variadic():
+            args.append('...')
+
         fmt = docstr.Type.FUNC
         ttype = cursor.result_type.spelling
 
diff --git a/test/example-70-function.c b/test/example-70-function.c
index 24f1d20abccc..5042b0795b99 100644
--- a/test/example-70-function.c
+++ b/test/example-70-function.c
@@ -7,3 +7,11 @@
  * :since: v0.1
  */
 int frob(struct list *list, enum mode mode);
+
+/**
+ * variadic frobnicator
+ *
+ * :param fmt: the format
+ * :param ...: variadic
+ */
+int frobo(const char *fmt, ...);
diff --git a/test/example-70-function.stdout b/test/example-70-function.stdout
index 0bdcdb009ba8..acdfe9864108 100644
--- a/test/example-70-function.stdout
+++ b/test/example-70-function.stdout
@@ -8,3 +8,11 @@
    :return: 0 on success, non-zero error code on error.
    :since: v0.1
 
+
+.. c:function:: int frobo(const char * fmt, ...)
+
+   variadic frobnicator
+
+   :param fmt: the format
+   :param ...: variadic
+
-- 
2.20.1


Other related posts: