Skip to content

Commit bfd37e1

Browse files
committed
[sipify] Add return types for functions in docstrings
and change \return -> :return: in docystrings
1 parent 8c5e241 commit bfd37e1

28 files changed

+644
-102
lines changed

python/core/annotations/qgsannotationmanager.sip

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class QgsAnnotationManager : QObject
4444
Returns true if the addition was successful, or false if the annotation could not be added.
4545
\see removeAnnotation()
4646
\see annotationAdded()
47+
:rtype: bool
4748
%End
4849

4950
bool removeAnnotation( QgsAnnotation *annotation );
@@ -55,6 +56,7 @@ class QgsAnnotationManager : QObject
5556
\see compositionRemoved()
5657
\see compositionAboutToBeRemoved()
5758
\see clear()
59+
:rtype: bool
5860
%End
5961

6062
void clear();
@@ -66,19 +68,22 @@ class QgsAnnotationManager : QObject
6668
QList< QgsAnnotation * > annotations() const;
6769
%Docstring
6870
Returns a list of all annotations contained in the manager.
71+
:rtype: list of QgsAnnotation
6972
%End
7073

7174
bool readXml( const QDomElement &element, const QDomDocument &doc );
7275
%Docstring
7376
Reads the manager's state from a DOM element, restoring all annotations
7477
present in the XML document.
7578
\see writeXml()
79+
:rtype: bool
7680
%End
7781

7882
QDomElement writeXml( QDomDocument &doc ) const;
7983
%Docstring
8084
Returns a DOM element representing the state of the manager.
8185
\see readXml()
86+
:rtype: QDomElement
8287
%End
8388

8489
signals:

python/core/annotations/qgshtmlannotation.sip

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class QgsHtmlAnnotation: QgsAnnotation
2828
~QgsHtmlAnnotation();
2929

3030
QSizeF minimumFrameSize() const;
31+
%Docstring
32+
:rtype: QSizeF
33+
%End
3134

3235
void setSourceFile( const QString &htmlFile );
3336
%Docstring
@@ -39,6 +42,7 @@ class QgsHtmlAnnotation: QgsAnnotation
3942
%Docstring
4043
Returns the file path for the source HTML file.
4144
\see setSourceFile()
45+
:rtype: str
4246
%End
4347

4448
virtual void writeXml( QDomElement &elem, QDomDocument &doc ) const;
@@ -49,6 +53,7 @@ class QgsHtmlAnnotation: QgsAnnotation
4953
static QgsHtmlAnnotation *create() /Factory/;
5054
%Docstring
5155
Returns a new QgsHtmlAnnotation object.
56+
:rtype: QgsHtmlAnnotation
5257
%End
5358

5459
protected:

python/core/annotations/qgssvgannotation.sip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ class QgsSvgAnnotation: QgsAnnotation
3939
%Docstring
4040
Returns the file path for the source SVG file.
4141
\see setFilePath()
42+
:rtype: str
4243
%End
4344

4445
static QgsSvgAnnotation *create() /Factory/;
4546
%Docstring
4647
Returns a new QgsSvgAnnotation object.
48+
:rtype: QgsSvgAnnotation
4749
%End
4850

4951
protected:

python/core/annotations/qgstextannotation.sip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class QgsTextAnnotation: QgsAnnotation
3131
Returns the text document which will be rendered
3232
within the annotation.
3333
\see setDocument()
34+
:rtype: QTextDocument
3435
%End
3536

3637
void setDocument( const QTextDocument *doc );
@@ -46,6 +47,7 @@ class QgsTextAnnotation: QgsAnnotation
4647
static QgsTextAnnotation *create() /Factory/;
4748
%Docstring
4849
Returns a new QgsTextAnnotation object.
50+
:rtype: QgsTextAnnotation
4951
%End
5052

5153
protected:

python/core/processing/qgsprocessingalgorithm.sip

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class QgsProcessingAlgorithm
4949
\see displayName()
5050
\see group()
5151
\see tags()
52+
:rtype: str
5253
%End
5354

5455
QString id() const;
@@ -57,48 +58,56 @@ class QgsProcessingAlgorithm
5758
provider's ID and the algorithms unique name (e.g. "qgis:mergelayers" ).
5859
\see name()
5960
\see provider()
61+
:rtype: str
6062
%End
6163

6264
virtual QString displayName() const = 0;
6365
%Docstring
6466
Returns the translated algorithm name, which should be used for any user-visible display
6567
of the algorithm name.
6668
\see name()
69+
:rtype: str
6770
%End
6871

