Generate Doxygen comments by parsing function prototype

Asked by Salvatore Benedetto

I'd like to create a simple python snippet that generates automatically a doxygen block from a C/C++ function prototype.

I've started with something very simple like this

snippet dfunct "Funciont/Method doxygen description" b
/*!
 * \anchor `!p res=snip.v.text.split()[1]`
 * \brief TODO
 *
 * \param[in]
 *
 * \return `!p res=snip.v.text.split()[0]`
 *
 * <strong>Example</strong>
 * \code
 * \endcode
 */
 ${VISUAL}
endsnippet

and the first question that I wanted to ask is if I have to reparse the snip.v.text object every time (like I do above for anchor
and return) or if I can parse it once, and access the result from the rest of the snippets?

The other question I was wondering if there is any way to access the content of the ViM unnamed register from a snippet,
so that I can use that instead of the visually selected text?

Thanks for this great plugin by the way! I really love it.

Question information

Language:
English Edit question
Status:
Answered
For:
UltiSnips Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
SirVer (sirver) said :
#1

1) you can assign to a variable in the first block - the python blocks are evaluated in order, so you have access to the same scope in all of them.
2) use vim.eval() for that. see :help python. something like vim.eval('expand(\'""\')') might work.

Revision history for this message
Salvatore Benedetto (salvatore-benedetto) said :
#2

Thanks a lot SirVer!

Revision history for this message
eddie ash (eddie-b) said :
#3

Salvatore,
If you were able to complete this snippet. Can you please post the code? I would be intrested in using it.

Can you help with this problem?

Provide an answer of your own, or ask Salvatore Benedetto for more information if necessary.

To post a message you must log in.