From 04f2296df43d5abca65e12e78fa50792bee8d516 Mon Sep 17 00:00:00 2001 From: ashn Date: Mon, 13 Jul 2020 18:17:17 -0400 Subject: [PATCH] Filter out doc comments in source sections In a piece of documented code such as: ``` //! @struct buffer //! A buffer for holding some data. //! This is just an example so don't read into it too much. struct buffer { //! @member data //! Contents of this buffer. char data[BUFFER_MAX_LENGTH]; //! @member length //! Length of the buffer in bytes. uint8_t length; }; ``` the information for members `data` and `length` are documented by their @member tags. Prior to this commit, these sections would "appear twice" in generated documentation, once in plain HTML generated form the @member tags and once again as raw source code when the struct body was printed. This commit changes print_section to filter out doc lines as a means to prevent this issue. --- cdoc.c | 6 ++++-- example.c | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cdoc.c b/cdoc.c index 5eb8c42..423e349 100644 --- a/cdoc.c +++ b/cdoc.c @@ -538,8 +538,10 @@ print_doc(struct doc const d) if (d.source != NULL) { puts("
");
         char** ln = d.source;
-        while (*ln != NULL) {
-            puts(*ln++);
+        for (; *ln != NULL; ++ln) {
+            if (!is_doc_line(*ln)) {
+                puts(*ln);
+            }
         }
         puts("
"); } diff --git a/example.c b/example.c index 6420bfa..645dfdb 100644 --- a/example.c +++ b/example.c @@ -29,7 +29,6 @@ struct string //! encoding of the buffer. Do NOT assume that data //! points to an ASCII byte string. char* data; - //! @member size //! Length of data in bytes. size_t size; -- 2.30.2