Author Topic: Is it possible to see a function's comments in autocomplete?  (Read 7011 times)

MachinTrucChose

  • Guest
Is it possible to see a function's comments in autocomplete?
« on: November 18, 2009, 04:59:01 am »
I love the autocomplete feature and use it frequently, but is there no way to be able to see a function's comments (preferably both the ones in the header and the implementation file)?

It's time-consuming (and annoying) to rightclick the function name, click Go To Declaration/Implementation, read the function's documentation, then navigate back to where I was about to use it.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6035
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Is it possible to see a function's comments in autocomplete?
« Reply #1 on: November 18, 2009, 05:58:30 am »
Good question:
Currently, this is not implemented in the CodeCompletion plugin. So, we us the way your mentioned.
rightclick the function name, click Go To Declaration/Implementation, read the function's documentation, then navigate back to where I was about to use it.

I think there are two ways to add this function:

1, We can open the source file behind the scene, and read the comments around(before and after) the function declaration, and show them in the tip windows.

2, When building the token trie( parsing the source file), we should add new field of Token class, which restore the related comments, then we can use them later.

I personally prefer the first method. :D
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

MachinTrucChose

  • Guest
Re: Is it possible to see a function's comments in autocomplete?
« Reply #2 on: November 20, 2009, 04:21:56 am »
OK, so it's not implemented yet? Thanks for answering.

Out of curiosity, why would the first implementation suggestion be preferable? If I'm understanding you correctly, the Autocomplete plugin parses all the source files on launch, saving all the function names/parameter list in memory. Wouldn't it be better to use that same occasion to save the comments as well? Sure, this uses more memory (a negligeable amount like 1mb unless you're loading the entire Linux kernel source), but at least you're not opening/closing files in the background constantly.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6035
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Is it possible to see a function's comments in autocomplete?
« Reply #3 on: November 20, 2009, 04:28:58 am »
OK, so it's not implemented yet? Thanks for answering.

Out of curiosity, why would the first implementation suggestion be preferable? If I'm understanding you correctly, the Autocomplete plugin parses all the source files on launch, saving all the function names/parameter list in memory. Wouldn't it be better to use that same occasion to save the comments as well? Sure, this uses more memory (a negligeable amount like 1mb unless you're loading the entire Linux kernel source), but at least you're not opening/closing files in the background constantly.

Yes, You are right!
This is a good reason to use the second implementation. We can add a field "wxString comment" to every Token. But I'm not sure it can implement easily. Because we have both comments around the statement. How can the parser determine which comment belong to the correct token?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9702
Re: Is it possible to see a function's comments in autocomplete?
« Reply #4 on: November 20, 2009, 06:40:47 am »
How can the parser determine which comment belong to the correct token?
This is absolutely not easy. Often you find such code snippets:
Code
/* My comment on the function */
/* const */ RetObj& MyFunc (int i, float b) // b=0
{
  // ...
}

How would you differ which comment to show?

The only thing I can imagine is to support e.g. doxygen comments only. In that case the code would look like:
Code
/** My doxygen comment on the function */
/* const */ RetObj& MyFunc (int i, float b) // b=0
{
  // ...
}
...and you could easily search for comments between "/**" and "*/" before a function. Hence using specialisations like:
Code
int myInt; //!< My Doxygen comment
...which are possible in principle for functions, too would be difficult.

So - the only idea I have is to support doxygen style comments before a function. The last question: What to show? The documentation of the declaration, or implementation, both can be applicable and appear twice.

Edit: I'll also tell you what I usually do:
I create code with full doxygen documentation. Then I create the documentation and embed this into C::B as a help file. Thus I have always every documentation available. Because mostly I not only need the docs of the function, but some others, too. which are nicely liinked in the generated help.
« Last Edit: November 20, 2009, 06:44:50 am by MortenMacFly »
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: Is it possible to see a function's comments in autocomplete?
« Reply #5 on: November 20, 2009, 07:15:07 am »
Quote
Edit: I'll also tell you what I usually do:
I create code with full doxygen documentation. Then I create the documentation and embed this into C::B as a help file. Thus I have always every documentation available. Because mostly I not only need the docs of the function, but some others, too. which are nicely liinked in the generated help.


Seems a good way. :D
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline frithjofh

  • Regular
  • ***
  • Posts: 376
Re: Is it possible to see a function's comments in autocomplete?
« Reply #6 on: November 20, 2009, 01:22:55 pm »
maybe the way morten describes is the way for a new plugin. automating the insertion of the documentation in the files a little bit and generating the help file directly and having the possibility of viewing this help file in a the html help view window ...
regards

nausea
« Last Edit: November 20, 2009, 01:26:13 pm by nausea »
architect with some spare time  -  c::b compiled from last svn  -   openSuSE leap x86_64  -  AMD FX-4100

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9702
Re: Is it possible to see a function's comments in autocomplete?
« Reply #7 on: November 20, 2009, 03:08:49 pm »
automating the insertion of the documentation in the files a little bit
This is partially already done if you are using the class wizard to create a new class. This wizard can already setup doxygen comments for you according to the setup of your class.

generating the help file directly
I've automised this compatible to all my projects (that follow a certain structure) easily with a batch file that takes arguments from the command I am triggering via an entry in the tool menu.

having the possibility of viewing this help file in a the html help view window ...
This is present.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