doxyrest icon indicating copy to clipboard operation
doxyrest copied to clipboard

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

Open mateasmario opened this issue 2 years ago • 1 comments

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?

mateasmario avatar Feb 06 '22 17:02 mateasmario

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.

LexouDuck avatar Feb 22 '22 19:02 LexouDuck