Skip to content

Commit

Permalink
[sipify] Replace nullptr with None in docstrings
Browse files Browse the repository at this point in the history
Since nullptr has no meaning to Python devs
  • Loading branch information
nyalldawson committed Apr 6, 2017
1 parent 5ccc6cc commit ca8e1d3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
6 changes: 3 additions & 3 deletions python/core/qgspropertytransformer.sip
Expand Up @@ -261,7 +261,7 @@ class QgsPropertyTransformer
\param fieldName will be set to a field name which is used to calculate the input
to the property transformer. This will be set to an
empty string if an expression is the transformer input.
\returns corresponding property transformer, or nullptr if expression could not
\returns corresponding property transformer, or None if expression could not
be parsed to a transformer.
%End

Expand Down Expand Up @@ -323,7 +323,7 @@ class QgsGenericNumericTransformer : QgsPropertyTransformer
\param fieldName will be set to a field name which is used to calculate the input
to the property transformer. This will be set to an
empty string if an expression is the transformer input.
\returns corresponding QgsSizeScaleTransformer, or nullptr if expression could not
\returns corresponding QgsSizeScaleTransformer, or None if expression could not
be parsed to a size scale transformer.
%End

Expand Down Expand Up @@ -449,7 +449,7 @@ class QgsSizeScaleTransformer : QgsPropertyTransformer
\param fieldName will be set to a field name which is used to calculate the input
to the property transformer. This will be set to an
empty string if an expression is the transformer input.
\returns corresponding QgsSizeScaleTransformer, or nullptr if expression could not
\returns corresponding QgsSizeScaleTransformer, or None if expression could not
be parsed to a size scale transformer.
%End

Expand Down
2 changes: 1 addition & 1 deletion python/core/raster/qgsrasterfilewriter.sip
Expand Up @@ -48,7 +48,7 @@ class QgsRasterFileWriter
.. note::

Does not work with tiled mode enabled.
\returns Instance of data provider in editing mode (on success) or null on error.
\returns Instance of data provider in editing mode (on success) or None on error.
.. versionadded:: 3.0
%End

Expand Down
3 changes: 3 additions & 0 deletions scripts/sipify.pl
Expand Up @@ -14,6 +14,9 @@ sub processDoxygenLine
$line =~ s/\\a //g;
# replace :: with . (changes c++ style namespace/class directives to Python style)
$line =~ s/::/./g;
# replace nullptr with None (nullptr means nothing to Python devs)
$line =~ s/\bnullptr\b/None/g;

if ( $line =~ m/[\\@](ingroup|class)/ ) {
return ""
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterfilewriter.h
Expand Up @@ -59,7 +59,7 @@ class CORE_EXPORT QgsRasterFileWriter
* Returned provider may be used to initialize the raster using writeBlock() calls.
* Ownership of the returned provider is passed to the caller.
* \note Does not work with tiled mode enabled.
* \returns Instance of data provider in editing mode (on success) or null on error.
* \returns Instance of data provider in editing mode (on success) or nullptr on error.
* \since QGIS 3.0
*/
QgsRasterDataProvider *createOneBandRaster( Qgis::DataType dataType,
Expand Down
5 changes: 5 additions & 0 deletions tests/scripts/sipifyheader.expected.sip
Expand Up @@ -131,6 +131,11 @@ Factory annotation
Here's some comment mentioning another class QgsAutoAwesomemater.makeLessAwesome.
%End

MyPointer *pointerReturnValue();
%Docstring
I return a pointer. If something bad happens, I return None.
%End

bool isOKwithErrMesg( QString &ErrMsg /Out/ );

void InOutParam( bool &ok = true /In,Out/ );
Expand Down
5 changes: 5 additions & 0 deletions tests/scripts/sipifyheader.h
Expand Up @@ -163,6 +163,11 @@ class CORE_EXPORT QgsSipifyHeader : public QtClass<QVariant>, private Ui::QgsBas
*/
void LongDocStringMethodWithBrief();

/**
* I return a pointer. If something bad happens, I return nullptr.
*/
MyPointer *pointerReturnValue();

bool isOKwithErrMesg( QString &ErrMsg SIP_OUT );

void InOutParam( bool &ok = true SIP_INOUT );
Expand Down

0 comments on commit ca8e1d3

Please sign in to comment.