danymat / neogen

A better annotation generator. Supports multiple languages and annotation conventions.
GNU General Public License v3.0
1.28k stars 55 forks source link

feature: please support /// comments for c and c++ #146

Open aerosayan opened 1 year ago

aerosayan commented 1 year ago

Hello,

Thanks for creating neogen. I really love using it. It makes doxygen documenting code so easy. Literally saves hours.

Currently you support the default style of doxygen comments for c/c++ i.e /* doxygen comments here */

Could you please also support /// based comments?

For example, something like this:

    ///
    /// Subdivide the given node, and create 8 child nodes
    ///
    /// @param iLevelIdx : level index of parent node
    /// @param iSelfIdx : self index of parent node
    /// @param id : thread id
    ///
    void
    SubdivideNode(const oxint iLevelIdx, const oxint iSelfIdx, const oxint id);

    ///
    /// Set the required values of the newly created child nodes
    ///
    /// @param iParentLevelIdx : level index of parent node
    /// @param iParentIdx : self index of parent node
    /// @param iSelfIdx : self index of current child node
    /// @param iSiblingIdx : sibling index of current child node
    /// @param id : thread id
    ///
    void
    SetChildNode(
        const oxint iParentLevelIdx, const oxint iParentIdx,
        const oxint iSelfIdx, const oxint iSiblingIdx, const oxint id);

This style of comments is actually preferred by many c/c++ devs and it would be amazing if you could support it.

Thanks

Luxni commented 6 months ago

the example is described in "lua/neogen/template.lua", i test in my lazyvim config, it's worked for me.

return {
  "danymat/neogen",
  dependencies = "nvim-treesitter/nvim-treesitter",
  config = true,
  opts = {
    languages = {
      c = {
        template = {
          annotation_convention = "my_doxygen",
          my_doxygen = {
            { nil, "/**", { no_results = true, type = { "func", "file", "class" } } },
            { nil, " * @file", { no_results = true, type = { "file" } } },
            { nil, " * @brief $1", { no_results = true, type = { "func", "file", "class" } } },
            { nil, " */", { no_results = true, type = { "func", "file", "class" } } },
            { nil, "", { no_results = true, type = { "file" } } },

            { nil, "///", { type = { "func", "class", "type" } } },
            { "class_name", " /// @class %s", { type = { "class" } } },
            { "type", "/// @typedef %s", { type = { "type" } } },
            { nil, "/// @brief $1", { type = { "func", "class", "type" } } },
            { nil, "///", { type = { "func", "class", "type" } } },
            { "tparam", "/// @tparam %s $1" },
            { "parameters", "/// @param %s $1" },
            { "return_statement", "/// @return $1" },
            { nil, "///", { type = { "func", "class", "type" } } },
},},},},},}