Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change cpp doxygen style #57

Closed
Perry3D opened this issue Jan 31, 2022 · 3 comments
Closed

Change cpp doxygen style #57

Perry3D opened this issue Jan 31, 2022 · 3 comments
Labels
under review Waiting for review by users or developer.

Comments

@Perry3D
Copy link

Perry3D commented Jan 31, 2022

Hi,

is there a way to configure Neogen to use the triple dash style instead of c-style comments?
Currently the doxygen looks like this:

/**
 * @brief 
 *
 * @param a 
 * @param b 
 * @return 
 */
int add(int a, int b);

My company code style is like this:

/// @brief 
/// @param a 
/// @param b 
/// @return 
int add(int a, int b);

Thank you for this great plugin!

@danymat
Copy link
Owner

danymat commented Feb 1, 2022

Hello ! I'm currently in the process of refactoring the codebase to expose more easily the annotation standards, and providing better docs for it !
But now, you can take a look Neogen works in c:

doxygen = {
{ nil, "/**", { no_results = true, type = { "func", "file" } } },
{ nil, " * @file", { no_results = true, type = { "file" } } },
{ nil, " * @brief $1", { no_results = true, type = { "func", "file" } } },
{ nil, " */", { no_results = true, type = { "func", "file" } } },
{ nil, "", { no_results = true, type = { "file" } } },
{ nil, "/**", { type = { "func" } } },
{ nil, " * @brief $1", { type = { "func" } } },
{ nil, " *", { type = { "func" } } },
{ "tparam", " * @tparam %s $1" },
{ "parameters", " * @param %s $1" },
{ "return_statement", " * @return $1" },
{ nil, " */" },
},

This is the template responsible for generating Doxygen in C. You can see that every second parameter of each table is a string, and note that:

  • $1 is the cursor placement
  • %s will be replaced by the value

So for you, the Doxygen table could be something like:

        custom = {
            { nil, "/// @file", { no_results = true, type = { "file" } } },
            { nil, "/// @brief $1", { no_results = true, type = { "func", "file" } } },
            { nil, "", { no_results = true, type = { "file" } } },

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

And to use in your Neogen setup:

require('neogen').setup {
    enabled = true,
	languages = {
	    c = {
	        template = {
                    annotation_convention = "custom",
                    custom =  {
                      { nil, "/// @file", { no_results = true, type = { "file" } } },
                      { nil, "/// @brief $1", { no_results = true, type = { "func", "file" } } },
                      { nil, "", { no_results = true, type = { "file" } } },

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

Tell me if it works !

@danymat danymat added the under review Waiting for review by users or developer. label Feb 1, 2022
@Perry3D
Copy link
Author

Perry3D commented Feb 1, 2022

Thank you very much for the detailed answer. Works fine for me.
Except one copy paste thing: you set the template for lua instead of c or cpp.

require('neogen').setup {
  enabled = true,
  languages = {
    cpp = {
      template = {
        annotation_convention = "custom",
        custom =  {
          { nil, "/// @file", { no_results = true, type = { "file" } } },
          { nil, "/// @brief $1", { no_results = true, type = { "func", "file" } } },
          { nil, "", { no_results = true, type = { "file" } } },

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

@danymat
Copy link
Owner

danymat commented Feb 1, 2022

Oh yeah right, fixed

@danymat danymat closed this as completed Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
under review Waiting for review by users or developer.
Projects
None yet
Development

No branches or pull requests

2 participants