6972
virtual QStringList tags() const;
7073
%Docstring
7174
Returns a list of tags which relate to the algorithm, and are used to assist users in searching
7275
for suitable algorithms. These tags should be localised.
76+
:rtype: list of str
7377
%End
7478

7579
virtual QIcon icon() const;
7680
%Docstring
7781
Returns an icon for the algorithm.
7882
\see svgIconPath()
83+
:rtype: QIcon
7984
%End
8085

8186
virtual QString svgIconPath() const;
8287
%Docstring
8388
Returns a path to an SVG version of the algorithm's icon.
8489
\see icon()
90+
:rtype: str
8591
%End
8692

8793
virtual QString group() const;
8894
%Docstring
8995
Returns the name of the group this algorithm belongs to. This string
9096
should be localised.
9197
\see tags()
98+
:rtype: str
9299
%End
93100

94101
virtual Flags flags() const;
95102
%Docstring
96103
Returns the flags indicating how and when the algorithm operates and should be exposed to users.
104+
:rtype: Flags
97105
%End
98106

99107
QgsProcessingProvider *provider() const;
100108
%Docstring
101109
Returns the provider to which this algorithm belongs.
110+
:rtype: QgsProcessingProvider
102111
%End
103112

104113
private:

python/core/processing/qgsprocessingprovider.sip

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ class QgsProcessingProvider : QObject
3636
%Docstring
3737
Returns an icon for the provider.
3838
\see svgIconPath()
39+
:rtype: QIcon
3940
%End
4041

4142
virtual QString svgIconPath() const;
4243
%Docstring
4344
Returns a path to an SVG version of the provider's icon.
4445
\see icon()
46+
:rtype: str
4547
%End
4648

4749
virtual QString id() const = 0;
@@ -50,32 +52,37 @@ class QgsProcessingProvider : QObject
5052
should be a unique, short, character only string, eg "qgis" or "gdal". This
5153
string should not be localised.
5254
\see name()
55+
:rtype: str
5356
%End
5457

5558
virtual QString name() const = 0;
5659
%Docstring
5760
Returns the full provider name, which is used to describe the provider within the GUI.
5861
This string should be localised.
5962
\see id()
63+
:rtype: str
6064
%End
6165

6266
virtual bool canBeActivated() const;
6367
%Docstring
6468
Returns true if the provider can be activated, or false if it cannot be activated (e.g. due to
6569
missing external dependencies).
6670
\see isActive()
71+
:rtype: bool
6772
%End
6873

6974
virtual bool isActive() const;
7075
%Docstring
7176
Returns true if the provider is active and able to run algorithms.
77+
:rtype: bool
7278
%End
7379

7480
virtual QStringList supportedOutputRasterLayerExtensions() const;
7581
%Docstring
7682
Returns a list of the raster format file extensions supported by this provider.
7783
\see supportedOutputVectorLayerExtensions()
7884
\see supportedOutputTableExtensions()
85+
:rtype: list of str
7986
%End
8087

8188
virtual QStringList supportedOutputVectorLayerExtensions() const;
@@ -84,20 +91,23 @@ class QgsProcessingProvider : QObject
8491
\see supportedOutputRasterLayerExtensions()
8592
\see supportedOutputTableExtensions()
8693
\see supportsNonFileBasedOutput()
94+
:rtype: list of str
8795
%End
8896

8997
virtual QStringList supportedOutputTableExtensions() const;
9098
%Docstring
9199
Returns a list of the table format file extensions supported by this provider.
92100
\see supportedOutputRasterLayerExtensions()
93101
\see supportedOutputVectorLayerExtensions()
102+
:rtype: list of str
94103
%End
95104

96105
virtual bool supportsNonFileBasedOutput() const;
97106
%Docstring
98107
Returns true if the provider supports non-file based outputs (such as memory layers
99108
or direct database outputs).
100109
\see supportedOutputVectorLayerExtensions()
110+
:rtype: bool
101111
%End
102112

103113
virtual bool load();
@@ -107,8 +117,9 @@ class QgsProcessingProvider : QObject
107117
Subclasses should not individually load any algorithms in their load() implementations, as that must
108118
occur within the loadAlgorithms() method. Instead, subclasses should call refreshAlgorithms()
109119
from any overloaded load() method to trigger an initial load of the provider's algorithms.
110-
\returns true if provider could be successfully loaded
120+
:return: true if provider could be successfully loaded
111121
\see unload()
122+
:rtype: bool
112123
%End
113124

114125
virtual void unload();
@@ -126,13 +137,15 @@ class QgsProcessingProvider : QObject
126137
%Docstring
127138
Returns a list of algorithms supplied by this provider.
128139
\see algorithm()
140+
:rtype: list of const QgsProcessingAlgorithm
129141
%End
130142

