Don't mangle http see links in PyQGIS docs

This commit is contained in:
Nyall Dawson 2024-09-03 12:03:56 +10:00
parent 534ca73c59
commit f2e4c3dfb7
6 changed files with 24 additions and 18 deletions

View File

@ -718,7 +718,7 @@ Please note that the sum will be negative if the points are defined in clockwise
Therefore, if you want to use the sum as an area (as the method name indicates) then you probably should use the absolute value,
since otherwise a bug can be introduced (such as the bug fixed for github issue 49578)
.. seealso:: :py:func:`https` //en.wikipedia.org/wiki/Shoelace_formula#Triangle_formula
.. seealso:: https://en.wikipedia.org/wiki/Shoelace_formula#Triangle_formula
%End
virtual double vertexAngle( QgsVertexId vertex ) const;

View File

@ -120,14 +120,14 @@ Returns a list of licences available by default in the wizard.
%Docstring
Returns a list of link types available by default in the wizard.
.. seealso:: :py:func:`https` //github.com/OSGeo/Cat-Interop/blob/master/LinkPropertyLookupTable.csv
.. seealso:: https://github.com/OSGeo/Cat-Interop/blob/master/LinkPropertyLookupTable.csv
%End
static QStringList parseMimeTypes();
%Docstring
Returns a list of MIME types available by default in the wizard.
.. seealso:: :py:func:`https` //fr.wikipedia.org/wiki/Type_MIME
.. seealso:: https://fr.wikipedia.org/wiki/Type_MIME
%End
static QMap<QString, QString> parseTypes();

View File

@ -718,7 +718,7 @@ Please note that the sum will be negative if the points are defined in clockwise
Therefore, if you want to use the sum as an area (as the method name indicates) then you probably should use the absolute value,
since otherwise a bug can be introduced (such as the bug fixed for github issue 49578)
.. seealso:: :py:func:`https` //en.wikipedia.org/wiki/Shoelace_formula#Triangle_formula
.. seealso:: https://en.wikipedia.org/wiki/Shoelace_formula#Triangle_formula
%End
virtual double vertexAngle( QgsVertexId vertex ) const;

View File

@ -120,14 +120,14 @@ Returns a list of licences available by default in the wizard.
%Docstring
Returns a list of link types available by default in the wizard.
.. seealso:: :py:func:`https` //github.com/OSGeo/Cat-Interop/blob/master/LinkPropertyLookupTable.csv
.. seealso:: https://github.com/OSGeo/Cat-Interop/blob/master/LinkPropertyLookupTable.csv
%End
static QStringList parseMimeTypes();
%Docstring
Returns a list of MIME types available by default in the wizard.
.. seealso:: :py:func:`https` //fr.wikipedia.org/wiki/Type_MIME
.. seealso:: https://fr.wikipedia.org/wiki/Type_MIME
%End
static QMap<QString, QString> parseTypes();

View File

@ -852,23 +852,29 @@ def process_doxygen_line(line: str) -> str:
return create_class_links(depr_line)
# Handle see also
see_matches = list(re.finditer(r'\\see +(\w+(\.\w+)*)(\([^()]*\))?', line))
see_matches = list(re.finditer(r'\\see +([\w:/.#-]+(\.\w+)*)(\([^()]*\))?(\.?)', line))
if see_matches:
for see_match in reversed(see_matches):
seealso = see_match.group(1)
seealso_suffix = see_match.group(4)
seeline = ''
dbg_info(f"see also: `{seealso}`")
if re.match(r'^Qgs[A-Z]\w+(\([^()]*\))?$', seealso):
dbg_info(f"\\see :py:class:`{seealso}`")
seeline = f":py:class:`{seealso}`"
elif re.match(r'^(Qgs[A-Z]\w+)\.(\w+)(\([^()]*\))?$', seealso):
dbg_info(f"\\see py:func with param: :py:func:`{seealso}`")
seeline = f":py:func:`{seealso}`"
elif re.match(r'^[a-z]\w+(\([^()]*\))?$', seealso):
dbg_info(f"\\see :py:func:`{seealso}`")
seeline = f":py:func:`{seealso}`"
if re.match(r'^http', seealso):
seeline = f"{seealso}"
elif seealso_match := re.match(r'^(Qgs[A-Z]\w+(\([^()]*\))?)(\.)?$', seealso):
dbg_info(f"\\see :py:class:`{seealso_match.group(1)}`")
seeline = f":py:class:`{seealso_match.group(1)}`{seealso_match.group(3) or ''}"
elif seealso_match := re.match(r'^((Qgs[A-Z]\w+)\.(\w+)(\([^()]*\))?)(\.)?$', seealso):
dbg_info(f"\\see py:func with param: :py:func:`{seealso_match.group(1)}`")
seeline = f":py:func:`{seealso_match.group(1)}`{seealso_match.group(5) or ''}"
elif seealso_match := re.match(r'^([a-z]\w+(\([^()]*\))?)(\.)?$', seealso):
dbg_info(f"\\see :py:func:`{seealso_match.group(1)}`")
seeline = f":py:func:`{seealso_match.group(1)}`{seealso_match.group(3) or ''}"
if full_line_match := re.match(r'^\s*\\see +(\w+(?:\.\w+)*)(?:\([^()]*\))?[\s,.:-]*(.*?)$', line):
if seeline.startswith('http'):
return f"\n.. seealso:: {seeline}\n"
suffix = full_line_match.group(2)
if suffix:
return f"\n.. seealso:: {seeline or seealso} {suffix.strip()}\n"
@ -876,7 +882,7 @@ def process_doxygen_line(line: str) -> str:
return f"\n.. seealso:: {seeline or seealso}\n"
else:
if seeline:
line = line[:see_match.start()] + seeline + line[
line = line[:see_match.start()] + seeline + seealso_suffix + line[
see_match.end():] # re.sub(r'\\see +(\w+(\.\w+)*(\(\))?)', seeline, line)
else:
line = line.replace('\\see', 'see')

View File

@ -67,7 +67,7 @@ class RemoveRecentCrsDelegate : public QStyledItemDelegate SIP_SKIP
* QgsProjectionSelectionDialog dialog. In most cases it is more
* suitable to use the compact QgsProjectionSelectionWidget widget.
*
* \see QgsProjectionSelectionDialog.
* \see QgsProjectionSelectionDialog
* \see QgsProjectionSelectionWidget
*/