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
Help api types #14081
Help api types #14081
Conversation
Added input type info:
|
Found this pretty example (and with advanced help, shows all awaitable get constraints too):
|
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
Ready for review as #13993 has landed. |
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super, super epic. And we can generate docsite pages as well in a followup, I assume...
def _print_all_api_types(self) -> None: | ||
self._print_title("Plugin API Types") | ||
api_type_descriptions: Dict[str, str] = {} | ||
for api_type, rule_infos in self._all_help_info.rule_output_type_to_rule_infos.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your example the output is sorted alphabetically, but I'm not sure how?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should omit types beginning with an underscore? Those are not intended to be used by general plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theres a "sorted" call in the returned dict comprehension of get_rule_infos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. So I suggest we filter out types that start with _
, and then this is good to go.
Yes, that's the idea :) |
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So cool! 😍
print(f"{name}{description}\n") | ||
api_help_cmd = f"{self._bin_name} help $api_type" | ||
print(f"Use `{self.maybe_green(api_help_cmd)}` to get help for a specific API type.\n") | ||
|
||
def _print_global_help(self): | ||
def print_cmd(args: str, desc: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be updated to mention api-tools
.
Builds on top of #13993
Add help info for all available rule output types, and the rules that provides them.
Example output:
Granted, the help info is a bit terse, but that's only because there has not been a real motivation for providing it before. With this, any rule descriptions and doc strings, along with doc strings on output types is presented.
It's a nice place to discover what types are actually available.
Perhaps also required inputs should be presented for the rules?Done.