grass.tools: Add Tools API to generated tools doc #6015
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: