Uploaded image for project: 'Request For Comments'
  1. Request For Comments
  2. RFC-225

Bring C++ doc standards in line with Python docs

    XMLWordPrintable

    Details

    • Type: RFC
    • Status: Implemented
    • Resolution: Done
    • Component/s: DM
    • Labels:
      None

      Description

      Jonathan Sick has written detailed guidelines that standardize Python docstrings and require that developers give a reasonably complete specification of each class, method, or function. The corresponding C++ guidelines are much looser, requiring little more than a descriptive paragraph with few content requirements.

      I propose that the C++ documentation guidelines be revised to be more analogous to the current Python guidelines. In particular, I propose:

      • that the C++ docs include some comment formatting guidelines, analogous to https://developer.lsst.io/docs/py_docs.html#basic-format-of-docstrings. These can be taken from the rules at https://confluence.lsstcorp.org/display/LDMDG/Documentation+Standards
      • that class documentation include the following content, in the following order:
        • a one-line description of the class
        • @deprecated tag (if applicable)
        • one or more summary paragraphs (recommended)
        • @tparam tags (if applicable)
        • @see tags (optional; we should standardize on one of @see and @sa)
        • @note tags (optional; we should standardize on one of @note, @remark, and @remarks)
        • @cite tags (optional)
        • @example tags (optional)
      • that public or protected method or function documentation include the following content, in the following order:
        • a one-line description
        • @deprecated tag (if applicable)
        • one or more summary paragraphs (recommended)
        • @tparam tags (if applicable)
        • @param tags (if applicable)
        • @return tag (if applicable)
        • @throws tags (if applicable; we should disallow @exception or @throw for consistency with Python's raises)
        • exception safety (preferably via a custom tag to be added to LSST's Doxygen files)
        • @relatesalso tag (for non-member helper functions; we should standardize on one of @relatesalso and @relatedalso)
        • @see tags (optional)
        • @note tags (optional)
        • @cite tags (optional)
        • @example tags (optional)
      • that the use of the @overload tag be documented separately from the basic function documentation, as at present
      • that public or protected constant or other variable-like documentation include the following content, in the following order:
        • a one-line description
        • @deprecated tag (if applicable)
        • one or more summary paragraphs (optional)
        • @hideinitializer or @showinitializer tag (optional)
        • @note tags (optional)
        • @cite tags (optional)
        • @example tags (optional)

      I have no specific changes to suggest for "File Description Comment for Header Files" or "Package Documentation / Definition", but such changes should be considered within scope of this RFC.

      Would it be useful to use an optional @since tag to indicate when a new component was added to its package? I haven't seen much about versioning in the developer documentation, so I have no idea how reasonable this would be.

        Attachments

          Issue Links

            Activity

            No builds found.
            krzys Krzysztof Findeisen created issue -
            tjenness Tim Jenness made changes -
            Field Original Value New Value
            Watchers Krzysztof Findeisen, Tim Jenness [ Krzysztof Findeisen, Tim Jenness ] Jonathan Sick, Krzysztof Findeisen [ Jonathan Sick, Krzysztof Findeisen ]
            Hide
            Parejkoj John Parejko added a comment -

            +1 Standardization of documentation (and requirements to have it) are good.

            Show
            Parejkoj John Parejko added a comment - +1 Standardization of documentation (and requirements to have it) are good.
            Hide
            ktl Kian-Tat Lim added a comment -

            +1 from me if people can stand writing all that .

            Show
            ktl Kian-Tat Lim added a comment - +1 from me if people can stand writing all that .
            Hide
            jbosch Jim Bosch added a comment -

            +1 on all of this.

            I think I'd advocate dropping file-level Doxygen comments entirely, or at least allowing them to be empty when they'd be identical to the description of the only or primary class in the file. We have too many of these right now that don't add any useful information.

            Also, if this hasn't been established in our guidelines, I think we should prefer "@" for Doxygen markup rather than "\". As discussed recently somewhere, "\" is parsed by too many other tools, and that can cause confusion.

            Show
            jbosch Jim Bosch added a comment - +1 on all of this. I think I'd advocate dropping file-level Doxygen comments entirely, or at least allowing them to be empty when they'd be identical to the description of the only or primary class in the file. We have too many of these right now that don't add any useful information. Also, if this hasn't been established in our guidelines, I think we should prefer "@" for Doxygen markup rather than "\". As discussed recently somewhere, "\" is parsed by too many other tools, and that can cause confusion.
            Hide
            jsick Jonathan Sick added a comment -

            Thanks Krzysztof Findeisen, this is great! I like your suggestions with Jim Bosch's additions. I don't think we'll be using file-level Doxygen comments in the Pipelines API reference.

            Re: version added:

            I've seen a lot of projects use 'version added' fields, but most do it quite inconsistently. It seems to only happen when an overall API is very mature, as a way to highlight new APIs or changes to call parameters.

            At the same time, we'll be publishing documentation in parallel for each release (and more), so the API reference is really a representation of truth for the specific version of the Stack that are being used. When an API was added is besides the point (deprecation notices are different, since they provide actionable information).

            The release notes are the best place to advertise new and changed APIs (in addition to collecting deprecation notices). We've been poor at documenting API changes in our release notes and/or change log (our release notes are mostly at a higher level), but this is a direction we want to go (not yet here in this RFC).

            In summary, I can see cases where we'll want to have 'version added' or 'version changed' fields in C++ docs for very tricky and backwards incompatible changes, but for the most part consistent version information should be in release notes/change logs.

            Show
            jsick Jonathan Sick added a comment - Thanks Krzysztof Findeisen , this is great! I like your suggestions with Jim Bosch 's additions. I don't think we'll be using file-level Doxygen comments in the Pipelines API reference. Re: version added: I've seen a lot of projects use 'version added' fields, but most do it quite inconsistently. It seems to only happen when an overall API is very mature, as a way to highlight new APIs or changes to call parameters. At the same time, we'll be publishing documentation in parallel for each release (and more), so the API reference is really a representation of truth for the specific version of the Stack that are being used. When an API was added is besides the point (deprecation notices are different, since they provide actionable information). The release notes are the best place to advertise new and changed APIs (in addition to collecting deprecation notices). We've been poor at documenting API changes in our release notes and/or change log (our release notes are mostly at a higher level), but this is a direction we want to go (not yet here in this RFC). In summary, I can see cases where we'll want to have 'version added' or 'version changed' fields in C++ docs for very tricky and backwards incompatible changes, but for the most part consistent version information should be in release notes/change logs.
            Hide
            jsick Jonathan Sick added a comment -

            The C++ API documentation standards should point out that doxygen comments must be in the .h file. See https://community.lsst.org/t/doxygen-parsing-of-cc-files/1175?u=jsick

            Show
            jsick Jonathan Sick added a comment - The C++ API documentation standards should point out that doxygen comments must be in the .h file. See https://community.lsst.org/t/doxygen-parsing-of-cc-files/1175?u=jsick
            Hide
            krzys Krzysztof Findeisen added a comment -

            Jim Bosch, it's been a couple of years since I've used Doxygen, but IIRC documentation for top level functions and (eew) globals only gets generated if there's a @file comment – otherwise, there's no page to put the function documentation on. Classes don't need a @file, though.

            Jonathan Sick, is the "only in headers" already LSST policy (and merely contradicted by the existing guidelines), or is it something being introduced in this RFC? I've never (yet) encountered the bug you linked to, and separating method specs from their definitions does make it harder to implement/maintain the latter.

            Re: @since tags, I have found them useful for deciding whether I have access to a feature when I don't have access to old documentation (and it's much easier than searching through the release notes of an indeterminate number of versions), but I won't press the point.

            Show
            krzys Krzysztof Findeisen added a comment - Jim Bosch , it's been a couple of years since I've used Doxygen, but IIRC documentation for top level functions and (eew) globals only gets generated if there's a @file comment – otherwise, there's no page to put the function documentation on. Classes don't need a @file , though. Jonathan Sick , is the "only in headers" already LSST policy (and merely contradicted by the existing guidelines), or is it something being introduced in this RFC? I've never (yet) encountered the bug you linked to, and separating method specs from their definitions does make it harder to implement/maintain the latter. Re: @since tags, I have found them useful for deciding whether I have access to a feature when I don't have access to old documentation (and it's much easier than searching through the release notes of an indeterminate number of versions), but I won't press the point.
            Hide
            jbosch Jim Bosch added a comment - - edited

            I've just scoured my email for what happened with the policy on whether all Doxygen goes in header files, and it looks like it was formally decided that all new documentation should go in .h files, but it's not clear whether the guidelines were actual updated (it seems like they were from the conversation, but that was back on Trac, and now that page is just a link to Confluence). I'm not sure if old LSST mailing lists are archived somewhere, but this was thread dm-devel #4 with subject "Updating the C++ Standards Doc", dated 10/31/14.

            Oh, and if anyone is interesting in tracking down the history here further, that email refers to a TCT meeting on October 5, 2012 (so even that old email thread was trying to reconstruct history), which sadly doesn't have meeting notes in Trac, probably because (according to the email thread) Robyn Allsman wasn't there for that meeting.

            Show
            jbosch Jim Bosch added a comment - - edited I've just scoured my email for what happened with the policy on whether all Doxygen goes in header files, and it looks like it was formally decided that all new documentation should go in .h files, but it's not clear whether the guidelines were actual updated (it seems like they were from the conversation, but that was back on Trac, and now that page is just a link to Confluence). I'm not sure if old LSST mailing lists are archived somewhere, but this was thread dm-devel #4 with subject "Updating the C++ Standards Doc", dated 10/31/14. Oh, and if anyone is interesting in tracking down the history here further, that email refers to a TCT meeting on October 5, 2012 (so even that old email thread was trying to reconstruct history), which sadly doesn't have meeting notes in Trac , probably because (according to the email thread) Robyn Allsman wasn't there for that meeting.
            Hide
            krzys Krzysztof Findeisen added a comment -

            A concern: in my original post, I proposed that an alias be added to Doxygen config files to allow a documentation section for exception safety. Given that the discussion Jonathan linked to suggests LSST's Doxygen setup is fairly brittle, do we dare make such configuration changes?

            Show
            krzys Krzysztof Findeisen added a comment - A concern: in my original post, I proposed that an alias be added to Doxygen config files to allow a documentation section for exception safety. Given that the discussion Jonathan linked to suggests LSST's Doxygen setup is fairly brittle, do we dare make such configuration changes?
            Hide
            jbosch Jim Bosch added a comment -

            Given that the discussion Jonathan linked to suggests LSST's Doxygen setup is fairly brittle, do we dare make such configuration changes?

            I wouldn't let that stand in the way; we can let the RFC be about what we want and what should be obtainable, and if the implementation ticket takes longer because something doesn't work properly, we can treat that as a separate problem.

            Show
            jbosch Jim Bosch added a comment - Given that the discussion Jonathan linked to suggests LSST's Doxygen setup is fairly brittle, do we dare make such configuration changes? I wouldn't let that stand in the way; we can let the RFC be about what we want and what should be obtainable, and if the implementation ticket takes longer because something doesn't work properly, we can treat that as a separate problem.
            Hide
            krzys Krzysztof Findeisen added a comment -

            We seem to have consensus on most things. I'd be happy to resolve the question of alternate keywords by fiat, so the only outstanding issue is the file-level comment block.

            I agree with Jim Bosch that file-level comments rarely have useful content, but removing file pages from the documentation means removing any API element that's not a class member. Could we change the rules so that the file comment is required if and only if the class has functions (including auxiliary functions or operators related to a class), and should not be present if the file only declares classes? Or would that make things too confusing and/or inconsistent?

            Show
            krzys Krzysztof Findeisen added a comment - We seem to have consensus on most things. I'd be happy to resolve the question of alternate keywords by fiat, so the only outstanding issue is the file-level comment block. I agree with Jim Bosch that file-level comments rarely have useful content, but removing file pages from the documentation means removing any API element that's not a class member. Could we change the rules so that the file comment is required if and only if the class has functions (including auxiliary functions or operators related to a class), and should not be present if the file only declares classes? Or would that make things too confusing and/or inconsistent?
            Hide
            jbosch Jim Bosch added a comment -

            Could we change the rules so that the file comment is required if and only if the class has functions (including auxiliary functions or operators related to a class), and should not be present if the file only declares classes? Or would that make things too confusing and/or inconsistent?

            I think this would be okay, though I agree it could make it too easy to forget at times. It sounds like we either have to do that or add a file comment with no content to every file.

            Show
            jbosch Jim Bosch added a comment - Could we change the rules so that the file comment is required if and only if the class has functions (including auxiliary functions or operators related to a class), and should not be present if the file only declares classes? Or would that make things too confusing and/or inconsistent? I think this would be okay, though I agree it could make it too easy to forget at times. It sounds like we either have to do that or add a file comment with no content to every file.
            Hide
            krzys Krzysztof Findeisen added a comment -

            Aha, I did some testing and it appears function documentation is still generated, at least in afw. I don't know if this is because namespace documentation (where the generated documentation appears) is configured differently or because header files get verbatim included anyway.

            I withdraw my objections to removing @file (though the question may need to be revisited if source inclusion is disabled later on).

            Show
            krzys Krzysztof Findeisen added a comment - Aha, I did some testing and it appears function documentation is still generated, at least in afw . I don't know if this is because namespace documentation (where the generated documentation appears) is configured differently or because header files get verbatim included anyway. I withdraw my objections to removing @file (though the question may need to be revisited if source inclusion is disabled later on).
            krzys Krzysztof Findeisen made changes -
            Link This issue is triggering DM-7891 [ DM-7891 ]
            krzys Krzysztof Findeisen made changes -
            Link This issue is triggering DM-7892 [ DM-7892 ]
            krzys Krzysztof Findeisen made changes -
            Link This issue is triggering DM-7893 [ DM-7893 ]
            Hide
            krzys Krzysztof Findeisen added a comment -

            Adopting with changes proposed by Jim Bosch and Jonathan Sick.

            Show
            krzys Krzysztof Findeisen added a comment - Adopting with changes proposed by Jim Bosch and Jonathan Sick.
            krzys Krzysztof Findeisen made changes -
            Resolution Done [ 10000 ]
            Status Proposed [ 10805 ] Adopted [ 10806 ]
            krzys Krzysztof Findeisen made changes -
            Link This issue is triggering DM-9049 [ DM-9049 ]
            krzys Krzysztof Findeisen made changes -
            Status Adopted [ 10806 ] Implemented [ 11105 ]
            krzys Krzysztof Findeisen made changes -
            Link This issue relates to DM-16814 [ DM-16814 ]

              People

              Assignee:
              krzys Krzysztof Findeisen
              Reporter:
              krzys Krzysztof Findeisen
              Watchers:
              Jim Bosch, John Parejko, John Swinbank, Jonathan Sick, Joshua Meyers, Kian-Tat Lim, Krzysztof Findeisen
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Planned End:

                  Jenkins

                  No builds found.