Skip to content

Commit c743a28

Browse files
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

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

inflection/docs/Doxyfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,15 +2373,15 @@ ENABLE_PREPROCESSING = YES
23732373
# The default value is: NO.
23742374
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
23752375

2376-
MACRO_EXPANSION = NO
2376+
MACRO_EXPANSION = YES
23772377

23782378
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
23792379
# the macro expansion is limited to the macros specified with the PREDEFINED and
23802380
# EXPAND_AS_DEFINED tags.
23812381
# The default value is: NO.
23822382
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
23832383

2384-
EXPAND_ONLY_PREDEF = NO
2384+
EXPAND_ONLY_PREDEF = YES
23852385

23862386
# If the SEARCH_INCLUDES tag is set to YES, the include files in the
23872387
# INCLUDE_PATH will be searched if a #include is found.
@@ -2404,7 +2404,8 @@ INCLUDE_PATH =
24042404
# used.
24052405
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
24062406

2407-
INCLUDE_FILE_PATTERNS =
2407+
INCLUDE_FILE_PATTERNS = *.h \
2408+
*.hpp
24082409

24092410
# The PREDEFINED tag can be used to specify one or more macro names that are
24102411
# defined before the preprocessor is started (similar to the -D option of e.g.
@@ -2414,7 +2415,8 @@ INCLUDE_FILE_PATTERNS =
24142415
# recursively expanded use the := operator instead of the = operator.
24152416
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
24162417

2417-
PREDEFINED =
2418+
PREDEFINED = INFLECTION_CLASS_API= \
2419+
INFLECTION_CAPI=
24182420

24192421
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
24202422
# tag can be used to specify a list of macro names that should be expanded. The

0 commit comments

Comments
 (0)