diff options
author | Juergen Bocklage-Ryannel <juergen.bocklage-ryannel@pelagicore.com> | 2017-02-06 11:36:38 +0100 |
---|---|---|
committer | Juergen Bocklage-Ryannel <juergen.bocklage-ryannel@pelagicore.com> | 2017-02-06 11:36:38 +0100 |
commit | dec3046824904714b896cc0da4f38a6a2e727343 (patch) | |
tree | 02b53c6bf73b1bc611ec9a63613af1f69875989e | |
parent | a350707baa3c2da1f93c230c5132ca73dc9f6d44 (diff) | |
download | qtivi-qface-dec3046824904714b896cc0da4f38a6a2e727343.tar.gz |
WIP: qdoc templates for qtcpp generator
-rwxr-xr-x | qface/builtin/qtcpp/qtcpp.py | 4 | ||||
-rw-r--r-- | qface/builtin/qtcpp/templates/abstractinterface.cpp | 27 | ||||
-rw-r--r-- | qface/builtin/qtcpp/templates/docs.pri | 32 | ||||
-rw-r--r-- | qface/builtin/qtcpp/templates/generated.pri | 8 | ||||
-rw-r--r-- | qface/builtin/qtcpp/templates/module.cpp | 24 | ||||
-rw-r--r-- | qface/builtin/qtcpp/templates/plugin-online.qdocconf | 19 | ||||
-rw-r--r-- | qface/builtin/qtcpp/templates/plugin-project.qdocconf | 27 | ||||
-rw-r--r-- | qface/builtin/qtcpp/templates/plugin.pro | 1 | ||||
-rw-r--r-- | qface/builtin/qtcpp/templates/plugin.qdocconf | 21 | ||||
-rw-r--r-- | qface/builtin/qtcpp/templates/qmake.conf | 5 | ||||
-rw-r--r-- | qface/builtin/qtcpp/templates/struct.cpp | 11 | ||||
-rw-r--r-- | qface/helper/doc.py | 3 |
12 files changed, 176 insertions, 6 deletions
diff --git a/qface/builtin/qtcpp/qtcpp.py b/qface/builtin/qtcpp/qtcpp.py index ed2d1f4..630e64a 100755 --- a/qface/builtin/qtcpp/qtcpp.py +++ b/qface/builtin/qtcpp/qtcpp.py @@ -43,6 +43,10 @@ def run(src, dst): generator.write('generated/qml{{module.module_name|lower}}module.cpp', 'module.cpp', ctx) generator.write('generated/qmlvariantmodel.h', 'variantmodel.h', ctx) generator.write('generated/qmlvariantmodel.cpp', 'variantmodel.cpp', ctx) + generator.write('docs/plugin.qdocconf', 'plugin.qdocconf', ctx) + generator.write('docs/plugin-project.qdocconf', 'plugin-project.qdocconf', ctx) + generator.write('docs/docs.pri', 'docs.pri', ctx) + generator.write('.qmake.conf', 'qmake.conf', ctx) for interface in module.interfaces: log.debug('generate code for interface %s', interface) ctx.update({'interface': interface}) diff --git a/qface/builtin/qtcpp/templates/abstractinterface.cpp b/qface/builtin/qtcpp/templates/abstractinterface.cpp index 811a1a0..3a70cb6 100644 --- a/qface/builtin/qtcpp/templates/abstractinterface.cpp +++ b/qface/builtin/qtcpp/templates/abstractinterface.cpp @@ -9,7 +9,15 @@ #include <QtQml> -{{interface.comment}} +/*! + \qmltype {{interface}} + \inqmlmodule {{module}} +{% with doc = interface.comment|parse_doc %} + \brief {{doc.brief}} + + {{doc.description}} +{% endwith %} +*/ {{class}}::{{class}}(QObject *parent) : QObject(parent) {% for property in interface.properties %} @@ -24,6 +32,15 @@ } {% for property in interface.properties %} +/*! + \qmlproperty {{property.type}} {{interface}}::{{property}} +{% with doc = property.comment|parse_doc %} + \brief {{doc.brief}} + + {{doc.description}} +{% endwith %} +*/ + void {{class}}::set{{property|upperfirst}}({{ property|parameterType }}) { if(m_{{property}} == {{property}}) { @@ -40,6 +57,13 @@ void {{class}}::set{{property|upperfirst}}({{ property|parameterType }}) {% endfor %} {%- for operation in interface.operations %} +/*! + \qmlmethod {{operation.type}} {{interface}}::{{operation}}({{operation.parameters|map('parameterType')|join(', ')}}) +{% with doc = operation.comment|parse_doc %} + \brief {{doc.brief}} + {{doc.description}} +{% endwith %} +*/ {{operation|returnType}} {{class}}::{{operation}}({{operation.parameters|map('parameterType')|join(', ')}}) { {% for parameter in operation.parameters %} @@ -50,3 +74,4 @@ void {{class}}::set{{property|upperfirst}}({{ property|parameterType }}) } {% endfor %} + diff --git a/qface/builtin/qtcpp/templates/docs.pri b/qface/builtin/qtcpp/templates/docs.pri new file mode 100644 index 0000000..f6a3e81 --- /dev/null +++ b/qface/builtin/qtcpp/templates/docs.pri @@ -0,0 +1,32 @@ +exists($$[QT_INSTALL_BINS]/qdoc):exists($$[QT_INSTALL_BINS]/qhelpgenerator) { + check_qdoc = "qdoc/qhelpgenerator in $$[QT_INSTALL_BINS]" + QDOC = $$[QT_INSTALL_BINS]/qdoc + QHELPGENERATOR = $$[QT_INSTALL_BINS]/qhelpgenerator +} else { + check_qdoc = "qdoc/qhelpgenerator in PATH" + QDOC = qdoc + QHELPGENERATOR = qhelpgenerator +} + +defineReplace(cmdEnv) { + !equals(QMAKE_DIR_SEP, /): 1 ~= s,^(.*)$,(set \\1) &&,g + return("$$1") +} + +defineReplace(qdoc) { + return("$$cmdEnv(OUTDIR=$$1 QMLLIVE_VERSION=$$VERSION QMLLIVE_VERSION_TAG=$$VERSION_TAG QT_INSTALL_DOCS=$$[QT_INSTALL_DOCS/src]) $$QDOC") +} + +html-docs.commands = $$qdoc($$BUILD_DIR/doc/html) $$PWD/plugin.qdocconf +html-docs.files = $$BUILD_DIR/doc/html + +docs.depends = html-docs + +QMAKE_EXTRA_TARGETS += html-docs docs + + +OTHER_FILES += \ + $$PWD/*.qdocconf \ + $$PWD/*.qdoc \ + $$PWD/examples/*.qdoc \ + $$PWD/images/*.png diff --git a/qface/builtin/qtcpp/templates/generated.pri b/qface/builtin/qtcpp/templates/generated.pri index 4baac95..7457474 100644 --- a/qface/builtin/qtcpp/templates/generated.pri +++ b/qface/builtin/qtcpp/templates/generated.pri @@ -12,11 +12,11 @@ HEADERS += \ {% for interface in module.interfaces %} $$PWD/qmlabstract{{interface|lower}}.h \ {% endfor %} - $$PWD/qmlvariantmodel.h \ {% for struct in module.structs %} $$PWD/qml{{struct|lower}}.h \ - $$PWD/qml{{struct|lower}}model.h {% if not loop.last %}\{% endif %} + $$PWD/qml{{struct|lower}}model.h \ {% endfor %} + $$PWD/qmlvariantmodel.h SOURCES += \ @@ -24,10 +24,10 @@ SOURCES += \ {% for interface in module.interfaces %} $$PWD/qmlabstract{{interface|lower}}.cpp \ {% endfor %} - $$PWD/qmlvariantmodel.cpp \ {% for struct in module.structs %} $$PWD/qml{{struct|lower}}.cpp \ - $$PWD/qml{{struct|lower}}model.cpp {% if not loop.last %}\{% endif %} + $$PWD/qml{{struct|lower}}model.cpp \ {% endfor %} + $$PWD/qmlvariantmodel.cpp diff --git a/qface/builtin/qtcpp/templates/module.cpp b/qface/builtin/qtcpp/templates/module.cpp index c145320..1289471 100644 --- a/qface/builtin/qtcpp/templates/module.cpp +++ b/qface/builtin/qtcpp/templates/module.cpp @@ -10,6 +10,26 @@ #include <QtQml> +/*! + \qmlmodule {{module}} 1.0 +{% with doc = module.comment|parse_doc %} + + {{doc.brief}} + + + {{doc.description}} +{% endwith %} + */ + + +/*! + \qmltype {{module.module_name}}Module + \inqmlmodule {{module}} + \brief API to access module functionality + + Provides the enumerations and data type factories for + this module. +*/ QObject* {{class|lower}}_singletontype_provider(QQmlEngine*, QJSEngine*) { return new {{class}}(); @@ -21,6 +41,10 @@ QObject* {{class|lower}}_singletontype_provider(QQmlEngine*, QJSEngine*) } {% for struct in module.structs %} +/*! + \qmlmethod {{struct}} {{module.module_name}}Module::create{{struct}}() + \brief Creates a default constructed data object from type {{struct}} +*/ Qml{{struct}} {{class}}::create{{struct}}() { return Qml{{struct}}(); diff --git a/qface/builtin/qtcpp/templates/plugin-online.qdocconf b/qface/builtin/qtcpp/templates/plugin-online.qdocconf new file mode 100644 index 0000000..771cdae --- /dev/null +++ b/qface/builtin/qtcpp/templates/plugin-online.qdocconf @@ -0,0 +1,19 @@ +HTML.footer = \ + " </div>\n" \ + " <p class=\"copy-notice\">\n" \ + " <acronym title=\"Copyright\">©</acronym> 2016 Pelagicore AG.\n" \ + " Documentation contributions included herein are the copyrights of\n" \ + " their respective owners. " \ + " The documentation provided herein is licensed under the terms of the" \ + " <a href=\"http://www.gnu.org/licenses/fdl.html\">GNU Free Documentation" \ + " License version 1.3</a> as published by the Free Software Foundation. " \ + " Qt and respective logos are trademarks of The Qt Company Ltd. " \ + " in Finland and/or other countries worldwide. All other trademarks are property\n" \ + " of their respective owners. </p>\n" + +include($QT_INSTALL_DOCS/global/qt-html-templates-online.qdocconf) + +# Add an .html file with sidebar content, used in the online style +# HTML.stylesheets += style/qt5-sidebar.html + +include(plugin-project.qdocconf) diff --git a/qface/builtin/qtcpp/templates/plugin-project.qdocconf b/qface/builtin/qtcpp/templates/plugin-project.qdocconf new file mode 100644 index 0000000..0a846cb --- /dev/null +++ b/qface/builtin/qtcpp/templates/plugin-project.qdocconf @@ -0,0 +1,27 @@ +{% set module_name = module|lower|replace(".", "_")%} +project = {{module}} +description = {{module|upper}} Reference Documentation +version = 1.0 + +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" + +outputdir = html + +exampledirs = ../examples ../src + +headerdirs = \ + .. \ + ../generated + +sourcedirs = \ + .. \ + ../generated + +imagedirs = images + +navigation.landingpage = "{{module}}" +buildversion = "{{module_name}} 1.0" diff --git a/qface/builtin/qtcpp/templates/plugin.pro b/qface/builtin/qtcpp/templates/plugin.pro index 6a241ec..4984015 100644 --- a/qface/builtin/qtcpp/templates/plugin.pro +++ b/qface/builtin/qtcpp/templates/plugin.pro @@ -26,6 +26,7 @@ SOURCES += \ include( generated/generated.pri ) +include( docs/docs.pri ) DISTFILES = qmldir diff --git a/qface/builtin/qtcpp/templates/plugin.qdocconf b/qface/builtin/qtcpp/templates/plugin.qdocconf new file mode 100644 index 0000000..a45a34b --- /dev/null +++ b/qface/builtin/qtcpp/templates/plugin.qdocconf @@ -0,0 +1,21 @@ +include($QT_INSTALL_DOCS/global/qt-html-templates-offline.qdocconf) +include(plugin-project.qdocconf) + +HTML.footer = \ + " </div>\n" \ + " </div>\n" \ + " </div>\n" \ + " </div>\n" \ + "</div>\n" \ + "<div class=\"footer\">\n" \ + " <p>\n" \ + " <acronym title=\"Copyright\">©</acronym> 2016 Pelagicore AG.\n" \ + " Documentation contributions included herein are the copyrights of\n" \ + " their respective owners.<br>" \ + " The documentation provided herein is licensed under the terms of the" \ + " <a href=\"http://www.gnu.org/licenses/fdl.html\">GNU Free Documentation" \ + " License version 1.3</a> as published by the Free Software Foundation.<br>" \ + " Qt and respective logos are trademarks of The Qt Company Ltd. " \ + " in Finland and/or other countries worldwide. All other trademarks are property\n" \ + " of their respective owners. </p>\n" \ + "</div>\n" diff --git a/qface/builtin/qtcpp/templates/qmake.conf b/qface/builtin/qtcpp/templates/qmake.conf new file mode 100644 index 0000000..03d3435 --- /dev/null +++ b/qface/builtin/qtcpp/templates/qmake.conf @@ -0,0 +1,5 @@ +SOURCE_DIR=$$PWD +BUILD_DIR=$$shadowed($$PWD) +QMAKEFEATURES=$$SOURCE_DIR/qmake-features + +VERSION = 1.0.0 diff --git a/qface/builtin/qtcpp/templates/struct.cpp b/qface/builtin/qtcpp/templates/struct.cpp index 70dd967..9d3da67 100644 --- a/qface/builtin/qtcpp/templates/struct.cpp +++ b/qface/builtin/qtcpp/templates/struct.cpp @@ -37,7 +37,16 @@ public: }; // Class -{{struct.comment}} + +/*! + \qmltype {{struct}} + \inqmlmodule {{module}} +{% with doc = struct.comment|parse_doc %} + \brief {{doc.brief}} + + {{doc.description}} +{% endwith %} +*/ {{class}}::{{class}}() : d(new {{class}}Data) diff --git a/qface/helper/doc.py b/qface/helper/doc.py index d8f05cf..eff0852 100644 --- a/qface/helper/doc.py +++ b/qface/helper/doc.py @@ -7,6 +7,9 @@ class DocObject(object): def parse_doc(s): o = DocObject() + print('parse_doc:', s) + if not s: + return tag = None for line in s.splitlines(): if re.match(r'\/\*\*', line): |