0

Goal

For documentation purposes I would like to export a C++ code snippet from QtCreator as an HTML file and then use CSS to highlight its syntax, for example like that:

syntax highlighted code

Since QtCreator does not have an export option, I am using QDoc to achieve that.

As per documentation, I use \quotefile in a qdoc-file in my project to turn the source code from main.cpp into an HTML:

/*!
    \page index
    \quotefile main.cpp
 */

Running qdoc produces an index.html and when I open it, there is indeed the marked-up content of main.cpp.

Note: To demonstrate the issue I am using the code from the documentation:

#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QPushButton hello("Hello world!");
    hello.resize(100, 30);

    hello.show();
    return app.exec();
}

Problem

When I inspect the produced html code in the browser, for the hello( part for example, I get:

 hello(

When I inspect the html code of the documentation however, which I believe is generated with the help of QDoc as well, for the same part I see:

<span class="pln"> hello</span>

I do not know why in my case the additional markup is missing.

Question

How to setup QDoc so, that I can specify the rules of how each part of the code snippet should be marked up?

scopchanov
  • 7,966
  • 10
  • 40
  • 68
  • Can you post your working cpp-code? This doesn't look valid cpp to me: QPushButton hello("Hello world!");.resize(100, 30); – Jens Oct 16 '20 at 08:47
  • @Jens _This doesn't look valid cpp to me_ It does not look valid to me as well. As I've mentioned: I use the code from the documentation. This way I can make a side-by-side comparison of the results. It is also irrelevant. Even with `.resize(100, 30);` omitted, the result is still `" hello("`, without the tags. – scopchanov Oct 16 '20 at 08:56
  • @Jens Of course it is a valid cpp. Why it should not be? – scopchanov Nov 07 '21 at 00:59
  • @Jens, take a look at https://doc.qt.io/qt-5.12/07-0-qdoc-commands-includingexternalcode.html#quotefile – scopchanov Nov 07 '21 at 01:04
  • It wasn't until October, 20. – Jens Nov 07 '21 at 09:55
  • @Jens, excuse me, but I really do not know what do you mean by that. I took this code snippet from the documentation and it has been there for years. Take a look for example at https://doc.qt.io/archives/3.3/tutorial1-01.html. This is from the archives for Qt 3.3. – scopchanov Nov 07 '21 at 10:57

0 Answers0