-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
use faster method to get short_description from DOCUMENTATION #42705
Conversation
This is a very nice improvement when running
|
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.
LGTM; nice speedup, and I can't really think of a way to break it the way we do plugin docs today... The CI sanity test is no longer using -l
for the "full parse test", so I'm +1 for this.
I needed to retrieve the metadata for modules which failed because of missing documentation and thought I should mention at the same time: you were correct about this not needing to be implemented as a parameter in the function call. Just replacing get_docstring would be a much simpler and better approach (especially as it doesn't set up a contract that it will never fulfill (all return values being empty except for doc). I've modified the code so that it follows the simpler pattern. |
SUMMARY
Created a stub lookup function for pulling only the short_description from docstrings to speed up the runtime of the ansible-doc -l command.
ISSUE TYPE
COMPONENT NAME
cli/doc
ANSIBLE VERSION
ADDITIONAL INFORMATION
The idea is to not use the heavy portions of get_docstring when the only piece needed is the short_description for output to ansible-doc -l. The current lookup is parsing every module and converting them to nodes, which is slow operation that will continue to grow over time as modules grow or are added.
I have made a couple assumptions: documentation string doesn't have leading indents, and the first instance of short_description in a given module is the one in the documentation string.
Given the style guide for module creation I don't think it would be an issue, but happy to make handling more robust if there are known cases where this wouldn't be enforced (out put of command is unchanged on my test system with the new method).
I also implemented this as an additional parser function for get_plugin_list_text in case this was used or planned to be used elsewhere in its current state. If this is the only function it performs then get_docstub doesn't need to be parameterized in the function call and can just replace get_docstring.