vovkos / doxyrest

A compiler from Doxygen XML to reStructuredText -- hence, the name. It parses XML databases generated by Doxygen and produces reStructuredText for the Python documentation generator Sphinx.
MIT License
306 stars 23 forks source link

Doxyrest does not provide value for #define(s) in .rst files #50

Open mateasmario opened 2 years ago

mateasmario commented 2 years ago

I'm trying to generate documentation for a C++ source code (file main.cpp) using Doxygen, doxyrest and Sphinx. The source code looks like this:

/*! \file main.cpp
    \brief A Documented file.

    Details.
*/

/*! \def MAXIMUMSIZE

    \brief A macro that returns the maximum

    Details.
*/
#define MAXIMUMSIZE 20

//! A public variable.
/*!
    Details.
*/
    int publicVar = 3;

I have both GENERATE_HTML and GENERATE_XML enabled in Doxygen, and everything seems to be fine. The problem is when I'm trying to generate .rst files based on my newly generated xml-dir folder. I've seen that the value of the publicVar integer is written in the rst(s), but MAXIMUMSIZE's value is not. image

I need my Sphinx documentation to also provide the value of the #define, not only its name.

This is how Sphinx looks like: image

And I want it to be like that: image

Is there any stuff in doxyrest-config.lua I need to change in order to keep the macro values?

LexouDuck commented 2 years ago

There is indeed a simple enough workaround for this, which I use in my own projects.

You need to add a line of code to the doxyrest/frame/cfamily/utils.lua file, at line 505:

function getDefineDeclString(define, nameTemplate, indent)
    local s = "#define "

    s = s .. fillItemNameTemplate(nameTemplate, define.name, define.id)

    if #define.paramArray > 0 then
        -- no space between name and params!

        s = s .. getParamArrayString(s, define.paramArray, false, "(", ")", indent, " \\\n")
    end

>   s = s .. '\t' .. getLinkedTextString(define.initializer, true)

    return s
end

You can see the line of code in question, I put a > character at the beginning of the line.