[hawkmoth] Re: [PATCH 12/13] test: expand tests to cover nested elements

  • From: Jani Nikula <jani@xxxxxxxxxx>
  • To: Bruno Santos <brunomanuelsantos@xxxxxxxxxxxxxxxxxx>, hawkmoth@xxxxxxxxxxxxx
  • Date: Sat, 12 Jan 2019 11:33:01 +0200

On Tue, 08 Jan 2019, Bruno Santos <brunomanuelsantos@xxxxxxxxxxxxxxxxxx> wrote:

---
 test/struct.c      | 24 ++++++++++++++++++++++--
 test/struct.stdout | 23 ++++++++++++++++++++++-
 test/union.c       | 21 ++++++++++++++++++++-
 test/union.stdout  | 32 +++++++++++++++++++++++++++++++-

I think I'd like to add separate test files for the more complicated
cases. struct-nested.c etc.

 4 files changed, 95 insertions(+), 5 deletions(-)

diff --git a/test/struct.c b/test/struct.c
index 0b0640d..159d7c9 100644
--- a/test/struct.c
+++ b/test/struct.c
@@ -8,8 +8,28 @@ struct sample_struct {
       * member
       */
      int jesh;
+
      /**
-      * foo next
+      * Document the 1st instance only. If you want to document prev as well,
+      * make everyone's life easier and split it in multiple lines.

Agreed. This is the kind of design tradeoffs I like to make in favor of
simplicity. You want to document it, split it.

       */
-     struct sample_struct *next;
+     struct sample_struct *next, *prev;
+
+     /** This documents the first instance of the structure. */
+     struct {
+             /** Member. */
+             int josh;
+
+             /** One more level. */
+             struct {
+                     /** You get the idea. */
+                     int awheeee;
+             } deep_struct;
+
+             /* Recursion will stop here. */

So this will stop recursion because this particular comment is not a
documentation comment? Agreed on the approach, just want to double
check.

BR,
Jani.

+             struct {
+                     /** Not documented. */
+                     int nope;
+             } undocumented_struct;
+     } structception;
 };
diff --git a/test/struct.stdout b/test/struct.stdout
index 1a0fa60..d465223 100644
--- a/test/struct.stdout
+++ b/test/struct.stdout
@@ -13,5 +13,26 @@

    .. c:member:: struct sample_struct * next

-      foo next
+      Document the 1st instance only. If you want to document prev as well,
+      make everyone's life easier and split it in multiple lines.
+
+
+   .. c:member:: struct <anonymous> structception
+
+      This documents the first instance of the structure.
+
+
+      .. c:member:: int josh
+
+         Member.
+
+
+      .. c:member:: struct <anonymous> deep_struct
+
+         One more level.
+
+
+         .. c:member:: int awheeee
+
+            You get the idea.

diff --git a/test/union.c b/test/union.c
index 13a4208..393fe49 100644
--- a/test/union.c
+++ b/test/union.c
@@ -7,14 +7,33 @@ union foo {
       * int member 1.
       */
      int foo;
+
      /**
       * int member 2.
       */
      int bar;
+
      /**
       * struct member.
       */
-     struct _baz {
+     struct {
+             /** Another member. */
              int bax;
      } baz;
+
+     /** Puke. */
+     enum {
+             /** Yellow. */
+             YELLOW,
+             AND_SO_ON
+     } rainbow;
+
+     /** Nested union. */
+     union {
+             /** Spam, spam, spam & spam. */
+             int spam;
+
+             /** Spam, spam, spam, eggs & spam. */
+             int eggs;
+     } unionception.
 };
diff --git a/test/union.stdout b/test/union.stdout
index a6cc7b5..1112709 100644
--- a/test/union.stdout
+++ b/test/union.stdout
@@ -14,7 +14,37 @@
       int member 2.


-   .. c:type:: struct _baz
+   .. c:member:: struct <anonymous> baz

       struct member.

+
+      .. c:member:: int bax
+
+         Another member.
+
+
+   .. c:member:: enum <anonymous> rainbow
+
+      Puke.
+
+
+      .. c:macro:: YELLOW
+
+         Yellow.
+
+
+   .. c:member:: union <anonymous> unionception
+
+      Nested union.
+
+
+      .. c:member:: int spam
+
+         Spam, spam, spam & spam.
+
+
+      .. c:member:: int eggs
+
+         Spam, spam, spam, eggs & spam.
+
--
2.20.1

Other related posts: