grass.tools: Add Tools API to generated tools doc#6015
Merged
wenzeslaus merged 6 commits intoOSGeo:mainfrom Jul 28, 2025
Merged
grass.tools: Add Tools API to generated tools doc#6015wenzeslaus merged 6 commits intoOSGeo:mainfrom
wenzeslaus merged 6 commits intoOSGeo:mainfrom
Conversation
Concept of how this could look like. The formatting needs more work. The parameters are the same as grass.script except io.StringIO which will be difficult to generate with the current metadata because the parser does not know about stdin in this sense (the validity is resolved while opening the file by a library function call at tool-level, but during command line parsing, the parser merely allows for dash being provided instead of a filename).
49930f5 to
f7adc3e
Compare
Member
Author
|
This is now waiting for #2923 to be merged. The CI failure (addons) is unrelated. |
echoix
reviewed
Jul 27, 2025
…ify the comment about parse_command versus others.
Member
Author
|
Please, check the new wording for both the generated text and the comment. |
echoix
approved these changes
Jul 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds grass.tools.Tools from #2923 to the generated documentation of tools as a new tab similar to the grass.script tab. The documentation and treatment of parameters is the same at this points in grass.tools as in grass.script except for io.StringIO.
The io.StringIO type is added based on the gisprompt on a best-guess basis. The current parser metadata don't contain explicit machine-readable information about stdin being allowed. Parser then does not know whether or not a specific tool supports stdin for one of its parameters. The stdin is resolved while opening the file by a library function call at the level of individual tools, but during command line parsing, the parser merely allows for dash being provided instead of a filename. The resulting documentation now contains
"'-' for standard input"or the like based on what is in each tool. This is slightly misleading for the Tools API because"-"won't do anything useful because the only way to supply stdin at this point is io.StringIO. However, without extending the parser metadata, I don't see any way how to make it better.The example creates a Tools object called tools and then calls its method:
Example with r.basins.fill:
The documentation contains text:
Comparison with the grass.script tab for r.info which does not have many parameters:
The io.StringIO piece in r.in.ascii documentation: