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
Implement ability to limit module documentation building #24576
Conversation
The test
|
7b6dd1f
to
7561797
Compare
- Added new option to plugin_formatter.py to support passing-in a list of modules for which the documentation should be built. - Updated docuemtnation Makefile to allow specifying list of modules via environment variables (defaulting to all modules). - Update instructions for building documentation and module development to include commands and description of limiting module documentation builds.
Ok, next time I should run the sanity test myself :P |
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.
Fantastic - thanks @azaghal!
Looks good to me. Someone from the core team please review and merge if no issues. |
making it a 'limit' but also forcing to specify seem counter indicative, I would either rename to 'list' or would default to None/absent and filter against list if it is passed in. Also i would make into list on args parsing, not in the function that is rendering. other than that minutia, looks good |
docs/bin/plugin_formatter.py
Outdated
@@ -125,12 +125,13 @@ def write_data(text, options, outputname, module): | |||
##################################################################################### | |||
|
|||
|
|||
def list_modules(module_dir, depth=0): | |||
def list_modules(module_dir, depth=0, limit_to_modules="all"): |
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.
I think I would make limit_to_modules arg a list here, and do the comma split on the cli arg before calling list_modules.
(currently it looks this would do odd things if attempting to build module docs for a module with a name like 'ec2_vps_cwt_jkg_none_facts' or 'firewalld' or 'easy_install'? Haven't tested though so that may be covered...)
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.
limit_to_modules
is currently supposed to be comma-separated string, so modules with mentioned names should not be a problem.
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.
I'll see what I can do to switch to lists and conditionals. One problem is my Makefile
expertise is virtually non-existent (and don't have much time/will to learn it atm :)
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.
Hm... Another thing is how to specify "no modules" at all. I.e. without using the "all" or "none" keywords? Or would it be ok to preserve a variant where value of all
or none
means that?
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.
Sheesh... So, before I get any deeper into this, the limit_to_modules
parameter received after option parser is invoked should end-up producing one of the following values:
None
- no limitation, default if option is not specified.[]
- don't build any modules. This should be set if you specify special keyword ---limit-to-modules none
.['a', 'b', 'c']
- build only specified module. This should be set if you specify--limit-to-modules a,b,c
.
Three ways that I can see to go around this (with one simply not working):
-
Massage option value after call to
(options, args) = p.parse_args()
. -
Use callback, but this won't work since we need to set type, and there is no
list
type (plus, we needlist + None
type in this particular case I guess).
Preferences? Or am I just overcomplicating this?
- Pass list of modules (or None) to list_modules function instead of string. - Move conversion of module list to argument parsing code. - No special keywords. Default ("") means build all modules. For no modules just specify non-existing module name. - Updated documentation to reflect the changes.
Ok, updated the pull request based on comments from review (gave-up on complicated solution :). |
docs/bin/plugin_formatter.py
Outdated
@@ -194,6 +197,8 @@ def generate_parser(): | |||
p.add_option("-v", "--verbose", action='store_true', default=False, help="Verbose") | |||
p.add_option("-o", "--output-dir", action="store", dest="output_dir", default=None, help="Output directory for module files") | |||
p.add_option("-I", "--includes-file", action="store", dest="includes_file", default=None, help="Create a file containing list of processed modules") | |||
p.add_option("-l", "--limit-to-modules", action="store", dest="limit_to_modules", default="", |
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.
making None the default saves you some code
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.
Ah, right... Was playing around with setting type
, and that one did not like None. Will fix.
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.
Actually... I don't think it does, but I will fix it.
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.
Pushed again.
- Use better default value, and don't treat "" as special case. - Conditionally invoke different variants of command in Makefile instead of using special value "".
mod_info, categories, aliases = list_modules(options.module_dir) | ||
# Convert passed-in limit_to_modules to None or list of modules. | ||
if options.limit_to_modules is not None: | ||
options.limit_to_modules = [s.lower() for s in options.limit_to_modules.split(",")] |
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.
dont reassign options.limit_to_modules, just created a new limit_to_modules var
if options.limit_to_modules is not None:
limit_to_modules = [s.lower() for s in options.limit_to_modules.split(",")]
mod_info, categories, aliases = list_modules(options.module_dir, limit_to_modules=limit_to_modules)
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.
I wouldn't block on this but stylewise, I do agree with alikins that it's better to do all modifications of things in options inside of the argument parsing functions and then set other variables if the code is outside of it. (In my own code I tend to have a parse_options function that would combine generate_parser, validate_options, and also do transformations on the arguments like this. That function would return the options data structure at the end and then I'd try to treat it as immutable thereafter).
so @nitzmahone #25313 gives the ability to generate a single non-module html page. Combined with this we can generate any page. This would save lots of people lots of time, so +1000 from me |
+1 for this. Note that running html docs build with a subset of modules can lead to false positive errors (due to modules being able to link to other modules and those other modules perhaps not being present). So you do have to be careful if you add this to some sort of automated testing. |
Likely we don't need #25791 if this gets merged, so cross referencing it. |
Given that #25313 got merged, not sure this pull request is relevant? I actually thought I had closed it already :) |
What's the plan for this & #25791 |
Well, at least I have no idea what the plans are. I took a bit different approach compared to #25313, more centered around modules. For what it's worth, my patch is faster on initial build (since processing of most modules is skipped). Otherwise, the other approach covers everything (minus the docs :) |
I updated #25791 with docs and shellcheck fixes now. |
make webdocs` instead. This should make testing module documentation syntax much | ||
faster. Instead of a single module, you can also specify a comma-separated list | ||
of modules. In order to skip building documentation for all modules, specify | ||
non-existing module name, for example `MODULES=none make webdocs`. |
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.
I recommend passing vars as args in all new make
examples. Example: make webdocs MODULES=none
Also, use a non-existent module name
instead of non-existing module name
.
Not a blocker, just a suggestion to improve readability. If you do change it, update all new occurrences.
We've agreed to go with this and close #25791 |
Wording tweak
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.
Docs OK with some minor edits. Can't wait to implement this. Thanks @azaghal!
Sorry for late reply (as usual...), but going through my mail backlog :) Should I continue in the same direction, probably just double-checking on reviews? I am happy to invest time as long as it's not a dead (or super-prolonged) end :) |
Thanks very much @azaghal! |
Oh, no changes needed in the end? Great, I hope it will help people :) |
SUMMARY
The purpose of this pull request is to introduce option for limiting which module documentation gets built. Implementation achieves this via
MODULES
environment variable that can get passed-in tomake webdocs
.The reason for this change is to allow both module developers and documentation contributors to more quickly see and test their changes. Building entire documentation for all modules can take quite a while, and it deters from fixing small syntax, typos and similar errors.
ISSUE TYPE
COMPONENT NAME
Documentation build system
ANSIBLE VERSION
ADDITIONAL INFORMATION
In order to test the change, you can do the following: