Creating QDoc Configuration Files

To generate documentation, QDoc uses configuration files, with the qdocconf extension, to store configuration settings.

The The QDoc Configuration File article covers the various configuration variables in greater detail.

QDoc Configuration Files

QDoc's configuration settings can reside in a single qdocconf file, but can also be in other qdocconf files. The include(<filepath>) command allows configuration files to include other configuration files.

QDoc has two outputs, HTML documentation and documentation in DITA XML format. The main distinction between the two outputs is that HTML documentation needs to have its HTML styling information in the configuration files. DITA XML documentation does not, and a separate process can style the documentation in DITA at a later time. DITA XML is therefore more flexible in allowing different styles to apply to the same information.

To run qdoc, the project configuration file is supplied as an argument.

qdoc project.qdocconf

The project configuration contains information that qdoc uses to create the documentation.

Project Information

QDoc uses the project information to generate the documentation.

project = QDoc Project
description = Sample QDoc project

Input and Output Directories

Specifying the path to the source directories allow QDoc to find sources and generate documentation.

sourcedirs = <path to source code>
exampledirs = <path to examples directory>
imagedirs = <path to image directory>

sources.fileextensions = "*.cpp *.qdoc *.mm *.qml"
headers.fileextensions = "*.h *.ch *.h++ *.hh *.hpp *.hxx"
examples.fileextensions = "*.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp *.qml"
examples.imageextensions = "*.png *.jpeg *.jpg *.gif *.mng"

QDoc will process headers and sources from the ones specified in the fileextensions variable.

Likewise, QDoc needs the path to the output directory. The outputformats variable determines the type of documentation. These variables should be in separate configuration files to modularize the documentation build.

outputdir  =    $SAMPLE_PROJECT/doc/html
outputformats = HTML

QDoc can resolve the paths relative to the qdocconf file as well as environment variables.

Note: During each QDoc run, the output directory is deleted.

Extra Files

QDoc will output generated documentation into the directory specified in the output directory. It is also possible to specify extra files that QDoc should export.

HTML.extraimages = extraImage.png \
                   extraImage2.png

The extraImage.png and the extraImage2.png files will be copied to the HTML output directory.

Qt Help Framework Configuration

QDoc will also export a Qt Help Project file, in a qhp file. The qhp file is then used by the qhelpgenerator to package the documentation into a qch file. Qt Creator and Qt Assistant reads the qch file to display the documentation.

The Creating Help Project Files article covers the configuration options.

HTML Configuration

QDoc has an HTML generator that will export a set of documentation into HTML files using various configuration settings. QDoc will place the generated documentation into the directory specified by the outputdir variable.

outputformats = HTML
outputdir =  <path to output directory>

QDoc needs to know where the styles and templates for generating HTML are located. Typically, the templates directory contains a scripts, images, and a style directory, containing scripts and CSS files.

The main configuration variables are:

HTML.postheader
HTML.postpostheader
HTML.postheader
HTML.footer

HTML.headerstyles
HTML.stylesheets = template/style/style.css \
                   template/style/style1.css

HTML.scripts = template/scripts/script.js

The HTML.headerstyles variable inserts the style information into the HTML file and the HTML.stylesheets specifies which files QDoc should copy into the output directory. As well, QDoc will embed the string in the postheader, footer, and related variables into each HTML file.

The Format-specific Configuration Variables article outlines the usage of each variable.

Qt Index Reference

Documentation projects can link to Qt APIs and other articles by specifying the path to the qt.index file. When qdoc generates the Qt Reference Documentation, it will also generate an index file, containing the URLs to the articles. Other projects can use the links in the index file so that they can link to other articles and API documentation within Qt.

indexes = $QT_INSTALL_DOCS/html/qt.index $OTHER_PROJECT/html/qt.index

It is possible to specify multiple index files from several projects.

Macros and Other Configurations

Macros for substituting HTML characters exist and are helpful for generating specific HTML-valid characters.

macro.pi.HTML         = "&Pi;"

The snippet code will replace any instances of \\pi with &Pi; in the HTML file, which will appear as the Greek Π symbol when viewed in browsers.

QML Additions

QDoc is able to parse QML files for QDoc comments. QDoc will parse files with the QML extension, .qml, if the extension type is included in the fileextensions variable.

Also, the generated HTML files can have a prefix and a suffix following the QML module name, specified in the QDoc configuration file.

outputprefixes = QML
outputprefixes.QML = uicomponents-
outputsuffixes = QML
outputsuffixes.QML = -tp

See also: outputprefixes, outputsuffixes.

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.12/qdoc-guide-conf.html