Problem
Since the upgrade from Qt 5.10 to Qt 5.11 I have started having problems to generate a documentation with QDoc for my existing projects.
One of the many issues are missing functions in the documentation, although the corresponding comments exist in the source code.
Research
I have managed to narrow the issue down to the inclusion of the Q_OBJECT
macro, as shown by the provided code example (see below).
This is indeed mentioned in the Qt documentation:
If not specified by the
Cpp.ignoretokens
orCpp.ignoredirectives
variables, non-standard constructs (typically macros) can result in erroneous documentation.
Q_OBJECT
is not supposed to cause problems though, because just a little bit further it is written:
The
Q_OBJECT
macro, however, is an exception: QDoc recognizes this particular non-standard construct, so there is no need specifying it using theCpp.ignoredirectives
variable.
In any case I do include qt-cpp-defines.qdocconf
in my qdocconf
file.
I have also tried to manually add Q_OBJECT
to the ignore list
Cpp.ignoredirectives += Q_OBJECT
but the result is the same.
I experience the described issue under Windows 10 and Ubuntu 17. Under Windows 7 I cannot execute qdoc.exe
at all.
What is the correct configuration of qdocconf
to overcome this issue?
Minimal example
For a quick reproduction (in the real situation the declarations and the implementations are split and proper comments are added), please consider the following setup:
Foo.h
#include <QObject>
class Foo : public QObject
{
// Q_OBJECT // <-- uncomment this to break QDoc
public:
Foo() {}
void boo() {}
protected:
void moo() {}
};
Foo.cpp
#include "Foo.h"
/*!
\class Foo
*/
test.qdocconf
include($QT_INSTALL_DOCS/global/compat.qdocconf)
include($QT_INSTALL_DOCS/global/fileextensions.qdocconf)
include($QT_INSTALL_DOCS/global/qt-cpp-defines.qdocconf)
include($QT_INSTALL_DOCS/global/macros.qdocconf)
# Uncoment this for a test
# Cpp.ignoredirectives += Q_OBJECT
outputdir = html
headerdirs = .
sourcedirs = .
exampledirs = .
imagedirs = ./images
Results
- Good result (without
Q_OBJECT
)
Executing qdoc.exe test.qdocconf
I get more or less the following:
- Foo
Contents
- Public Functions
- Protected Functions
- Detailed Description
Foo Class
- List of all members, including inherited members
Public Functions
Foo()
void boo()
Protected Functions
void moo()
Detailed Description
Member Function Documentation
Foo::Foo()
Default constructs an instance of Foo.
void Foo::boo()
[protected] void Foo::moo()
- Bad result (with
Q_OBJECT
)
Uncommenting the Q_OBJECT
macro and running qdoc.exe
again yelds the following result:
- Foo
Contents
- Detailed Description
Foo Class
Detailed Description
IMPORTANT: Foo
, moo
and boo
are gone.