From 38121bf0530fb75a56dffef64a9f9f730a54e19f Mon Sep 17 00:00:00 2001 From: Christian Fetzer Date: Tue, 30 Oct 2018 14:56:03 +0100 Subject: [PATCH 1/2] Add support for QtSignals This change adds proper support for QtSignals by treating signals as functions (similar to what has been done for QtSlots). In addition change the example for QtSlots to QtSignalsAndSlots so that both signals and slots are properly documented and validated. Without this change breathe emits the following warnings for classes that contain signals: WARNING: Error in declarator or parameters and qualifiers If pointer to member declarator: Invalid definition: Expected identifier in nested name. [error at 34] QtSignalSlotExample::workingSignal ----------------------------------^ --- breathe/renderer/sphinxrenderer.py | 5 +++-- documentation/source/class.rst | 18 +++++++++--------- documentation/source/conf.py | 2 +- examples/specific/Makefile | 2 +- .../{qtslots.cfg => qtsignalsandslots.cfg} | 6 +++--- .../{qtslots.h => qtsignalsandslots.h} | 10 +++++++++- 6 files changed, 26 insertions(+), 17 deletions(-) rename examples/specific/{qtslots.cfg => qtsignalsandslots.cfg} (59%) rename examples/specific/{qtslots.h => qtsignalsandslots.h} (70%) diff --git a/breathe/renderer/sphinxrenderer.py b/breathe/renderer/sphinxrenderer.py index ec6a1568..ac1bdd40 100644 --- a/breathe/renderer/sphinxrenderer.py +++ b/breathe/renderer/sphinxrenderer.py @@ -72,6 +72,7 @@ class DomainDirectiveFactory(object): 'interface': (DoxyCPPClassObject, 'interface'), 'function': (cpp.CPPFunctionObject, 'function'), 'friend': (cpp.CPPFunctionObject, 'function'), + 'signal': (cpp.CPPFunctionObject, 'function'), 'slot': (cpp.CPPFunctionObject, 'function'), 'enum': (cpp.CPPTypeObject, 'type'), 'typedef': (cpp.CPPTypeObject, 'type'), @@ -547,7 +548,7 @@ def render_signature(file_data, doxygen_target, name, kind): ("public-func", "Public Functions"), ("public-attrib", "Public Members"), ("public-slot", "Public Slots"), - ("signal", "Signal"), + ("signal", "Signals"), ("dcop-func", "DCOP Function"), ("property", "Property"), ("event", "Event"), @@ -1236,7 +1237,7 @@ def dispatch_compound(self, node): def dispatch_memberdef(self, node): """Dispatch handling of a memberdef node to a suitable visit method.""" - if node.kind in ("function", "slot") or \ + if node.kind in ("function", "signal", "slot") or \ (node.kind == 'friend' and node.argsstring): return self.visit_function(node) if node.kind == "enum": diff --git a/documentation/source/class.rst b/documentation/source/class.rst index 962920f4..8c5f28e2 100644 --- a/documentation/source/class.rst +++ b/documentation/source/class.rst @@ -221,23 +221,23 @@ It produces this output: :no-link: -Qt Slots Example ----------------- +Qt Signals & Slots Example +-------------------------- -Doxygen is aware of Qt Slots and so Breathe can pick them up and display them in -the output. They are displayed in appropriate ``Public Slots``, ``Protected -Slots`` and ``Private Slots`` sections. +Doxygen is aware of Qt Signals and Slots and so Breathe can pick them up and +display them in the output. They are displayed in appropriate ``Signals``, +``Public Slots``, ``Protected Slots`` and ``Private Slots`` sections. .. code-block:: rst - .. doxygenclass:: QtSlotExample - :project: qtslots + .. doxygenclass:: QtSignalSlotExample + :project: qtsignalsandslots :members: Produces the following output: -.. doxygenclass:: QtSlotExample - :project: qtslots +.. doxygenclass:: QtSignalSlotExample + :project: qtsignalsandslots :members: :no-link: diff --git a/documentation/source/conf.py b/documentation/source/conf.py index 23700258..5963fc9c 100644 --- a/documentation/source/conf.py +++ b/documentation/source/conf.py @@ -206,7 +206,7 @@ "lists":"../../examples/specific/lists/xml/", "group":"../../examples/specific/group/xml/", "union":"../../examples/specific/union/xml/", - "qtslots":"../../examples/specific/qtslots/xml/", + "qtsignalsandslots":"../../examples/specific/qtsignalsandslots/xml/", "array":"../../examples/specific/array/xml/", "c_enum":"../../examples/specific/c_enum/xml/", "c_typedef":"../../examples/specific/c_typedef/xml/", diff --git a/examples/specific/Makefile b/examples/specific/Makefile index fb6773cd..19c2981d 100644 --- a/examples/specific/Makefile +++ b/examples/specific/Makefile @@ -20,7 +20,7 @@ HAVE_DOT = /usr/bin/dot projects = nutshell alias rst inline namespacefile c_file array c_enum inheritance \ members userdefined fixedwidthfont latexmath functionOverload \ - image name union group struct struct_function qtslots lists \ + image name union group struct struct_function qtsignalsandslots lists \ headings links parameters template_class template_class_non_type \ template_function template_specialisation enum c_typedef define interface diff --git a/examples/specific/qtslots.cfg b/examples/specific/qtsignalsandslots.cfg similarity index 59% rename from examples/specific/qtslots.cfg rename to examples/specific/qtsignalsandslots.cfg index 83aa171f..464dace2 100644 --- a/examples/specific/qtslots.cfg +++ b/examples/specific/qtsignalsandslots.cfg @@ -1,10 +1,10 @@ -PROJECT_NAME = "Qt Slots" -OUTPUT_DIRECTORY = qtslots +PROJECT_NAME = "Qt Signals & Slots" +OUTPUT_DIRECTORY = qtsignalsandslots GENERATE_LATEX = NO GENERATE_MAN = NO GENERATE_RTF = NO CASE_SENSE_NAMES = NO -INPUT = qtslots.h +INPUT = qtsignalsandslots.h QUIET = YES JAVADOC_AUTOBRIEF = YES GENERATE_HTML = NO diff --git a/examples/specific/qtslots.h b/examples/specific/qtsignalsandslots.h similarity index 70% rename from examples/specific/qtslots.h rename to examples/specific/qtsignalsandslots.h index 9c281634..af750f0e 100644 --- a/examples/specific/qtslots.h +++ b/examples/specific/qtsignalsandslots.h @@ -3,7 +3,7 @@ #include -class QtSlotExample: public QObject +class QtSignalSlotExample: public QObject { Q_OBJECT @@ -15,6 +15,14 @@ class QtSlotExample: public QObject */ void workingFunction( int iShownParameter ) { Q_UNUSED( iShownParameter ; ) } + signals: + + /*! + *\param iShown + This is in function declaration + */ + void workingSignal( int iShown ); + public slots: /*! From c9eba5e20997847b4cfcb46c580488896ba30aa5 Mon Sep 17 00:00:00 2001 From: Christian Fetzer Date: Tue, 30 Oct 2018 16:55:02 +0100 Subject: [PATCH 2/2] Fix Flake8 warning W605 (invalid escape sequence) in sphinxrenderer.py breathe/renderer/sphinxrenderer.py:802:14: W605 invalid escape sequence '\[' breathe/renderer/sphinxrenderer.py:802:14: W605 invalid escape sequence '\]' --- breathe/renderer/sphinxrenderer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/breathe/renderer/sphinxrenderer.py b/breathe/renderer/sphinxrenderer.py index ac1bdd40..e96be965 100644 --- a/breathe/renderer/sphinxrenderer.py +++ b/breathe/renderer/sphinxrenderer.py @@ -799,7 +799,7 @@ def visit_docformula(self, node): rst_node = self.node_factory.displaymath() # Or multiline - if latex.startswith("\[") and latex.endswith("\]"): + if latex.startswith("\\[") and latex.endswith("\\]"): latex = latex[2:-2:] # Here we steal the core of the mathbase "math" directive handling code from: