Skip to content

indocumentationsnippets

jgillis edited this page Feb 3, 2015 · 4 revisions

Snippets of python code + output in the API intend to make CasADi project more accessible. An example can be seen in the API docs.

It is very easy for users to add such snippets: once you locate the correct Doxygen lines, use the following syntax to add code:

/** \brief foo

    \doctest
    print 123
    print SX.sym("x")
    \doctestout
    123
    x
    \enddoctest
*/
void foo();

Note: no '*' symbols in the lines with the doctests.

The code will be formatted nicely in the api docs, and, more crucially will end up (*) in the Python docstrings as:

"""
>>> print 123
>>> print SX.sym("x")
123
x
""""

This is unittested as python -m doctests -v casadi.py by casadibot every night

(*) casadibot does this with make doxexport in docs/api

Clone this wiki locally