From 87f10e140e494ce8ebd41edfce6d8d400e92989c Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 4 Jul 2019 10:49:24 +1000 Subject: [PATCH] Fix generation of enum class Pydocs --- .../auto_additions/qgsprovidermetadata.py | 8 ++++++++ .../auto_additions/qgsstyleentityvisitor.py | 14 +++++++++++++- scripts/sipify.pl | 19 ++++++++++--------- src/core/symbology/qgsstyleentityvisitor.h | 2 +- 4 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 python/core/auto_additions/qgsprovidermetadata.py diff --git a/python/core/auto_additions/qgsprovidermetadata.py b/python/core/auto_additions/qgsprovidermetadata.py new file mode 100644 index 00000000000..41f961ffb66 --- /dev/null +++ b/python/core/auto_additions/qgsprovidermetadata.py @@ -0,0 +1,8 @@ +# The following has been generated automatically from src/core/qgsprovidermetadata.h +# monkey patching scoped based enum +QgsProviderMetadata.FilterType.FilterVector.__doc__ = "" +QgsProviderMetadata.FilterType.FilterRaster.__doc__ = "" +QgsProviderMetadata.FilterType.FilterMesh.__doc__ = "" +QgsProviderMetadata.FilterType.FilterMeshDataset.__doc__ = "" +QgsProviderMetadata.FilterType.__doc__ = 'Type of file filters\n\n.. versionadded:: 3.10\n\n' + '* ``FilterVector``: ' + QgsProviderMetadata.FilterType.FilterVector.__doc__ + '\n' + '* ``FilterRaster``: ' + QgsProviderMetadata.FilterType.FilterRaster.__doc__ + '\n' + '* ``FilterMesh``: ' + QgsProviderMetadata.FilterType.FilterMesh.__doc__ + '\n' + '* ``FilterMeshDataset``: ' + QgsProviderMetadata.FilterType.FilterMeshDataset.__doc__ +# -- diff --git a/python/core/auto_additions/qgsstyleentityvisitor.py b/python/core/auto_additions/qgsstyleentityvisitor.py index 4244474c3a0..46f44f7e3c9 100644 --- a/python/core/auto_additions/qgsstyleentityvisitor.py +++ b/python/core/auto_additions/qgsstyleentityvisitor.py @@ -1,4 +1,16 @@ # The following has been generated automatically from src/core/symbology/qgsstyleentityvisitor.h # monkey patching scoped based enum -QgsStyleEntityVisitorInterface.NodeType.__doc__ = 'Describes the types of nodes which may be visited by the visitor.\n\n' + +QgsStyleEntityVisitorInterface.NodeType.Project.__doc__ = "QGIS Project node" +QgsStyleEntityVisitorInterface.NodeType.Layer.__doc__ = "Map layer" +QgsStyleEntityVisitorInterface.NodeType.SymbolRule.__doc__ = "Rule based symbology or label child rule" +QgsStyleEntityVisitorInterface.NodeType.Layouts.__doc__ = "Layout collection" +QgsStyleEntityVisitorInterface.NodeType.PrintLayout.__doc__ = "An individual print layout" +QgsStyleEntityVisitorInterface.NodeType.LayoutItem.__doc__ = "Individual item in a print layout" +QgsStyleEntityVisitorInterface.NodeType.Report.__doc__ = "A QGIS print report" +QgsStyleEntityVisitorInterface.NodeType.ReportHeader.__doc__ = "Report header section" +QgsStyleEntityVisitorInterface.NodeType.ReportFooter.__doc__ = "Report footer section" +QgsStyleEntityVisitorInterface.NodeType.ReportSection.__doc__ = "Report sub section" +QgsStyleEntityVisitorInterface.NodeType.Annotations.__doc__ = "Annotations collection" +QgsStyleEntityVisitorInterface.NodeType.Annotation.__doc__ = "An individual annotation" +QgsStyleEntityVisitorInterface.NodeType.__doc__ = 'Describes the types of nodes which may be visited by the visitor.\n\n' + '* ``Project``: ' + QgsStyleEntityVisitorInterface.NodeType.Project.__doc__ + '\n' + '* ``Layer``: ' + QgsStyleEntityVisitorInterface.NodeType.Layer.__doc__ + '\n' + '* ``SymbolRule``: ' + QgsStyleEntityVisitorInterface.NodeType.SymbolRule.__doc__ + '\n' + '* ``Layouts``: ' + QgsStyleEntityVisitorInterface.NodeType.Layouts.__doc__ + '\n' + '* ``PrintLayout``: ' + QgsStyleEntityVisitorInterface.NodeType.PrintLayout.__doc__ + '\n' + '* ``LayoutItem``: ' + QgsStyleEntityVisitorInterface.NodeType.LayoutItem.__doc__ + '\n' + '* ``Report``: ' + QgsStyleEntityVisitorInterface.NodeType.Report.__doc__ + '\n' + '* ``ReportHeader``: ' + QgsStyleEntityVisitorInterface.NodeType.ReportHeader.__doc__ + '\n' + '* ``ReportFooter``: ' + QgsStyleEntityVisitorInterface.NodeType.ReportFooter.__doc__ + '\n' + '* ``ReportSection``: ' + QgsStyleEntityVisitorInterface.NodeType.ReportSection.__doc__ + '\n' + '* ``Annotations``: ' + QgsStyleEntityVisitorInterface.NodeType.Annotations.__doc__ + '\n' + '* ``Annotation``: ' + QgsStyleEntityVisitorInterface.NodeType.Annotation.__doc__ # -- diff --git a/scripts/sipify.pl b/scripts/sipify.pl index 6c6647b8281..ccf5494adae 100755 --- a/scripts/sipify.pl +++ b/scripts/sipify.pl @@ -990,17 +990,18 @@ while ($LINE_IDX < $LINE_COUNT){ my $enum_member = $+{em}; my $comment = $+{co}; dbg_info("is_scope_based:$is_scope_based enum_mk_base:$enum_mk_base monkeypatch:$monkeypatch"); - if ($is_scope_based eq "1") { - if ( $monkeypatch eq 1 and $enum_member ne "" ){ - if ($enum_mk_base ne "") { - push @OUTPUT_PYTHON, "$enum_mk_base.$enum_member = $enum_qualname.$enum_member\n"; - push @OUTPUT_PYTHON, "$enum_mk_base.$enum_member.__doc__ = \"$comment\"\n" ; - push @enum_members_doc, "'* ``$enum_member``: ' + $enum_qualname.$enum_member.__doc__"; - } else { + if ($is_scope_based eq "1" and $enum_member ne "") { + if ( $monkeypatch eq 1 and $enum_mk_base ne ""){ + push @OUTPUT_PYTHON, "$enum_mk_base.$enum_member = $enum_qualname.$enum_member\n"; + push @OUTPUT_PYTHON, "$enum_mk_base.$enum_member.__doc__ = \"$comment\"\n" ; + push @enum_members_doc, "'* ``$enum_member``: ' + $enum_qualname.$enum_member.__doc__"; + } else { + if ( $monkeypatch eq 1 ) + { push @OUTPUT_PYTHON, "$ACTUAL_CLASS.$enum_member = $ACTUAL_CLASS.$enum_qualname.$enum_member\n"; - push @OUTPUT_PYTHON, "$ACTUAL_CLASS.$enum_qualname.$enum_member.__doc__ = \"$comment\"\n"; - push @enum_members_doc, "'* ``$enum_member``: ' + $ACTUAL_CLASS.$enum_qualname.$enum_member.__doc__"; } + push @OUTPUT_PYTHON, "$ACTUAL_CLASS.$enum_qualname.$enum_member.__doc__ = \"$comment\"\n"; + push @enum_members_doc, "'* ``$enum_member``: ' + $ACTUAL_CLASS.$enum_qualname.$enum_member.__doc__"; } } $enum_decl = fix_annotations($enum_decl); diff --git a/src/core/symbology/qgsstyleentityvisitor.h b/src/core/symbology/qgsstyleentityvisitor.h index 4f8a282a153..a116b0be4f1 100644 --- a/src/core/symbology/qgsstyleentityvisitor.h +++ b/src/core/symbology/qgsstyleentityvisitor.h @@ -38,7 +38,7 @@ class CORE_EXPORT QgsStyleEntityVisitorInterface /** * Describes the types of nodes which may be visited by the visitor. */ - enum class NodeType + enum class NodeType : int { Project, //!< QGIS Project node Layer, //!< Map layer