136

I made documentation for my SDK, using Doxygen. It contains the list of files, namespaces, classes, types etc. - everything that I placed as Doxygen comments in the code. Now I want to write some general information about SDK (kind of introduction), which is not related directly to any code element. I want to place this introduction on the documentation start page. How can I do this?

1

6 Answers 6

114

Have a look at the mainpage command.

Also, have a look this answer to another thread: How to include custom files in Doxygen. It states that there are three extensions which doxygen classes as additional documentation files: .dox, .txt and .doc. Files with these extensions do not appear in the file index but can be used to include additional information into your final documentation - very useful for documentation that is necessary but that is not really appropriate to include with your source code (for example, an FAQ)

So I would recommend having a mainpage.dox (or similarly named) file in your project directory to introduce you SDK. Note that inside this file you need to put one or more C/C++ style comment blocks.

1
  • 11
    At least markdown files (.md and .markdown) are considered as additional documentation files as well. I prefer them over .dox because they don't need surrounding code comments and can be nicely edited with a markdown editor - without drawbacks.
    – Pascal
    Dec 13, 2017 at 8:44
86

As of v1.8.8 there is also the option USE_MDFILE_AS_MAINPAGE. So make sure to add your index file, e.g. README.md, to INPUT and set it as this option's value:

INPUT += README.md
USE_MDFILE_AS_MAINPAGE = README.md
9
  • 6
    In addition to this, if you're going to use README.md as the main page, make sure it comes first in the INPUT list. When there are multiple mainpage candidates, the first encountered while parsing is selected, or so it seems. Sep 3, 2015 at 19:09
  • 3
    By the way, in doxygen gui you only have to include your .md file under expert > input > input. Mar 6, 2016 at 3:59
  • 1
    USE_MDFILE_AS_MAINPAGE did not work for me. According to the documentation, you have to include {#mainpage} after the title of the markdown document. This did work.
    – samvv
    May 20, 2016 at 11:41
  • 2
    @samvv I did not add any extra to the markdown document. I just used the INPUT = README.md then INPUT += src (to follow @Lester's suggestion) and the USE_MDFILE_AS_MAINPAGE = README.md and it worked like a charm. Version: $ doxygen --version returns 1.8.11 to me. Jul 10, 2016 at 11:17
  • 1
    In Doxygen 1.8.2, the only thing that did work is adding \mainpage inside (can do that in a comment (see this link about comments in MarkDown). This still created Related Pages area, with a placeholder (empty). That's annoying, but at least I got the main page
    – Evgen
    Dec 12, 2016 at 7:46
59

Note that with Doxygen release 1.8.0 you can also add Markdown formated pages. For this to work you need to create pages with a .md or .markdown extension, and add the following to the config file:

INPUT += your_page.md
FILE_PATTERNS += *.md *.markdown

See http://www.doxygen.nl/manual/markdown.html#md_page_header for details.

3
  • 7
    Actually the current 1.8.0 version support markdown BUT doesn't treat them as documentation. So you'll end up with markdown classes listed in Files and Directories section. Solution is to add dox=md as an EXTENSION_MAPPING and rename your markdown extensions to .dox.So the config will look like: INPUT += your_page.dox EXTENSION_MAPPING += dox=md
    – antitoxic
    Mar 14, 2012 at 9:37
  • 6
    Good point. I'll correct this such that .md and .markdown are treated similar to .dox.
    – doxygen
    Mar 17, 2012 at 23:25
  • 4
    Unfortunately, this ends up under Related Pages, not as the main page
    – Evgen
    Dec 12, 2016 at 2:09
8

Following syntax may help for adding a main page and related subpages for doxygen:

/*! \mainpage Drawing Shapes
 *
 * This project helps user to draw shapes.
 * Currently two types of shapes can be drawn:
 * - \subpage drawingRectanglePage "How to draw rectangle?"
 *
 * - \subpage drawingCirclePage "How to draw circle?"
 *
 */ 

/*! \page drawingRectanglePage How to draw rectangle?
 *
 * Lorem ipsum dolor sit amet
 *
 */

/*! \page drawingCirclePage How to draw circle?
 *
 * This page is about how to draw a circle.
 * Following sections describe circle:
 * - \ref groupCircleDefinition "Definition of Circle"
 * - \ref groupCircleClass "Circle Class"
 */

Creating groups as following also help for designing pages:

/** \defgroup groupCircleDefinition Circle Definition
 * A circle is a simple shape in Euclidean geometry.
 * It is the set of all points in a plane that are at a given distance from a given point, the centre;
 * equivalently it is the curve traced out by a point that moves so that its distance from a given point is constant.
 * The distance between any of the points and the centre is called the radius.
 */

An example can be found here

2
  • @FelixSFD thank you for your feedback. I updated my answer according to your answer.
    – Birol Capa
    Feb 13, 2017 at 14:31
  • Correct, adding it to the input does not do it, it has to be formatted as above (a comment). May 13, 2022 at 6:12
5

Add any file in the documentation which will include your content, for example toc.h:

@ mainpage Manual SDK
<hr/>
@ section pageTOC Content
  -# @ref Description
  -# @ref License
  -# @ref Item
...

And in your Doxyfile:

INPUT = toc.h \

Example (in Russian):

1
  • 1
    The scale-tech links are dead now.
    – Ben Fulton
    Nov 15, 2017 at 21:12
4

I tried all the above with v 1.8.13 to no avail. What worked for me (on macOS) was to use the doxywizard->Expert tag to fill the USE_MD_FILE_AS_MAINPAGE setting.

It made the following changes to my Doxyfile:

USE_MDFILE_AS_MAINPAGE = ../README.md
...
INPUT                  = ../README.md \
                         ../sdk/include \
                         ../sdk/src

Note the line termination for INPUT, I had just been using space as a separator as specified in the documentation. AFAICT this is the only change between the not-working and working version of the Doxyfile.

2
  • 1
    clarification - doxywizard is the GUI front end that installs on macOS. Nov 27, 2017 at 20:53
  • I had to add \mainpage to get README.md to be recognized as the mainpage
    – JBaczuk
    Feb 2, 2018 at 1:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.