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:>echo Hello, world!
C:\temp>echo Hello, world! | Hello, world!</pre>
Hello, world! |
|
C:\temp> | <pre>C:></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>echo Hello, world!
Hello, world! | Hello, world!
|
C:\temp> | C:\temp>
@endverbatim | </pre>
*/ | <div>
The question is: Can I write alias, that will work like "code" or "verbatim". Is it clean now?
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.
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>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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With