131143
const QgsProcessingAlgorithm *algorithm( const QString &name ) const;
132144
%Docstring
133145
Returns the matching algorithm by name, or a None if no matching
134146
algorithm is contained by this provider.
135147
\see algorithms()
148+
:rtype: QgsProcessingAlgorithm
136149
%End
137150

138151
signals:
@@ -155,6 +168,7 @@ class QgsProcessingProvider : QObject
155168
bool addAlgorithm( QgsProcessingAlgorithm *algorithm /Transfer/ );
156169
%Docstring
157170
Adds an algorithm to the provider. Ownership of the algorithm is transferred to the provider.
171+
:rtype: bool
158172
%End
159173

160174
private:

python/core/processing/qgsprocessingregistry.sip

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class QgsProcessingRegistry : QObject
3737
QList<QgsProcessingProvider *> providers() const;
3838
%Docstring
3939
Get list of available providers.
40+
:rtype: list of QgsProcessingProvider
4041
%End
4142

4243
bool addProvider( QgsProcessingProvider *provider /Transfer/ );
@@ -48,38 +49,44 @@ class QgsProcessingRegistry : QObject
4849
Adding a provider to the registry automatically triggers the providers QgsProcessingProvider.load()
4950
method to populate the provider with algorithms.
5051
\see removeProvider()
52+
:rtype: bool
5153
%End
5254

5355
bool removeProvider( QgsProcessingProvider *provider );
5456
%Docstring
5557
Removes a provider implementation from the registry (the provider object is deleted).
5658
Returns false if the provider could not be removed (eg provider does not exist in the registry).
5759
\see addProvider()
60+
:rtype: bool
5861
%End
5962

6063
bool removeProvider( const QString &providerId );
6164
%Docstring
6265
Removes a provider implementation from the registry (the provider object is deleted).
6366
Returns false if the provider could not be removed (eg provider does not exist in the registry).
6467
\see addProvider()
68+
:rtype: bool
6569
%End
6670

6771
QgsProcessingProvider *providerById( const QString &id );
6872
%Docstring
6973
Returns a matching provider by provider ID.
74+
:rtype: QgsProcessingProvider
7075
%End
7176

7277
QList< const QgsProcessingAlgorithm *> algorithms() const;
7378
%Docstring
7479
Returns a list of all available algorithms from registered providers.
7580
\see algorithmById()
81+
:rtype: list of const QgsProcessingAlgorithm
7682
%End
7783

7884
const QgsProcessingAlgorithm *algorithmById( const QString &id ) const;
7985
%Docstring
8086
Finds an algorithm by its ID. If no matching algorithm is found, a None
8187
is returned.
8288
\see algorithms()
89+
:rtype: QgsProcessingAlgorithm
8390
%End
8491

8592
signals:

python/core/processing/qgsprocessingutils.sip

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class QgsProcessingUtils
3333
value.
3434
\see compatibleVectorLayers()
3535
\see compatibleLayers()
36+
:rtype: list of QgsRasterLayer
3637
%End
3738

3839
static QList< QgsVectorLayer * > compatibleVectorLayers( QgsProject *project,
@@ -50,6 +51,7 @@ class QgsProcessingUtils
5051
value.
5152
\see compatibleRasterLayers()
5253
\see compatibleLayers()
54+
:rtype: list of QgsVectorLayer
5355
%End
5456

5557
static QList< QgsMapLayer * > compatibleLayers( QgsProject *project, bool sort = true );
@@ -61,6 +63,7 @@ class QgsProcessingUtils
6163
value.
6264
\see compatibleRasterLayers()
6365
\see compatibleVectorLayers()
66+
:rtype: list of QgsMapLayer
6467
%End
6568

6669

@@ -74,6 +77,7 @@ class QgsProcessingUtils
7477
for layers in the specified project, then those matching layers will be
7578
returned.
7679
\see mapLayerFromString()
80+
:rtype: QgsMapLayer
7781
%End
7882

7983
static QgsMapLayer *mapLayerFromString( const QString &string ) /Factory/;
@@ -83,12 +87,14 @@ class QgsProcessingUtils
8387
then the layer at this file path will be loaded.
8488
The caller takes responsibility for deleting the returned map layer.
8589
\see mapLayerFromProject()
90+
:rtype: QgsMapLayer
8691
%End
8792

8893
static QString normalizeLayerSource( const QString &source );
8994
%Docstring
9095
Normalizes a layer source string for safe comparison across different
9196
operating system environments.
97+
:rtype: str
9298
%End
9399

94100
};

0 commit comments

Comments
 (0)