Doxygen: how to include a markdown page to document a group - doxygen

I have a rather complex project and I want to document it using doxygen.
I have no problem documenting the code and I also managed to have a nice front-page using a custom README.md file coupled with "USE_MDFILE_AS_MAINPAGE = README.md" directive in Doxyfile.
I defined several groups (#defgroup) which show up as "Modules" in my documentation.
I would like to add a "main page" to each of the group giving general information, beside the customary function/variable/type documentation.
I tried adding custom MODULENAME.md files coupled with matching #includedoc MODULENAME.md entries in group definition, it seem to work (I see several lines like: "Generating docs for page md_mcu_noitr_coro_README..."), but I cannot find if and where the page is linked (I expected to see it in the "Detailed Description" for the module, as it happens if I put some documentation inline where I put the "#includedoc" directive.
a snippet of one of my modules is:
/**
* #file coro.h
* #brief definition of coroutine implementing functions.
*
* #date: Feb 8, 2018
* #author: myself
*
* #defgroup coro "Coroutine implementation in plain 'C'."
*
* #includedoc mcu_noitr/coro/README.md
* #{
*
*/
What am I doing wrong?
Note: it is also a bit surprising I need to put the whole path from where my Doxyfile is, otherwise doxygen won't find it even if it's right beside the file containing the #includedoc command.

I also came across the problem that included files with Markdown formatted text via \includedoc or \include{doc} does not result in correctly interpreted Markdown. Note that I included Markdown files from other Markdown files. My work-around was to use the C pre-processor (cpp) - which is widely available - on Markdown files and use it's #include directive. You could of course use a true general text processor such as M4 as suggested in the cpp man page. Set FILTER_PATTERNS in Doxyfile as:
FILTER_PATTERNS = *.md="cpp -P -traditional-cpp"
You'll need the -P option to avoid it outputting line markers, which confuses Doxygen. -traditional-cpp was needed to avoid cpp eating white space that is important for the correct interpretation of Markdown. Don't use single quotes as this results in an error when Doxygen calls cpp via sh.
Then in my Markdown main page:
Main Page {#mainpage}
==========
Blah blah blah.
#include "other.md"
Using FILTER_PATTERNS instead of INPUT_FILTER avoids the problem about not being allowed to add or remove lines.
I have my markdown files in the same directory, I would guess that if they are located in different places you could tell cpp about it via -I, which would address your expectations about include paths on the issue you filed.

At the moment doxygen does not consider the fact that commands like \includedoc can contain markdown code. At the moment the only possibility would be to write a filter, see configuration parateter INPUT_FILTER in the doxygen configuration file, (not tested!) to replace the \includedoc` with the code of that file.

Related

how to create a Doxygen link to the same file

I would like to write a Doxygen comment that names the file in which the comment occurs. Rather than write the filename explicitly, I would like Doxygen to supply me with it. Thus, if I change the name of the file, or move some of the content into a different file, I don't need to change hard-coded instances of the name.
For a concrete example, let's say I'm adding comments to functions in array.hpp, and I want the comment for certain functions to say "This function should only be used within array.hpp." I want to be able to write
/**
* This function should only be used within #thisfile.
*/
where #thisfile is a Doxygen expression that translates into array.hpp within the file array.hpp.
I've looked at the Doxygen documentation, including "Automatic link generation/Links to files" and the entire "Special Commands" section, but I haven't found what I'm looking for. Does such functionality exist?
Note that essentially the same question was asked on the Doxygen mailing list a few weeks ago. It has not received any replies.
General
As far as I know such functionality does not exist out-of-the-box. But you can add it by configuring an INPUT_FILTER in your Doxyfile. The path to the file is passed as an argument to the filter by doxygen. This can be used by the filter to replace your keyword (for example #thisfile) with the path to the file.
Below I give an example how to implement this with bash. A solution for other shells or Windows should be quite similar.
Example for bash
Write a short bash script infiltrate_filename.sh:
#!/bin/bash
pathToScript=`pwd`"/"
sed -e "s:#thisfile:${1/$pathToScript/}:g" $1
This script truncates the path to the file by the working directory. The resulting string is used to replace the keyword of your choice (here: #thisfile).
Make your script executable: chmod +x infiltrate_filename.sh
Set the INPUT_FILTER in your Doxyfile to INPUT_FILTER = ./infiltrate_filename.sh
That's it! 🎉 Now you can use #thisfile in your documentation blocks and it will be replaced by the path to the file. As the paths are relative to Doxygen's working directory they will automatically be linked to the file.
Notes
This solution assumes that the filter script is located in the working directory of doxygen (for example ~/my_project) and that the INPUT files are in subdirectories of the working directory (for example ~/my_project/src/foo/bar).
I have tested this example on a minimum working example. I am not a bash or sed expert. This solution may be improvable.

Customizing Doxygen output for an .ini configuration file

Is there a way to customize the HTML output for an .ini configuration file with incorporated comments, as for example:
[MySection]
;This is an extensive description of MyParameter (possibly with #commands after semicolon?)
MyParameter=MyValue
Despite this is a special usage, I would like to have each parameter parsed/listed separately with description (and unit? and recommended value?). The file could also look like this:
[MySection]
;#brief A brief description
;#details A detailled description
;#unit cows (The physical unit of the parameter)
;#recommendedValue 5 cows
MyParameter=7
Currently, I'm including the .ini file with #include/#verbinclude - unfortunately, without syntax highlighting. Thanks.
OK, I'm assuming that you included the file using the FILE_PATTERNS tag, so that at least the file is listed in your documentation. Additionally you have to set EXTENSION_MAPPING tag to tell doxygen how to interpret this file. Unfortunately the INI file syntax is not supported by doxygen. At this point you have two possibilities:
Writing a custom input-filter (e.g. in perl) and add this as INPUT_FILTER
Varying the comments so that the doxygen parser gets a valid code corresponding to the programming language you have defined in EXTENSION_MAPPING.
For example if you have set EXTENSION_MAPPING = ini=C Then your inifile should look like this:
;/// #file myinifile.ini
;/// #brief A brief description.
;/// #details A detailled description.
;/// #unit cows (The physical unit of the parameter)
;/// #recommendedValue 5 cows
MyParameter=7
;
The additional slashes /// are needed to tell the doxygen parser that this line is a comment line which shall be processed by the doxygen.
Also note the last semicolon ; which is needed since the doxygen C parser is expecting a closing ; after each declaration.

Doxygen: Exclude undocumented files

I have a framework which I am extending. There are some source folders which contain quite a lot of files and I want to document my work (especially those files which come from me) using doxygen.
Any file I am documenting contians a header:
/**
* #file my_file.c
* #author Stefan F.
* #date 28.05.2014
*
* #brief This file is awesome!
*/
Can I somehow tell doxygen to NOT include files without such a header?
I have already set
EXTRACT_ALL = NO
Files which don't have a doxygen header are not generated but they are still listed in the file list.
Does anyone know how to configure doxygen to get that behavior?
I'm not aware of any part of Doxygen that will do exactly what you are looking for, however, the simplest way to achieve your aim is simply to only list the files you want doxygenning in the doxyfile INPUT line.
INPUT = my_file_1.cpp myfile2.cpp moreofmyfiles/etc.cpp
(Beware it's a space separated list.)
Depending on your folder structure you may need to set RECURSIVE = NO
If it's your own personal project and you can name your file myname_file.cpp you could use FILE_PATTERNS to select only those files beginning "myname_* - but I'm expecting that's not a viable set of circumstances.

Doxygen \cite producing empty bibliography

I'm trying to use \cite in Doxygen to produce a bibliography page and also a reference within my text. I have bibtex in my search path and a proper .bib file. I have added the .bib file to CITE_BIB_FILES and am using a proper BibTex label found in the .bib file. Doxygen is creating a bibliography page, but it is empty. It is also creating a citation link in the documentation text, but the link is also empty. Any idea how I can get the citation info displayed?
I was facing the same problem. There is an perl dependency to generate citation. So you must have both perl and bibtex in the system path.
Ignore the example above, that only applies to Latex, for doxygen use (Note: no braces):
\cite Hale
The .bib file has to be located in doxygen working directory.
Bibliographic References HTML page will be then produced by doxygen with:
[1]J. K. Hale. Theory of functional–differential equations. Springer–Verlag, Berlin–Heidelberg–New York, 1977.
for the following bib entry:
#BOOK{Hale,
author = "J. K. Hale",
title = "Theory of functional--differential equations",
publisher = "Springer--Verlag, Berlin--Heidelberg--New York",
year = 1977
}
In order for \cite to work properly you need:
be sure to put your file.bib in the working directory where you call doxygen Doxyfile
bibtex executable must be in the search path
perl executable must be in the search path
the RefName used in \cite RefName must have a corresponding entry in file.bib
Maybe a little late, but I had the same problem. Doxygen generated a bibliography for LaTeX output, but not for HTML output and none of the proposed answers worked for me.
As suggested by #Raffi, this seems to be a bug in Doxygen < 1.8.3. I used Doxygen 1.8.1.1 and it did not work. Then I installed Doxygen 1.8.3.1 without changing anything else and it worked fine.
When you set CITE_BIB_FILES in DoxyFile did you include the .bib extension on the filename?
Doxygen claims it will automatically add the .bib extension, but if you omit it doxygen seems to gets confused and doesn't generate the citelist.doc file properly.
Include .bib in the filename and it should work fine, at least that is the case for me.
In order to create a bibliography you need to instal Perl, and add it to the search path, along with bibtex. In the documentation
for CITE_BIB_FILES it says:
"The CITE_BIB_FILES ... To use this feature you need bibtex and perl available in the search path ... "

Doxygen won't process main.cpp

So I'm new to using Doxygen and I was able to get it to work smoothly. I was able to document my classes and structs and it generates the HTML files perfectly. The issue I'm running into is it won't parse my main.cpp file. All the classes and structs have their own .h and .cpp files and they process fine. How do I get Doxygen to make the documentation for main.cpp? It doesn't have a .h file as this is where the program starts and ends. I wouldn't even know what to put in the .h file for main. I'm using Doxywizard in Windows.
Edit:
I put this in main and it generates a main page:
/**
#mainpage
This is a test application.
#author Alex
#date 10/21/2010
#version 1.0
*/
But then farther down the file where the function prototypes are I have this and it doesn't get parsed:
/**
#brief Error handler for the PDF writer.
It does nothing. It just has to exist.
*/
void error_handler (HPDF_STATUS error_no,
HPDF_STATUS detail_no,
void *user_data)
{
}
I put this at the top of main.cpp and it worked. Go figure.
/**
#file main.cpp
*/
If INPUT and FILE_PATTERNS are empty, it should search for *.cpp files (and many other patterns) in the current directory. (This from the doxygen manual.)
Since yours are empty, I expect one of two things is going on if you're not getting main.cpp documentation:
main.cpp is not in the current directory. To rule this out, make sure you're running doxygen from the same directory as both your config file and main.cpp.
There is a syntax error in your main.cpp documentation. These can be tricky to spot, as doxygen doesn't generally abort when it encounters an error - instead it just skips ahead. If this is the problem, comb through doxygen's output when you generate your docs line by line.
If neither of these ideas solve your problem, we might need more information. Output of ls -R, output of the doxygen run, etc. Good luck!
I did some research on this... From the doxygen manual :
Important: The documentation of global functions, variables, typedefs,
and enums will only be included in the
output if the file they are in is
documented as well.
There you go !