Commit c743a28
authored
Fix doxygen configuraiton (#149)
Here is why we fix the doxygen in this way.
I discussed with Gemini about how to fix this issue by asking
why doxygen cannot recognize class like class INFLECTION_CLASS_API inflection::dialog::NumberConcept ? how to fix it?
Gemini answered:
Doxygen's primary job is to parse C++, C, Java, Python, and other code to generate documentation. When Doxygen fails to recognize a class like class INFLECTION_CLASS_API inflection::dialog::NumberConcept, it's almost always due to the preprocessor macro INFLECTION_CLASS_API.
Here's why this happens and how to fix it:
Why Doxygen Cannot Recognize It
Preprocessor Macro Obscuring the Class Definition: Doxygen has a built-in preprocessor. If INFLECTION_CLASS_API is a macro that expands to something like __declspec(dllexport) (common for Windows DLLs) or __attribute__((visibility("default"))) (common for GCC/Clang on Linux/macOS), Doxygen's parser, by default, might not correctly interpret the resulting code. It sees __declspec(dllexport) class ... instead of class ....
ENABLE_PREPROCESSING = NO: If ENABLE_PREPROCESSING is set to NO in your Doxyfile, Doxygen won't process any macros, and it will simply see INFLECTION_CLASS_API as part of the class name, leading to a parsing error.
Macro Expansion Issues: Even with preprocessing enabled, Doxygen's default macro expansion behavior might not be sufficient. It might not expand INFLECTION_CLASS_API in a way that reveals the underlying class keyword to its parser.
How to Fix It
The solution involves configuring Doxygen's preprocessor to correctly handle the INFLECTION_CLASS_API macro.
Enable Preprocessing:
Make sure ENABLE_PREPROCESSING is set to YES in your Doxyfile.
Code snippet
ENABLE_PREPROCESSING = YES
Define the Macro in Doxygen:
You need to tell Doxygen what INFLECTION_CLASS_API means so it can effectively ignore or replace it during parsing. This is done using the PREDEFINED tag in your Doxyfile.
If INFLECTION_CLASS_API is empty (or should be ignored by Doxygen):
This is often the case for API macros where they expand to nothing for documentation builds.
Code snippet
PREDEFINED = INFLECTION_CLASS_API=
This tells Doxygen to replace INFLECTION_CLASS_API with nothing.
If INFLECTION_CLASS_API expands to a __declspec or __attribute__:
You need to remove these compiler-specific attributes.
For __declspec(dllexport) or __declspec(dllimport):
Code snippet
PREDEFINED = __declspec(x)=
This tells Doxygen to replace __declspec(anything) with nothing.
For __attribute__((visibility("default"))) or similar:
Code snippet
PREDEFINED = __attribute__(x)=
This tells Doxygen to replace __attribute__(anything) with nothing.
If INFLECTION_CLASS_API is a more complex macro:
If it's something like #define INFLECTION_CLASS_API SOME_OTHER_MACRO class, you might need to combine PREDEFINED with MACRO_EXPANSION and EXPAND_ONLY_PREDEF.
For example, if INFLECTION_CLASS_API itself expands to a simple empty string or a known attribute, the above methods should work. If it's more complex, you might need to use MACRO_EXPANSION = YES and EXPAND_ONLY_PREDEF = YES, then explicitly define INFLECTION_CLASS_API in PREDEFINED to be empty or a simple class keyword if it's truly hiding class. However, it's generally better to make the macro itself expand to an empty string for Doxygen.
Example PREDEFINED entry (most common scenario):
Code snippet
PREDEFINED = INFLECTION_CLASS_API= \
__declspec(x)= \
__attribute__(x)=
(Note the \ for multi-line definitions).
Run Doxygen in Debug Mode (Preprocessor Output):
If the above doesn't work, you can see exactly what Doxygen's preprocessor is doing by running Doxygen with the -d Preprocessor flag:
Bash
doxygen -d Preprocessor your_Doxyfile
This will print the preprocessed output to the console, allowing you to see how INFLECTION_CLASS_API is being handled and debug your PREDEFINED settings.
Steps to Implement the Fix:
Open your Doxyfile: This is the configuration file for your Doxygen project.
Locate ENABLE_PREPROCESSING: Ensure it's set to YES. If not, change it.
Locate PREDEFINED: Add or modify this tag.
Find out what INFLECTION_CLASS_API expands to in your actual build system (e.g., by looking at compiler preprocessor output or just checking the macro definition in your code).
Based on that, add the appropriate definition to PREDEFINED to effectively remove or normalize INFLECTION_CLASS_API for Doxygen.
Re-run Doxygen: After modifying the Doxyfile, run Doxygen again to generate the documentation.
By correctly configuring Doxygen's preprocessor to handle INFLECTION_CLASS_API, you should be able to get it to recognize your inflection::dialog::NumberConcept class.1 parent 33fecb1 commit c743a28
1 file changed
+6
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2373 | 2373 | | |
2374 | 2374 | | |
2375 | 2375 | | |
2376 | | - | |
| 2376 | + | |
2377 | 2377 | | |
2378 | 2378 | | |
2379 | 2379 | | |
2380 | 2380 | | |
2381 | 2381 | | |
2382 | 2382 | | |
2383 | 2383 | | |
2384 | | - | |
| 2384 | + | |
2385 | 2385 | | |
2386 | 2386 | | |
2387 | 2387 | | |
| |||
2404 | 2404 | | |
2405 | 2405 | | |
2406 | 2406 | | |
2407 | | - | |
| 2407 | + | |
| 2408 | + | |
2408 | 2409 | | |
2409 | 2410 | | |
2410 | 2411 | | |
| |||
2414 | 2415 | | |
2415 | 2416 | | |
2416 | 2417 | | |
2417 | | - | |
| 2418 | + | |
| 2419 | + | |
2418 | 2420 | | |
2419 | 2421 | | |
2420 | 2422 | | |
| |||
0 commit comments