Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I write doxygen alias similar to @code or @verbatim?

Tags:

doxygen

I need an alias to mark command-line code, set on a black background with white text, to be used like this:

@cmd
C:\temp>echo Hello, world!
Hello, world!

C:\temp>
@endcmd

Ordinary doxygen's aliases can't do this (multiline, nested "\temp"), but @code and @verbatim can. However, I can't use them because they are formatted as a white background with black text, so overwriting pre.fragment class with a custom CSS is not correct.

Any ideas?

UPD: Comments showed how bad my English is...

Well, try again. Regular doxygen's features like HTML and XML works as shown bellow:

    cpp file                       doxygen produced index.html
/**
@mainpage main               |  
<pre>                        | <pre>C:&gt;echo Hello, world! 
C:\temp>echo Hello, world!   | Hello, world!</pre>  
Hello, world!                |
                             |
C:\temp>                     | <pre>C:&gt;</pre>
</pre>                       |
*/                           |

in the log:

/tmp/index.h:3: warning: Found unknown command `\temp'
/tmp/index.h:6: warning: Found unknown command `\temp'

"code" and "verbatim" works different! Feel the difference:

  cpp file                       doxygen produced index.html
/**
@mainpage main               |
@verbatim                    | <div class="fragment">
C:\temp>echo Hello, world!   | <pre class="fragment">C:\temp&gt;echo Hello, world!
Hello, world!                | Hello, world!
                             |
C:\temp>                     | C:\temp&gt;
@endverbatim                 | </pre>
*/                           | <div>

The question is: Can I write alias, that will work like "code" or "verbatim". Is it clean now?

like image 414
hoxnox Avatar asked Nov 04 '22 06:11

hoxnox


2 Answers

What about just using and HTML div with your own CSS markup added to the Doxygen css file. It seems about the same amount of typing.

like image 159
Paul Joireman Avatar answered Nov 12 '22 23:11

Paul Joireman


This answer summarises some the the comments in Paul Joireman's answer.

Paul Joireman's answer is the way to go. Define two aliases in your doxygen configuration file:

ALIASES += "mycode=<div class="myfragment"><pre class=myfragment>"
ALIASES += "endmycode=</pre></div>"

and the wrap your code example in \mycode and \endmycode statements. For example, your C++ file could look something like

/** \mainpage main
 * \mycode
 * C:\\temp>echo Hello, World!
 * Hello, World!
 *
 * \endmycode
*/

which yields the following corresponding doxygen HTML output:

<div class="myfragment>"><pre class="myfragment>">
 C:\temp&gt;echo Hello, World!
 Hello, World!</pre></div>

(I'm not sure why there are >'s in the class="myfragments>" parts). You will need to format the myfragments class in the CSS file.

The one additional thing in the above C++ code that wasn't mentioned in the comments is the use of the escaped backslash \\ in the code example.

like image 21
Chris Avatar answered Nov 13 '22 00:11

Chris