~ashn/cdoc

04f2296df43d5abca65e12e78fa50792bee8d516 — ashn 7 months ago 389b94d
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.
2 files changed, 4 insertions(+), 3 deletions(-)

M cdoc.c
M example.c
M cdoc.c => cdoc.c +4 -2
@@ 538,8 538,10 @@ print_doc(struct doc const d)
    if (d.source != NULL) {
        puts("<pre><code>");
        char** ln = d.source;
        while (*ln != NULL) {
            puts(*ln++);
        for (; *ln != NULL; ++ln) {
            if (!is_doc_line(*ln)) {
                puts(*ln);
            }
        }
        puts("</code></pre>");
    }

M example.c => example.c +0 -1
@@ 29,7 29,6 @@ struct string
    //!     encoding of the buffer. Do <strong>NOT</strong> assume that data
    //!     points to an ASCII byte string.
    char* data;

    //! @member size
    //!     Length of data in bytes.
    size_t size;