qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.54k stars 2.99k forks source link

grass algorithm descriptions can't include a hyphen in the second line unless it starts with the algorithm id #59210

Open AlisterH opened 6 days ago

AlisterH commented 6 days ago

What is the bug or the crash?

First, some Grass processing algorithms have their algorithm id at the beginning of the description that is shown in the tooltip in the processing toolbox, and the right pane of the algorithm dialog, but others don't, so this is both unnecessary from the user's point of view, and inconsistent.

Second, when writing the second line of a description file for a grass processing algorithm, this does not work (QGIS silently fails to load the algorithm):

Calculates flow accumulation, subwatersheds, stream networks, and longest flow paths from a flow direction map. <p>If the catchment you are interested in is not created, it may be because it extends to the edge of the input - try a larger input.

The problem seems to be the hyphen. Either of these work:

r.accumulate - Calculates flow accumulation, subwatersheds, stream networks, and longest flow paths from a flow direction map. <p>If the catchment you are interested in is not created, it may be because it extends to the edge of the input; try a larger input.
Calculates flow accumulation, subwatersheds, stream networks, and longest flow paths from a flow direction map. <p>If the catchment you are interested in is not created, it may be because it extends to the edge of the input; try a larger input.

So: The only time a dash can be used is as a separator when the description is preceded by the algorithm id. This is obviously because of this comment in grass.txt

For split commands you must include the algorithm id first, e.g.:
    r.sun.insoltime - Solar irradiance and irradiation model (daily sums).

And the hackery in https://github.com/qgis/QGIS/blob/master/python/plugins/grassprovider/parsed_description.py

            # First line of the file is the Grass algorithm name
            line = lines.readline().strip('\n').strip()
            result.grass_command = line
            # Second line if the algorithm name in Processing
            line = lines.readline().strip('\n').strip()
            result.short_description = line
            if " - " not in line:
                result.name = result.grass_command
            else:
                result.name = line[:line.find(' ')].lower()

This is weird and I'm not sure it is really necessary, but maybe we should just mention it in grass.txt

Steps to reproduce the issue

Try writing and using a grass algorithm description with a hyphen in the description (not as a separator from a preceding the algorithm id).

Versions

QGIS version 3.38.3-Grenoble QGIS code revision 37f9e6efee Qt version 5.15.13 Python version 3.12.6 GDAL/OGR version 3.9.2 PROJ version 9.4.0 EPSG Registry database version v11.004 (2024-02-24) GEOS version 3.12.2-CAPI-1.18.2 SQLite version 3.45.1 PDAL version 2.6.3 PostgreSQL client version 16.2 SpatiaLite version 5.1.0 QWT version 6.2.0 QScintilla2 version 2.14.1 OS version Windows 11 Version 2009

Active Python plugins db_manager 0.1.20 grassprovider 2.12.99 MetaSearch 0.3.6 processing 2.12.99

Supported QGIS version

New profile

Additional context

No response

AlisterH commented 5 days ago

Weird; have updated the description as it seems I somehow got confused initially.