forked from pyinfra-dev/pyinfra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate global kwargs doc from the config.
This means new global kwargs will be automatically documented!
- Loading branch information
Showing
4 changed files
with
42 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ venv/ | |
docs/build/ | ||
docs/facts/ | ||
docs/modules/ | ||
docs/_deploy_globals.rst | ||
|
||
.idea/ | ||
|
||
pyinfra-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python | ||
|
||
from os import path | ||
|
||
from pyinfra.api.operation_kwargs import OPERATION_KWARGS | ||
|
||
|
||
def build_global_kwargs_doc(): | ||
this_dir = path.dirname(path.realpath(__file__)) | ||
docs_dir = path.abspath(path.join(this_dir, '..', 'docs')) | ||
|
||
lines = [] | ||
|
||
for category, kwarg_configs in OPERATION_KWARGS.items(): | ||
if category is None: | ||
continue | ||
|
||
lines.append('{0}:'.format(category)) | ||
|
||
for key, config in kwarg_configs.items(): | ||
description = config | ||
if isinstance(config, dict): | ||
description = config.get('description') | ||
|
||
lines.append(' + ``{0}``: {1}'.format(key, description)) | ||
|
||
module_filename = path.join(docs_dir, '_deploy_globals.rst') | ||
print('--> Writing {0}'.format(module_filename)) | ||
|
||
out = '\n'.join(lines) | ||
|
||
with open(module_filename, 'w') as outfile: | ||
outfile.write(out) | ||
|
||
|
||
if __name__ == '__main__': | ||
print('### Building global kwargs doc') | ||
build_global_kwargs_doc() |