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

Enable documentation in plugins #22796

Merged
merged 4 commits into from
Mar 23, 2017
Merged

Enable documentation in plugins #22796

merged 4 commits into from
Mar 23, 2017

Conversation

bcoca
Copy link
Member

@bcoca bcoca commented Mar 20, 2017

SUMMARY

Made ansible-doc more plugin agnostic
We can have docs in lookup, callback, connectionm strategy, etc
Use first docstring and make pepizis happy
generalized module_docs to plugin_docs
documented cartesian, ssh, default, jsonfile, etc as examples
fixes #12089

ISSUE TYPE
  • Feature Pull Request
  • Docs Pull Request
COMPONENT NAME

plugins

ANSIBLE VERSION
2.4
ADDITIONAL INFORMATION

TODO:

  • actually document all plugins in supported types, cannot use list until this is done (should list skip undoc?)
  • figure out how to integrate with website (probably similar to modules but in subsections)
  • figure out format for test/filters as they have multiple per file
  • figure out module_utils as these are really 'api for modules'
  • vars/inventory?
  • better definition of config (have 'file config/keyword/env var/inventory var' "aliases")
  • examples/return fields might need to be more format 'tolerant'
  • action plugins? these now are documented via the module files

@ansibot ansibot added WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. affects_2.4 This issue/PR affects Ansible v2.4 c:cli/console c:cli/doc c:plugins/cache c:plugins/callback c:plugins/connection/ssh c:plugins/lookup c:plugins/strategy needs_triage Needs a first human triage before being processed. labels Mar 20, 2017
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Mar 20, 2017
Copy link
Contributor

@gundalow gundalow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
Consist used of capital letters and full stops on the descriptions would be nice to make everything consistent.

description:
- a set of lists
required: True
EXAMPLES:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multi line yaml with key: value

Is the indentation correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how not so? just needs to be consistent, it can be 0,1... N spaces, i use 4

DOCUMENTATION:
author:
- Jan-Piet Mens (@jpmens)
lookup: etc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

etcd

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will fix, concentrating more on 'method' than actual docs right now


# modules that are ok that they do not have documentation strings
BLACKLIST_MODULES = frozenset((
'async_wrapper',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we docs for this, or is this one of those fake modules?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its 'fake module' but we can add docs, we do intend to make it 'full module'

'doc': None,
'plainexamples': None,
'returndocs': None,
'metadata': {'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'community'},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need default metadata? I wonder if in the future we can use CI to ensure this is present in all files, not just modules.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we plan to have 'community' plugins that are not core, so yes

@bcoca
Copy link
Member Author

bcoca commented Mar 20, 2017

consider taht most docs in the plugins are 'example' they are not full/correct, but a starting point


bkey = plugin_type.upper()
if bkey in plugin_docs.BLACKLIST and plugin in plugin_docs.BLACKLIST[bkey]:
self.args = self.args - plugin_docs.BLACKLIST[bkey]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably what you want to do is move the call to sorted(self.args) from line 111 to line 116.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

self.args = sorted(set(self.plugin_list))

bkey = plugin_type.upper()
if bkey in plugin_docs.BLACKLIST and plugin in plugin_docs.BLACKLIST[bkey]:
Copy link
Contributor

@abadger abadger Mar 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simpler to write: if plugin in plugin_docs.BLACKLIST.get(bkey, frozenset()):

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Just saw that this pattern happens in other places too.. ou can simplify everywhere that it occurs).

@bcoca bcoca changed the title [WIP] Enable documentation in plugins Enable documentation in plugins Mar 21, 2017
@bcoca bcoca removed the WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. label Mar 21, 2017

bkey = plugin_type.upper()
if plugin in plugin_docs.BLACKLIST.get(bkey, ()):
self.args = sorted(self.args) - plugin_docs.BLACKLIST[bkey]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually... this is what I meant:

    self.find_plugins(path)
self.args = set(self.plugin_list)

bkey = plugin_type.upper()
if plugin in plugin_docs.BLACKLIST.get(bkey, frozenset()):
    self.args = self.args - plugin_docs.BLACKLIST[bkey]
self.args = sorted(self.args)

self.find_plugins(path)

bkey = plugin_type.upper()
if plugin in plugin_docs.BLACKLIST.get(bkey, ()):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think plugin is defined at this point in the method.

@bcoca bcoca force-pushed the plugin_docs branch 2 times, most recently from 0c9f563 to c722f21 Compare March 22, 2017 00:48
@ansibot
Copy link
Contributor

ansibot commented Mar 22, 2017

The test ansible-test sanity --test pep8 failed with the following errors:

lib/ansible/cli/doc.py:319:161: E501 line too long (173 > 160 characters)
lib/ansible/plugins/connection/ssh.py:33:23: W291 trailing whitespace
lib/ansible/plugins/connection/ssh.py:51:112: W291 trailing whitespace

click here for bot help

@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Mar 22, 2017
Made ansible-doc more plugin agnostic
We can have docs in lookup, callback, connectionm strategy, etc
Use first docstring and make pepizis happy
generalized module_docs to plugin_docs
documented cartesian, ssh, default, jsonfile, etc as examples
changed lack of docs to warning when listing
made smarter about bad docstrings
better blacklisting
added handling of options/config/envs/etc
move blacklist to find_plugins, only need once
@ansibot
Copy link
Contributor

ansibot commented Mar 22, 2017

The test ansible-test sanity --test pep8 failed with the following error:

lib/ansible/plugins/connection/ssh.py:32:23: W291 trailing whitespace

click here for bot help

@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Mar 22, 2017
@ansibot
Copy link
Contributor

ansibot commented Mar 22, 2017

@ansibot ansibot added docs_pull_request needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Mar 22, 2017
@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Mar 23, 2017
@bcoca bcoca merged commit 91a385b into ansible:devel Mar 23, 2017
@bcoca bcoca deleted the plugin_docs branch March 23, 2017 05:27
@ansibot ansibot added docs This issue/PR relates to or includes documentation. feature This issue/PR relates to a feature request. and removed docs_pull_request labels Mar 4, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 c:cli/console c:plugins/cache c:plugins/callback c:plugins/connection/local c:plugins/connection/ssh c:plugins/lookup c:plugins/strategy docs This issue/PR relates to or includes documentation. feature This issue/PR relates to a feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

autodocument all plugins
4 participants