Skip to content
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

ansible-galaxy: add collection sub command #57106

Merged
merged 23 commits into from Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
00339d7
ansible-galaxy: add collection init sub command
jborean93 May 29, 2019
84b08c4
Fix changelog and other sanity issues
jborean93 May 29, 2019
b9ecb81
Slim down skeleton structure, fix encoding issue on template
jborean93 May 29, 2019
20a6cfc
Fix doc generation code to include sub commands
jborean93 Jun 4, 2019
b60c607
Added build step
jborean93 Jun 5, 2019
b61b30e
Tidy up the build action
jborean93 Jun 6, 2019
cd524ca
Fixed up doc changes and slight testing tweaks
jborean93 Jun 11, 2019
0051a1e
Re-organise tests to use pytest
jborean93 Jun 11, 2019
ad057a8
Added publish step and fixed up issues after working with Galaxy
jborean93 Jun 12, 2019
648a252
Unit test improvments
jborean93 Jun 16, 2019
9d35e5d
Fix unit test on 3.5
jborean93 Jun 16, 2019
59233d5
Add remaining build tests
jborean93 Jun 17, 2019
6839ff5
Test fixes, make the integration tests clearer to debug on failures
jborean93 Jun 17, 2019
2380513
Removed unicode name tests until I've got further clarification
jborean93 Jun 17, 2019
343e9ae
Added publish unit tests
jborean93 Jun 18, 2019
596710a
Change expected length value
jborean93 Jun 18, 2019
d3d33dd
Added collection install steps, tests forthcoming
jborean93 Jun 19, 2019
acced77
Added unit tests for collection install entrypoint
jborean93 Jun 25, 2019
ccab32f
Added some more tests for collection install
jborean93 Jun 26, 2019
bf2224e
follow proper encoding rules and added more tests
jborean93 Jun 27, 2019
89ac465
Add remaining tests
jborean93 Jun 27, 2019
1cb1edb
tidied up tests and code based on review
jborean93 Jun 28, 2019
d5577e4
exclude pre-release versions from galaxy API
jborean93 Jul 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/galaxy-collection-init.yaml
@@ -0,0 +1,3 @@
minor_changes:
- ansible-galaxy - Add ``collection init`` command to create a skeleton Collections directory.
- ansible-galaxy - Add ``collection build`` command to build a Collection tarball ready for uploading.
jborean93 marked this conversation as resolved.
Show resolved Hide resolved
71 changes: 42 additions & 29 deletions docs/bin/generate_man.py
Expand Up @@ -132,6 +132,7 @@ def opts_docs(cli_class_name, cli_module_name):
'short_desc': cli.parser.description,
'long_desc': trim_docstring(cli.__doc__),
'actions': {},
'content_depth': 2,
}
option_info = {'option_names': [],
'options': [],
Expand All @@ -157,44 +158,56 @@ def opts_docs(cli_class_name, cli_module_name):
# now for each action/subcommand
# force populate parser with per action options

# use class attrs not the attrs on a instance (not that it matters here...)
try:
subparser = cli.parser._subparsers._group_actions[0].choices
except AttributeError:
subparser = {}
for action, parser in subparser.items():
action_info = {'option_names': [],
'options': []}
# docs['actions'][action] = {}
# docs['actions'][action]['name'] = action
action_info['name'] = action
action_info['desc'] = trim_docstring(getattr(cli, 'execute_%s' % action).__doc__)
def get_actions(parser, docs):
# use class attrs not the attrs on a instance (not that it matters here...)
try:
subparser = parser._subparsers._group_actions[0].choices
except AttributeError:
subparser = {}

depth = 0

for action, parser in subparser.items():
action_info = {'option_names': [],
'options': [],
'actions': {}}
# docs['actions'][action] = {}
# docs['actions'][action]['name'] = action
action_info['name'] = action
action_info['desc'] = trim_docstring(getattr(cli, 'execute_%s' % action).__doc__)

# docs['actions'][action]['desc'] = getattr(cli, 'execute_%s' % action).__doc__.strip()
action_doc_list = opt_doc_list(parser)

uncommon_options = []
for action_doc in action_doc_list:
# uncommon_options = []

option_aliases = action_doc.get('options', [])
for option_alias in option_aliases:

# docs['actions'][action]['desc'] = getattr(cli, 'execute_%s' % action).__doc__.strip()
action_doc_list = opt_doc_list(parser)
if option_alias in shared_opt_names:
continue

uncommon_options = []
for action_doc in action_doc_list:
# uncommon_options = []
# TODO: use set
if option_alias not in action_info['option_names']:
action_info['option_names'].append(option_alias)

option_aliases = action_doc.get('options', [])
for option_alias in option_aliases:
if action_doc in action_info['options']:
continue

if option_alias in shared_opt_names:
continue
uncommon_options.append(action_doc)

# TODO: use set
if option_alias not in action_info['option_names']:
action_info['option_names'].append(option_alias)
action_info['options'] = uncommon_options

if action_doc in action_info['options']:
continue
depth = 1 + get_actions(parser, action_info)

uncommon_options.append(action_doc)
docs['actions'][action] = action_info

action_info['options'] = uncommon_options
return depth

docs['actions'][action] = action_info
action_depth = get_actions(cli.parser, docs)
docs['content_depth'] = action_depth + 1

docs['options'] = opt_doc_list(cli.parser)
return docs
Expand Down
25 changes: 24 additions & 1 deletion docs/templates/cli_rst.j2
Expand Up @@ -14,7 +14,7 @@

.. contents::
:local:
:depth: 2
:depth: {{content_depth}}


.. program:: {{cli_name}}
Expand Down Expand Up @@ -84,6 +84,29 @@ Actions
{% endfor %}
{% endif %}

{% for sub_action in actions[action]['actions'] %}


.. program:: {{cli_name}} {{action}} {{sub_action}}
.. _{{cli_name|replace('-','_')}}_{{action}}_{{sub_action}}:

{{ action + " " + sub_action }}
{{ '+' * (action|length + sub_action|length + 1) }}

{{ (actions[action]['actions'][sub_action]['desc']|default(' '))}}

{% if actions[action]['actions'][sub_action]['options'] %}


{% for option in actions[action]['actions'][sub_action]['options']|sort(attribute='options') %}
.. option:: {% for switch in option['options'] if switch in actions[action]['actions'][sub_action]['option_names'] %}{{switch}} {% if option['arg'] %} <{{option['arg']}}>{% endif %}{% if not loop.last %}, {% endif %}{% endfor %}

{{ (option['desc']) }}
{% endfor %}
{% endif %}

{% endfor %}

{% endfor %}
.. program:: {{cli_name}}
{% endif %}
Expand Down