mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
[sipify] habndle python code snippets
This commit is contained in:
parent
90e5196996
commit
d042304cc3
@ -44,21 +44,21 @@ Transformations between coordinate reference systems are done using QgsCoordinat
|
|||||||
|
|
||||||
For example, the following code will create and inspect "British national grid" CRS:
|
For example, the following code will create and inspect "British national grid" CRS:
|
||||||
|
|
||||||
~~~{.py}
|
.. code-block:: python
|
||||||
crs = QgsCoordinateReferenceSystem("EPSG:27700")
|
|
||||||
if crs.isValid():
|
crs = QgsCoordinateReferenceSystem("EPSG:27700")
|
||||||
print("CRS Description: {}".format(crs.description()))
|
if crs.isValid():
|
||||||
print("CRS PROJ.4 text: {}".format(crs.toProj4()))
|
print("CRS Description: {}".format(crs.description()))
|
||||||
else:
|
print("CRS PROJ.4 text: {}".format(crs.toProj4()))
|
||||||
print("Invalid CRS!")
|
else:
|
||||||
~~~
|
print("Invalid CRS!")
|
||||||
|
|
||||||
This will produce the following output:
|
This will produce the following output:
|
||||||
|
|
||||||
~~~
|
.. code-block:: python
|
||||||
CRS Description: OSGB 1936 / British National Grid
|
|
||||||
CRS PROJ.4 text: +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 [output trimmed]
|
CRS Description: OSGB 1936 / British National Grid
|
||||||
~~~
|
CRS PROJ.4 text: +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 [output trimmed]
|
||||||
|
|
||||||
CRS Definition Formats
|
CRS Definition Formats
|
||||||
======================
|
======================
|
||||||
@ -149,6 +149,7 @@ There are two different flavors of WKT: one is defined by OGC, the other is the
|
|||||||
used by ESRI. They look very similar, but they are not the same. QGIS is able to consume
|
used by ESRI. They look very similar, but they are not the same. QGIS is able to consume
|
||||||
both flavors.
|
both flavors.
|
||||||
|
|
||||||
|
|
||||||
.. seealso:: :py:class:`QgsCoordinateTransform`
|
.. seealso:: :py:class:`QgsCoordinateTransform`
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
@ -205,12 +205,12 @@ Returns details about internals of this renderer.
|
|||||||
|
|
||||||
E.g. if you only want to deal with visible features:
|
E.g. if you only want to deal with visible features:
|
||||||
|
|
||||||
~~~{.py}
|
.. code-block:: python
|
||||||
if not renderer.capabilities().testFlag(QgsFeatureRenderer.Filter) or renderer.willRenderFeature(feature, context):
|
|
||||||
deal_with_my_feature()
|
if not renderer.capabilities().testFlag(QgsFeatureRenderer.Filter) or renderer.willRenderFeature(feature, context):
|
||||||
else:
|
deal_with_my_feature()
|
||||||
skip_the_curren_feature()
|
else:
|
||||||
~~~
|
skip_the_curren_feature()
|
||||||
%End
|
%End
|
||||||
|
|
||||||
virtual QgsSymbolList symbols( QgsRenderContext &context );
|
virtual QgsSymbolList symbols( QgsRenderContext &context );
|
||||||
|
@ -46,6 +46,7 @@ my $PYTHON_SIGNATURE = '';
|
|||||||
|
|
||||||
my $COMMENT = '';
|
my $COMMENT = '';
|
||||||
my $COMMENT_PARAM_LIST = 0;
|
my $COMMENT_PARAM_LIST = 0;
|
||||||
|
my $CODE_SNIPPET = 0;
|
||||||
my $GLOB_IFDEF_NESTING_IDX = 0;
|
my $GLOB_IFDEF_NESTING_IDX = 0;
|
||||||
my @GLOB_BRACKET_NESTING_IDX = (0);
|
my @GLOB_BRACKET_NESTING_IDX = (0);
|
||||||
my $PRIVATE_SECTION_LINE = '';
|
my $PRIVATE_SECTION_LINE = '';
|
||||||
@ -119,6 +120,22 @@ sub write_header_footer {
|
|||||||
|
|
||||||
sub processDoxygenLine {
|
sub processDoxygenLine {
|
||||||
my $line = $_[0];
|
my $line = $_[0];
|
||||||
|
|
||||||
|
# detect code snipped
|
||||||
|
if ( $line =~ m/\\code\{\.(\w+)\}/ ) {
|
||||||
|
my $codelang = $1;
|
||||||
|
$codelang =~ s/py/python/;
|
||||||
|
$CODE_SNIPPET=1;
|
||||||
|
return ".. code-block:: $codelang\n\n";
|
||||||
|
}
|
||||||
|
if ( $line =~ m/\\endcode/ ) {
|
||||||
|
$CODE_SNIPPET = 0;
|
||||||
|
return "\n";
|
||||||
|
}
|
||||||
|
if ($CODE_SNIPPET == 1){
|
||||||
|
return " $line\n";
|
||||||
|
}
|
||||||
|
|
||||||
# remove prepending spaces
|
# remove prepending spaces
|
||||||
$line =~ s/^\s+//g;
|
$line =~ s/^\s+//g;
|
||||||
# remove \a formatting
|
# remove \a formatting
|
||||||
@ -130,6 +147,7 @@ sub processDoxygenLine {
|
|||||||
# replace \returns with :return:
|
# replace \returns with :return:
|
||||||
$line =~ s/\s*\\return(s)?/\n:return:/;
|
$line =~ s/\s*\\return(s)?/\n:return:/;
|
||||||
|
|
||||||
|
# params
|
||||||
if ( $line =~ m/\\param / ){
|
if ( $line =~ m/\\param / ){
|
||||||
$line =~ s/\s*\\param (\w+)\b/:param $1:/g;
|
$line =~ s/\s*\\param (\w+)\b/:param $1:/g;
|
||||||
if ( $COMMENT_PARAM_LIST == 0 )
|
if ( $COMMENT_PARAM_LIST == 0 )
|
||||||
@ -139,7 +157,6 @@ sub processDoxygenLine {
|
|||||||
$COMMENT_PARAM_LIST = 1;
|
$COMMENT_PARAM_LIST = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( $line =~ m/[\\@](ingroup|class)/ ) {
|
if ( $line =~ m/[\\@](ingroup|class)/ ) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -305,6 +322,7 @@ sub detect_comment_block{
|
|||||||
my %args = ( strict_mode => STRICT, @_ );
|
my %args = ( strict_mode => STRICT, @_ );
|
||||||
# dbg_info("detect comment strict:" . $args{strict_mode} );
|
# dbg_info("detect comment strict:" . $args{strict_mode} );
|
||||||
$COMMENT_PARAM_LIST = 0;
|
$COMMENT_PARAM_LIST = 0;
|
||||||
|
$CODE_SNIPPET = 0;
|
||||||
if ( $LINE =~ m/^\s*\/\*/ || $args{strict_mode} == UNSTRICT && $LINE =~ m/\/\*/ ){
|
if ( $LINE =~ m/^\s*\/\*/ || $args{strict_mode} == UNSTRICT && $LINE =~ m/\/\*/ ){
|
||||||
dbg_info("found comment block");
|
dbg_info("found comment block");
|
||||||
do {no warnings 'uninitialized';
|
do {no warnings 'uninitialized';
|
||||||
|
@ -79,21 +79,21 @@ typedef void ( *CUSTOM_CRS_VALIDATION )( QgsCoordinateReferenceSystem & ) SIP_SK
|
|||||||
*
|
*
|
||||||
* For example, the following code will create and inspect "British national grid" CRS:
|
* For example, the following code will create and inspect "British national grid" CRS:
|
||||||
*
|
*
|
||||||
* ~~~{.py}
|
* \code{.py}
|
||||||
* crs = QgsCoordinateReferenceSystem("EPSG:27700")
|
* crs = QgsCoordinateReferenceSystem("EPSG:27700")
|
||||||
* if crs.isValid():
|
* if crs.isValid():
|
||||||
* print("CRS Description: {}".format(crs.description()))
|
* print("CRS Description: {}".format(crs.description()))
|
||||||
* print("CRS PROJ.4 text: {}".format(crs.toProj4()))
|
* print("CRS PROJ.4 text: {}".format(crs.toProj4()))
|
||||||
* else:
|
* else:
|
||||||
* print("Invalid CRS!")
|
* print("Invalid CRS!")
|
||||||
* ~~~
|
* \endcode
|
||||||
*
|
*
|
||||||
* This will produce the following output:
|
* This will produce the following output:
|
||||||
*
|
*
|
||||||
* ~~~
|
* \code{.py}
|
||||||
* CRS Description: OSGB 1936 / British National Grid
|
* CRS Description: OSGB 1936 / British National Grid
|
||||||
* CRS PROJ.4 text: +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 [output trimmed]
|
* CRS PROJ.4 text: +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 [output trimmed]
|
||||||
* ~~~
|
* \endcode
|
||||||
*
|
*
|
||||||
* CRS Definition Formats
|
* CRS Definition Formats
|
||||||
* ======================
|
* ======================
|
||||||
|
@ -249,12 +249,12 @@ class CORE_EXPORT QgsFeatureRenderer
|
|||||||
*
|
*
|
||||||
* E.g. if you only want to deal with visible features:
|
* E.g. if you only want to deal with visible features:
|
||||||
*
|
*
|
||||||
* ~~~{.py}
|
* \code{.py}
|
||||||
* if not renderer.capabilities().testFlag(QgsFeatureRenderer.Filter) or renderer.willRenderFeature(feature, context):
|
* if not renderer.capabilities().testFlag(QgsFeatureRenderer.Filter) or renderer.willRenderFeature(feature, context):
|
||||||
* deal_with_my_feature()
|
* deal_with_my_feature()
|
||||||
* else:
|
* else:
|
||||||
* skip_the_curren_feature()
|
* skip_the_curren_feature()
|
||||||
* ~~~
|
* \endcode
|
||||||
*/
|
*/
|
||||||
virtual QgsFeatureRenderer::Capabilities capabilities() { return nullptr; }
|
virtual QgsFeatureRenderer::Capabilities capabilities() { return nullptr; }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user