Skip to content

grass.tools: Add Tools API to generated tools doc #6015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wenzeslaus
Copy link
Member

@wenzeslaus wenzeslaus commented Jul 2, 2025

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:

tools = Tools()
tools.r_info(map="name", format="json")

Example with r.basins.fill:

image

The documentation contains text:

This API is experimental in version 8.5 and expected to be stable in version 8.6.

Comparison with the grass.script tab for r.info which does not have many parameters:

grass.script (only) grass.tools
image image

The io.StringIO piece in r.in.ascii documentation:

image

@wenzeslaus wenzeslaus added this to the 8.5.0 milestone Jul 2, 2025
@wenzeslaus wenzeslaus self-assigned this Jul 2, 2025
@wenzeslaus wenzeslaus added manual Documentation related issues docs labels Jul 2, 2025
@github-actions github-actions bot added C Related code is in C libraries labels Jul 2, 2025
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).
@wenzeslaus wenzeslaus force-pushed the grass.tools-to-tool-doc branch from 49930f5 to f7adc3e Compare July 18, 2025 14:12
@wenzeslaus
Copy link
Member Author

This is now waiting for #2923 to be merged. The CI failure (addons) is unrelated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C docs libraries manual Documentation related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant