Fix Python docstring for dijkstra method

Fixes #56172
This commit is contained in:
Nyall Dawson 2025-07-09 08:51:21 +10:00
parent 4fe72dd84f
commit 6417adf60e
6 changed files with 28 additions and 16 deletions

View File

@ -2418,6 +2418,7 @@ EXPAND_AS_DEFINED = "SIP_ABSTRACT" \
"SIP_NODEFAULTCTORS" \
"SIP_NO_FILE" \
"SIP_OUT" \
"SIP_DOCSTRING_OUT" \
"SIP_PROPERTY" \
"SIP_PYARGDEFAULT" \
"SIP_PYARGREMOVE" \

View File

@ -21,19 +21,20 @@ points using different strategies with Dijkstra's algorithm.
#include "qgsgraphanalyzer.h"
%End
public:
static SIP_PYLIST dijkstra( const QgsGraph *source, int startVertexIdx, int criterionNum, QVector<int> *resultTree = 0, QVector<double> *resultCost = 0 );
static SIP_PYLIST dijkstra( const QgsGraph *source, int startVertexIdx, int criterionNum, QVector<int> *resultTree = 0, QVector<double> *resultCost = 0 );
%Docstring
Solve shortest path problem using Dijkstra algorithm
:param source: source graph
:param startVertexIdx: index of the start vertex
:param criterionNum: index of the optimization strategy
:param resultTree: array that represents shortest path tree. resultTree[
vertexIndex ] == inboundingArcIndex if vertex
reachable, otherwise resultTree[ vertexIndex ] == -1.
Note that the startVertexIdx will also have a value
of -1 and may need special handling by callers.
:param resultCost: array of the paths costs
:return: - resultTree: array that represents shortest path tree.
resultTree[ vertexIndex ] == inboundingArcIndex if vertex
reachable, otherwise resultTree[ vertexIndex ] == -1. Note
that the startVertexIdx will also have a value of -1 and may
need special handling by callers.
- resultCost: array of the paths costs
%End
%MethodCode

View File

@ -21,19 +21,20 @@ points using different strategies with Dijkstra's algorithm.
#include "qgsgraphanalyzer.h"
%End
public:
static SIP_PYLIST dijkstra( const QgsGraph *source, int startVertexIdx, int criterionNum, QVector<int> *resultTree = 0, QVector<double> *resultCost = 0 );
static SIP_PYLIST dijkstra( const QgsGraph *source, int startVertexIdx, int criterionNum, QVector<int> *resultTree = 0, QVector<double> *resultCost = 0 );
%Docstring
Solve shortest path problem using Dijkstra algorithm
:param source: source graph
:param startVertexIdx: index of the start vertex
:param criterionNum: index of the optimization strategy
:param resultTree: array that represents shortest path tree. resultTree[
vertexIndex ] == inboundingArcIndex if vertex
reachable, otherwise resultTree[ vertexIndex ] == -1.
Note that the startVertexIdx will also have a value
of -1 and may need special handling by callers.
:param resultCost: array of the paths costs
:return: - resultTree: array that represents shortest path tree.
resultTree[ vertexIndex ] == inboundingArcIndex if vertex
reachable, otherwise resultTree[ vertexIndex ] == -1. Note
that the startVertexIdx will also have a value of -1 and may
need special handling by callers.
- resultCost: array of the paths costs
%End
%MethodCode

View File

@ -1364,7 +1364,7 @@ def fix_annotations(line):
CONTEXT.skipped_params_remove.append(param)
dbg_info(f"caught removed param: {CONTEXT.skipped_params_remove[-1]}")
_out_params = re.findall(r"(\w+)\s+SIP_OUT", line)
_out_params = re.findall(r"(\w+)\s+(?:SIP_OUT|SIP_DOCSTRING_OUT)", line)
for param in _out_params:
CONTEXT.skipped_params_out.append(param)
dbg_info(f"caught removed param: {CONTEXT.skipped_params_out[-1]}")
@ -1388,6 +1388,7 @@ def fix_annotations(line):
r"\bSIP_KEEPREFERENCE\b": "/KeepReference/",
r"\bSIP_NODEFAULTCTORS\b": "/NoDefaultCtors/",
r"\bSIP_OUT\b": "/Out/",
r"\bSIP_DOCSTRING_OUT\b": "",
r"\bSIP_RELEASEGIL\b": "/ReleaseGIL/",
r"\bSIP_HOLDGIL\b": "/HoldGIL/",
r"\bSIP_TRANSFER\b": "/Transfer/",

View File

@ -40,7 +40,7 @@ class ANALYSIS_EXPORT QgsGraphAnalyzer
* Note that the startVertexIdx will also have a value of -1 and may need special handling by callers.
* \param resultCost array of the paths costs
*/
static void SIP_PYALTERNATIVETYPE( SIP_PYLIST ) dijkstra( const QgsGraph *source, int startVertexIdx, int criterionNum, QVector<int> *resultTree = nullptr, QVector<double> *resultCost = nullptr );
static void SIP_PYALTERNATIVETYPE( SIP_PYLIST ) dijkstra( const QgsGraph *source, int startVertexIdx, int criterionNum, QVector<int> *resultTree SIP_DOCSTRING_OUT = nullptr, QVector<double> *resultCost SIP_DOCSTRING_OUT = nullptr );
#ifdef SIP_RUN
//%MethodCode

View File

@ -57,6 +57,14 @@
*/
#define SIP_OUT
/*
* Alternative to SIP_OUT for methods with manual SIP MethodCode, where only the docstring needs to be
* considered for the output argument.
*
* No /Out/ annotation will be added to the SIP bindings.
*/
#define SIP_DOCSTRING_OUT
/*
* https://www.riverbankcomputing.com/static/Docs/sip/annotations.html#argument-annotation-In
*/