Modules tocfix (#51077)
define & create subcategories, output by category and subcat
This commit is contained in:
parent
2d83db7036
commit
3eec7f1820
2 changed files with 56 additions and 7 deletions
|
@ -301,6 +301,10 @@ def get_plugin_info(module_dir, limit_to=None, verbose=False):
|
||||||
# Start at the second directory because we don't want the "vendor"
|
# Start at the second directory because we don't want the "vendor"
|
||||||
mod_path_only = os.path.dirname(module_path[len(module_dir):])
|
mod_path_only = os.path.dirname(module_path[len(module_dir):])
|
||||||
|
|
||||||
|
# Find the subcategory for each module
|
||||||
|
relative_dir = mod_path_only.split('/')[1]
|
||||||
|
sub_category = mod_path_only[len(relative_dir) + 2:]
|
||||||
|
|
||||||
primary_category = ''
|
primary_category = ''
|
||||||
module_categories = []
|
module_categories = []
|
||||||
# build up the categories that this module belongs to
|
# build up the categories that this module belongs to
|
||||||
|
@ -338,6 +342,7 @@ def get_plugin_info(module_dir, limit_to=None, verbose=False):
|
||||||
'returndocs': returndocs,
|
'returndocs': returndocs,
|
||||||
'categories': module_categories,
|
'categories': module_categories,
|
||||||
'primary_category': primary_category,
|
'primary_category': primary_category,
|
||||||
|
'sub_category': sub_category,
|
||||||
}
|
}
|
||||||
|
|
||||||
# keep module tests out of becoming module docs
|
# keep module tests out of becoming module docs
|
||||||
|
@ -587,7 +592,7 @@ def process_categories(plugin_info, categories, templates, output_dir, output_na
|
||||||
write_data(text, output_dir, category_filename)
|
write_data(text, output_dir, category_filename)
|
||||||
|
|
||||||
|
|
||||||
def process_support_levels(plugin_info, templates, output_dir, plugin_type):
|
def process_support_levels(plugin_info, categories, templates, output_dir, plugin_type):
|
||||||
supported_by = {'Ansible Core Team': {'slug': 'core_supported',
|
supported_by = {'Ansible Core Team': {'slug': 'core_supported',
|
||||||
'modules': [],
|
'modules': [],
|
||||||
'output': 'core_maintained.rst',
|
'output': 'core_maintained.rst',
|
||||||
|
@ -650,9 +655,24 @@ These modules are currently shipped with Ansible, but will most likely be shippe
|
||||||
else:
|
else:
|
||||||
raise AnsibleError('Unknown supported_by value: %s' % info['metadata']['supported_by'])
|
raise AnsibleError('Unknown supported_by value: %s' % info['metadata']['supported_by'])
|
||||||
|
|
||||||
# Render the module lists
|
# Render the module lists based on category and subcategory
|
||||||
for maintainers, data in supported_by.items():
|
for maintainers, data in supported_by.items():
|
||||||
|
subcategories = {}
|
||||||
|
subcategories[''] = {}
|
||||||
|
for module in data['modules']:
|
||||||
|
new_cat = plugin_info[module]['sub_category']
|
||||||
|
category = plugin_info[module]['primary_category']
|
||||||
|
if category not in subcategories:
|
||||||
|
subcategories[category] = {}
|
||||||
|
subcategories[category][''] = {}
|
||||||
|
subcategories[category]['']['_modules'] = []
|
||||||
|
if new_cat not in subcategories[category]:
|
||||||
|
subcategories[category][new_cat] = {}
|
||||||
|
subcategories[category][new_cat]['_modules'] = []
|
||||||
|
subcategories[category][new_cat]['_modules'].append(module)
|
||||||
|
|
||||||
template_data = {'maintainers': maintainers,
|
template_data = {'maintainers': maintainers,
|
||||||
|
'subcategories': subcategories,
|
||||||
'modules': data['modules'],
|
'modules': data['modules'],
|
||||||
'slug': data['slug'],
|
'slug': data['slug'],
|
||||||
'module_info': plugin_info,
|
'module_info': plugin_info,
|
||||||
|
@ -747,7 +767,7 @@ def main():
|
||||||
process_categories(plugin_info, categories, templates, output_dir, category_list_name_template, plugin_type)
|
process_categories(plugin_info, categories, templates, output_dir, category_list_name_template, plugin_type)
|
||||||
|
|
||||||
# Render all the categories for modules
|
# Render all the categories for modules
|
||||||
process_support_levels(plugin_info, templates, output_dir, plugin_type)
|
process_support_levels(plugin_info, categories, templates, output_dir, plugin_type)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
35
docs/templates/modules_by_support.rst.j2
vendored
35
docs/templates/modules_by_support.rst.j2
vendored
|
@ -3,14 +3,43 @@
|
||||||
{# avoids rST "isn't included in any toctree" errors for module index docs #}
|
{# avoids rST "isn't included in any toctree" errors for module index docs #}
|
||||||
:orphan:
|
:orphan:
|
||||||
|
|
||||||
|
**************************@{ '*' * maintainers | length }@
|
||||||
Modules Maintained by the @{ maintainers }@
|
Modules Maintained by the @{ maintainers }@
|
||||||
``````````````````````````@{ '`' * maintainers | length }@
|
**************************@{ '*' * maintainers | length }@
|
||||||
|
|
||||||
{% for module in modules | sort %}
|
.. contents::
|
||||||
|
:local:
|
||||||
|
|
||||||
|
{% for category, data in subcategories.items() | sort %}
|
||||||
|
|
||||||
|
{% if category.lower() %}
|
||||||
|
.. _@{ category.lower() + '_' + slug.lower() + '_categories' }@:
|
||||||
|
{% else %}
|
||||||
|
.. _@{ slug.lower() + '_categories' }@:
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
@{ category.title() }@
|
||||||
|
@{ '=' * category | length }@
|
||||||
|
|
||||||
|
{% for name, info in data.items() | sort %}
|
||||||
|
|
||||||
|
{% if name.lower() %}
|
||||||
|
.. _@{ name.lower() + '_' + category + '_' + slug.lower() + '_' + plugin_type + 's' }@:
|
||||||
|
{% else %}
|
||||||
|
.. _@{ slug.lower() + '_' + category }@:
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
@{ name.title() }@
|
||||||
|
@{ '-' * name | length }@
|
||||||
|
|
||||||
|
{% for module in info['_modules'] | sort %}
|
||||||
* :ref:`@{ module }@_@{plugin_type}@`{% if module_info[module]['deprecated'] %} **(D)** {% endif%}
|
* :ref:`@{ module }@_@{plugin_type}@`{% if module_info[module]['deprecated'] %} **(D)** {% endif%}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
- **(D)**: This marks a module as deprecated, which means a module is kept for backwards compatibility but usage is discouraged.
|
- **(D)**: This marks a module as deprecated, which means a module is kept for backwards compatibility but usage is discouraged.
|
||||||
The module documentation details page may explain more about this rationale.
|
The module documentation details page may explain more about this rationale.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue