docs: PEP8 compliance (#24681)

- Make PEP8 compliant
pull/25219/head
Dag Wieers 8 years ago committed by John R Barker
parent 44121352fe
commit 47738eb1dd

@ -18,7 +18,7 @@ import os
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('../bin')) # sys.path.insert(0, os.path.abspath('../bin'))
sys.path.insert(0, os.path.abspath('../lib/ansible')) sys.path.insert(0, os.path.abspath('../lib/ansible'))
import sphinx_rtd_theme import sphinx_rtd_theme
import alabaster import alabaster
@ -26,7 +26,7 @@ import alabaster
# -- General configuration ------------------------------------------------ # -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here. # If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0' # needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be # Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
@ -41,8 +41,8 @@ extensions = [
'alabaster', 'alabaster',
] ]
#autodoc_default_flags = ['members', 'show-inheritance', 'inherited-members', 'undoc-members',] # autodoc_default_flags = ['members', 'show-inheritance', 'inherited-members', 'undoc-members', ]
autodoc_default_flags = ['members', 'show-inheritance', 'undoc-members',] autodoc_default_flags = ['members', 'show-inheritance', 'undoc-members', ]
autoclass_content = 'both' autoclass_content = 'both'
autodoc_member_order = 'bysource' autodoc_member_order = 'bysource'
autodoc_mock_imports = ['xmltodict', 'winrm', 'redis', 'StricRedis'] autodoc_mock_imports = ['xmltodict', 'winrm', 'redis', 'StricRedis']
@ -56,7 +56,7 @@ templates_path = ['_templates']
source_suffix = '.rst' source_suffix = '.rst'
# The encoding of source files. # The encoding of source files.
#source_encoding = 'utf-8-sig' # source_encoding = 'utf-8-sig'
# The master toctree document. # The master toctree document.
master_doc = 'index' master_doc = 'index'
@ -84,9 +84,9 @@ language = None
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used:
#today = '' # today = ''
# Else, today_fmt is used as the format for a strftime call. # Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y' # today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
@ -94,27 +94,27 @@ exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all # The reST default role (used for this markup: `text`) to use for all
# documents. # documents.
#default_role = None # default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text. # If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = True add_function_parentheses = True
# If true, the current module name will be prepended to all description # If true, the current module name will be prepended to all description
# unit titles (such as .. function::). # unit titles (such as .. function::).
#add_module_names = True # add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the # If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default. # output. They are ignored by default.
#show_authors = False # show_authors = False
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx' pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting. # A list of ignored prefixes for module index sorting.
#modindex_common_prefix = [] # modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents. # If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False # keep_warnings = False
# If true, `todo` and `todoList` produce output, else they produce nothing. # If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True todo_include_todos = True
@ -124,13 +124,13 @@ todo_include_todos = True
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
#html_theme = 'alabaster' # html_theme = 'alabaster'
#html_theme_path = ['../docsite/_themes'] # html_theme_path = ['../docsite/_themes']
#html_theme = 'srtd' # html_theme = 'srtd'
html_short_title = 'Ansible Documentation' html_short_title = 'Ansible Documentation'
#html_theme = "sphinx_rtd_theme" # html_theme = "sphinx_rtd_theme"
#html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
html_theme_path = [alabaster.get_path()] html_theme_path = [alabaster.get_path()]
html_theme = 'alabaster' html_theme = 'alabaster'
@ -138,26 +138,26 @@ html_theme = 'alabaster'
# Theme options are theme-specific and customize the look and feel of a theme # Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the # further. For a list of options available for each theme, see the
# documentation. # documentation.
#html_theme_options = {} # html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory. # Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = [] # html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to # The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation". # "<project> v<release> documentation".
#html_title = None # html_title = None
# A shorter title for the navigation bar. Default is the same as html_title. # A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None # html_short_title = None
# The name of an image file (relative to this directory) to place at the top # The name of an image file (relative to this directory) to place at the top
# of the sidebar. # of the sidebar.
#html_logo = None # html_logo = None
# The name of an image file (relative to this directory) to use as a favicon of # The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large. # pixels large.
#html_favicon = None # html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
@ -167,62 +167,62 @@ html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or # Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied # .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation. # directly to the root of the documentation.
#html_extra_path = [] # html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format. # using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y' # html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to # If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities. # typographically correct entities.
#html_use_smartypants = True # html_use_smartypants = True
# Custom sidebar templates, maps document names to template names. # Custom sidebar templates, maps document names to template names.
#html_sidebars = {} # html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to # Additional templates that should be rendered to pages, maps page names to
# template names. # template names.
#html_additional_pages = {} # html_additional_pages = {}
# If false, no module index is generated. # If false, no module index is generated.
#html_domain_indices = True # html_domain_indices = True
# If false, no index is generated. # If false, no index is generated.
#html_use_index = True # html_use_index = True
# If true, the index is split into individual pages for each letter. # If true, the index is split into individual pages for each letter.
#html_split_index = False # html_split_index = False
# If true, links to the reST sources are added to the pages. # If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True # html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True # html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True # html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will # If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the # contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served. # base URL from which the finished HTML is served.
#html_use_opensearch = '' # html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml"). # This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None # html_file_suffix = None
# Language to be used for generating the HTML full-text search index. # Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages: # Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
#html_search_language = 'en' # html_search_language = 'en'
# A dictionary with options for the search language support, empty by default. # A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value # Now only 'ja' uses this config value
#html_search_options = {'type': 'default'} # html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that # The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used. # implements a search results scorer. If empty, the default will be used.
#html_search_scorer = 'scorer.js' # html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'Ansibledoc' htmlhelp_basename = 'Ansibledoc'
@ -231,16 +231,16 @@ htmlhelp_basename = 'Ansibledoc'
latex_elements = { latex_elements = {
# The paper size ('letterpaper' or 'a4paper'). # The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper', # 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt'). # The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt', # 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble. # Additional stuff for the LaTeX preamble.
#'preamble': '', # 'preamble': '',
# Latex figure (float) alignment # Latex figure (float) alignment
#'figure_align': 'htbp', # 'figure_align': 'htbp',
} }
# Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples
@ -253,23 +253,23 @@ latex_documents = [
# The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of
# the title page. # the title page.
#latex_logo = None # latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts, # For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters. # not chapters.
#latex_use_parts = False # latex_use_parts = False
# If true, show page references after internal links. # If true, show page references after internal links.
#latex_show_pagerefs = False # latex_show_pagerefs = False
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
#latex_show_urls = False # latex_show_urls = False
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.
#latex_appendices = [] # latex_appendices = []
# If false, no module index is generated. # If false, no module index is generated.
#latex_domain_indices = True # latex_domain_indices = True
# -- Options for manual page output --------------------------------------- # -- Options for manual page output ---------------------------------------
@ -282,7 +282,7 @@ man_pages = [
] ]
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
#man_show_urls = False # man_show_urls = False
# -- Options for Texinfo output ------------------------------------------- # -- Options for Texinfo output -------------------------------------------
@ -297,13 +297,13 @@ texinfo_documents = [
] ]
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.
#texinfo_appendices = [] # texinfo_appendices = []
# If false, no module index is generated. # If false, no module index is generated.
#texinfo_domain_indices = True # texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'. # How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote' # texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu. # If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False # texinfo_no_detailmenu = False

@ -13,7 +13,7 @@ from ansible.playbook.task import Task
template_file = 'playbooks_keywords.rst.j2' template_file = 'playbooks_keywords.rst.j2'
oblist = {} oblist = {}
clist = [] clist = []
class_list = [ Play, Role, Block, Task ] class_list = [Play, Role, Block, Task]
p = optparse.OptionParser( p = optparse.OptionParser(
version='%prog 1.0', version='%prog 1.0',
@ -62,8 +62,8 @@ for aclass in class_list:
env = Environment(loader=FileSystemLoader(options.template_dir), trim_blocks=True,) env = Environment(loader=FileSystemLoader(options.template_dir), trim_blocks=True,)
template = env.get_template(template_file) template = env.get_template(template_file)
outputname = options.output_dir + template_file.replace('.j2','') outputname = options.output_dir + template_file.replace('.j2', '')
tempvars = { 'oblist': oblist, 'clist': clist } tempvars = {'oblist': oblist, 'clist': clist}
with open( outputname, 'w') as f: with open(outputname, 'w') as f:
f.write(template.render(tempvars)) f.write(template.render(tempvars))

@ -16,22 +16,21 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
from __future__ import print_function from __future__ import print_function
__metaclass__ = type __metaclass__ = type
import os import cgi
import datetime
import glob import glob
import sys
import yaml
import re
import optparse import optparse
import datetime import os
import cgi import re
import sys
import warnings import warnings
from collections import defaultdict import yaml
from collections import defaultdict
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
from six import iteritems from six import iteritems
@ -47,12 +46,12 @@ from ansible.utils import plugin_docs
TO_OLD_TO_BE_NOTABLE = 1.3 TO_OLD_TO_BE_NOTABLE = 1.3
# Get parent directory of the directory this script lives in # Get parent directory of the directory this script lives in
MODULEDIR=os.path.abspath(os.path.join( MODULEDIR = os.path.abspath(os.path.join(
os.path.dirname(os.path.realpath(__file__)), os.pardir, 'lib', 'ansible', 'modules' os.path.dirname(os.path.realpath(__file__)), os.pardir, 'lib', 'ansible', 'modules'
)) ))
# The name of the DOCUMENTATION template # The name of the DOCUMENTATION template
EXAMPLE_YAML=os.path.abspath(os.path.join( EXAMPLE_YAML = os.path.abspath(os.path.join(
os.path.dirname(os.path.realpath(__file__)), os.pardir, 'examples', 'DOCUMENTATION.yml' os.path.dirname(os.path.realpath(__file__)), os.pardir, 'examples', 'DOCUMENTATION.yml'
)) ))
@ -63,7 +62,7 @@ _URL = re.compile(r"U\(([^)]+)\)")
_CONST = re.compile(r"C\(([^)]+)\)") _CONST = re.compile(r"C\(([^)]+)\)")
DEPRECATED = b" (D)" DEPRECATED = b" (D)"
#####################################################################################
def rst_ify(text): def rst_ify(text):
''' convert symbols like I(this is in italics) to valid restructured text ''' ''' convert symbols like I(this is in italics) to valid restructured text '''
@ -79,7 +78,6 @@ def rst_ify(text):
return t return t
#####################################################################################
def html_ify(text): def html_ify(text):
''' convert symbols like I(this is in italics) to valid HTML ''' ''' convert symbols like I(this is in italics) to valid HTML '''
@ -94,36 +92,30 @@ def html_ify(text):
return t return t
#####################################################################################
def rst_fmt(text, fmt): def rst_fmt(text, fmt):
''' helper for Jinja2 to do format strings ''' ''' helper for Jinja2 to do format strings '''
return fmt % (text) return fmt % (text)
#####################################################################################
def rst_xline(width, char="="): def rst_xline(width, char="="):
''' return a restructured text line of a given length ''' ''' return a restructured text line of a given length '''
return char * width return char * width
#####################################################################################
def write_data(text, options, outputname, module): def write_data(text, options, outputname, module):
''' dumps module output to a file or the screen, as requested ''' ''' dumps module output to a file or the screen, as requested '''
if options.output_dir is not None: if options.output_dir is not None:
fname = os.path.join(options.output_dir, outputname % module) fname = os.path.join(options.output_dir, outputname % module)
fname = fname.replace(".py","") fname = fname.replace(".py", "")
f = open(fname, 'wb') f = open(fname, 'wb')
f.write(to_bytes(text)) f.write(to_bytes(text))
f.close() f.close()
else: else:
print(text) print(text)
#####################################################################################
def list_modules(module_dir, depth=0): def list_modules(module_dir, depth=0):
''' returns a hash of categories, each category being a hash of module names to file paths ''' ''' returns a hash of categories, each category being a hash of module names to file paths '''
@ -163,7 +155,7 @@ def list_modules(module_dir, depth=0):
continue continue
if module.startswith("_") and os.path.islink(module_path): if module.startswith("_") and os.path.islink(module_path):
source = os.path.splitext(os.path.basename(os.path.realpath(module_path)))[0] source = os.path.splitext(os.path.basename(os.path.realpath(module_path)))[0]
module = module.replace("_","",1) module = module.replace("_", "", 1)
aliases[source].add(module) aliases[source].add(module)
continue continue
@ -176,7 +168,6 @@ def list_modules(module_dir, depth=0):
return module_info, categories, aliases return module_info, categories, aliases
#####################################################################################
def generate_parser(): def generate_parser():
''' generate an optparse parser ''' ''' generate an optparse parser '''
@ -197,15 +188,13 @@ def generate_parser():
p.add_option('-V', action='version', help='Show version number and exit') p.add_option('-V', action='version', help='Show version number and exit')
return p return p
#####################################################################################
def jinja2_environment(template_dir, typ): def jinja2_environment(template_dir, typ):
env = Environment(loader=FileSystemLoader(template_dir), env = Environment(loader=FileSystemLoader(template_dir),
variable_start_string="@{", variable_start_string="@{",
variable_end_string="}@", variable_end_string="}@",
trim_blocks=True, trim_blocks=True)
)
env.globals['xline'] = rst_xline env.globals['xline'] = rst_xline
if typ == 'rst': if typ == 'rst':
@ -220,7 +209,7 @@ def jinja2_environment(template_dir, typ):
return env, template, outputname return env, template, outputname
#####################################################################################
def too_old(added): def too_old(added):
if not added: if not added:
return False return False
@ -233,6 +222,7 @@ def too_old(added):
return False return False
return (added_float < TO_OLD_TO_BE_NOTABLE) return (added_float < TO_OLD_TO_BE_NOTABLE)
def process_module(module, options, env, template, outputname, module_map, aliases): def process_module(module, options, env, template, outputname, module_map, aliases):
fname = module_map[module] fname = module_map[module]
@ -249,7 +239,7 @@ def process_module(module, options, env, template, outputname, module_map, alias
if os.path.islink(fname): if os.path.islink(fname):
return # ignore, its an alias return # ignore, its an alias
deprecated = True deprecated = True
module = module.replace("_","",1) module = module.replace("_", "", 1)
print("rendering: %s" % module) print("rendering: %s" % module)
@ -271,7 +261,7 @@ def process_module(module, options, env, template, outputname, module_map, alias
all_keys = [] all_keys = []
if not 'version_added' in doc: if 'version_added' not in doc:
sys.exit("*** ERROR: missing version_added in: %s ***\n" % module) sys.exit("*** ERROR: missing version_added in: %s ***\n" % module)
added = 0 added = 0
@ -285,17 +275,17 @@ def process_module(module, options, env, template, outputname, module_map, alias
del doc['version_added'] del doc['version_added']
if 'options' in doc and doc['options']: if 'options' in doc and doc['options']:
for (k,v) in iteritems(doc['options']): for (k, v) in iteritems(doc['options']):
# don't show version added information if it's too old to be called out # don't show version added information if it's too old to be called out
if 'version_added' in doc['options'][k] and too_old(doc['options'][k]['version_added']): if 'version_added' in doc['options'][k] and too_old(doc['options'][k]['version_added']):
del doc['options'][k]['version_added'] del doc['options'][k]['version_added']
if not 'description' in doc['options'][k]: if 'description' not in doc['options'][k]:
raise AnsibleError("Missing required description for option %s in %s " % (k, module)) raise AnsibleError("Missing required description for option %s in %s " % (k, module))
required_value = doc['options'][k].get('required', False) required_value = doc['options'][k].get('required', False)
if not isinstance(required_value, bool): if not isinstance(required_value, bool):
raise AnsibleError("Invalid required value '%s' for option '%s' in '%s' (must be truthy)" % (required_value, k, module)) raise AnsibleError("Invalid required value '%s' for option '%s' in '%s' (must be truthy)" % (required_value, k, module))
if not isinstance(doc['options'][k]['description'],list): if not isinstance(doc['options'][k]['description'], list):
doc['options'][k]['description'] = [doc['options'][k]['description']] doc['options'][k]['description'] = [doc['options'][k]['description']]
all_keys.append(k) all_keys.append(k)
@ -307,7 +297,7 @@ def process_module(module, options, env, template, outputname, module_map, alias
doc['docuri'] = doc['module'].replace('_', '-') doc['docuri'] = doc['module'].replace('_', '-')
doc['now_date'] = datetime.date.today().strftime('%Y-%m-%d') doc['now_date'] = datetime.date.today().strftime('%Y-%m-%d')
doc['ansible_version'] = options.ansible_version doc['ansible_version'] = options.ansible_version
doc['plainexamples'] = examples #plain text doc['plainexamples'] = examples # plain text
doc['metadata'] = metadata doc['metadata'] = metadata
if returndocs: if returndocs:
@ -328,7 +318,6 @@ def process_module(module, options, env, template, outputname, module_map, alias
write_data(text, options, outputname, module) write_data(text, options, outputname, module)
return doc['short_description'] return doc['short_description']
#####################################################################################
def print_modules(module, category_file, deprecated, options, env, template, outputname, module_map, aliases): def print_modules(module, category_file, deprecated, options, env, template, outputname, module_map, aliases):
modstring = module modstring = module
@ -340,9 +329,10 @@ def print_modules(module, category_file, deprecated, options, env, template, out
category_file.write(b" %s - %s <%s_module>\n" % (to_bytes(modstring), to_bytes(rst_ify(module_map[module][1])), to_bytes(modname))) category_file.write(b" %s - %s <%s_module>\n" % (to_bytes(modstring), to_bytes(rst_ify(module_map[module][1])), to_bytes(modname)))
def process_category(category, categories, options, env, template, outputname): def process_category(category, categories, options, env, template, outputname):
### FIXME: # FIXME:
# We no longer conceptually deal with a mapping of category names to # We no longer conceptually deal with a mapping of category names to
# modules to file paths. Instead we want several different records: # modules to file paths. Instead we want several different records:
# (1) Mapping of module names to file paths (what's presently used # (1) Mapping of module names to file paths (what's presently used
@ -367,7 +357,7 @@ def process_category(category, categories, options, env, template, outputname):
# start a new category file # start a new category file
category = category.replace("_"," ") category = category.replace("_", " ")
category = category.title() category = category.title()
modules = [] modules = []
@ -406,12 +396,12 @@ def process_category(category, categories, options, env, template, outputname):
sections.sort() sections.sort()
for section in sections: for section in sections:
category_file.write(b"\n%s\n%s\n\n" % (to_bytes(section.replace("_"," ").title()), b'-' * len(section))) category_file.write(b"\n%s\n%s\n\n" % (to_bytes(section.replace("_", " ").title()), b'-' * len(section)))
category_file.write(b".. toctree:: :maxdepth: 1\n\n") category_file.write(b".. toctree:: :maxdepth: 1\n\n")
section_modules = list(module_map[section].keys()) section_modules = list(module_map[section].keys())
section_modules.sort(key=lambda k: k[1:] if k.startswith('_') else k) section_modules.sort(key=lambda k: k[1:] if k.startswith('_') else k)
#for module in module_map[section]: # for module in module_map[section]:
for module in (m for m in section_modules if m in module_info): for module in (m for m in section_modules if m in module_info):
print_modules(module, category_file, deprecated, options, env, template, outputname, module_info, aliases) print_modules(module, category_file, deprecated, options, env, template, outputname, module_info, aliases)
@ -424,7 +414,6 @@ def process_category(category, categories, options, env, template, outputname):
# TODO: end a new category file # TODO: end a new category file
#####################################################################################
def validate_options(options): def validate_options(options):
''' validate option parser options ''' ''' validate option parser options '''
@ -436,7 +425,6 @@ def validate_options(options):
if not options.template_dir: if not options.template_dir:
sys.exit("--template-dir must be specified") sys.exit("--template-dir must be specified")
#####################################################################################
def main(): def main():
@ -465,9 +453,7 @@ def main():
for category in category_names: for category in category_names:
category_list_file.write(b" list_of_%s_modules\n" % to_bytes(category)) category_list_file.write(b" list_of_%s_modules\n" % to_bytes(category))
#
# Import all the docs into memory # Import all the docs into memory
#
module_map = mod_info.copy() module_map = mod_info.copy()
for modname in module_map: for modname in module_map:
@ -477,11 +463,10 @@ def main():
else: else:
categories['all'][modname] = (categories['all'][modname], result) categories['all'][modname] = (categories['all'][modname], result)
#
# Render all the docs to rst via category pages # Render all the docs to rst via category pages
#
for category in category_names: for category in category_names:
process_category(category, categories, options, env, template, outputname) process_category(category, categories, options, env, template, outputname)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

@ -17,13 +17,13 @@ import sys
import os import os
# pip install sphinx_rtd_theme # pip install sphinx_rtd_theme
#import sphinx_rtd_theme # import sphinx_rtd_theme
#html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
# If your extensions are in another directory, add it here. If the directory # If your extensions are in another directory, add it here. If the directory
# is relative to the documentation root, use os.path.abspath to make it # is relative to the documentation root, use os.path.abspath to make it
# absolute, like shown here. # absolute, like shown here.
#sys.path.append(os.path.abspath('some/directory')) # sys.path.append(os.path.abspath('some/directory'))
# #
sys.path.insert(0, os.path.join('ansible', 'lib')) sys.path.insert(0, os.path.join('ansible', 'lib'))
sys.path.append(os.path.abspath('_themes')) sys.path.append(os.path.abspath('_themes'))
@ -67,16 +67,16 @@ release = VERSION
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used:
#today = '' # today = ''
# Else, today_fmt is used as the format for a strftime call. # Else, today_fmt is used as the format for a strftime call.
today_fmt = '%B %d, %Y' today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build. # List of documents that shouldn't be included in the build.
#unused_docs = [] # unused_docs = []
# List of directories, relative to source directories, that shouldn't be # List of directories, relative to source directories, that shouldn't be
# searched for source files. # searched for source files.
#exclude_dirs = [] # exclude_dirs = []
# A list of glob-style patterns that should be excluded when looking # A list of glob-style patterns that should be excluded when looking
# for source files. # for source files.
@ -84,26 +84,26 @@ exclude_patterns = ['modules']
# The reST default role (used for this markup: `text`) to use for all # The reST default role (used for this markup: `text`) to use for all
# documents. # documents.
#default_role = None # default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text. # If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True # add_function_parentheses = True
# If true, the current module name will be prepended to all description # If true, the current module name will be prepended to all description
# unit titles (such as .. function::). # unit titles (such as .. function::).
#add_module_names = True # add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the # If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default. # output. They are ignored by default.
#show_authors = False # show_authors = False
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx' pygments_style = 'sphinx'
highlight_language = 'YAML+Jinja' highlight_language = 'YAML+Jinja'
#Substitutions, variables, entities, & shortcuts for text which do not need to link to anything. # Substitutions, variables, entities, & shortcuts for text which do not need to link to anything.
#For titles which should be a link, use the intersphinx anchors set at the index, chapter, and section levels, such as qi_start_: # For titles which should be a link, use the intersphinx anchors set at the index, chapter, and section levels, such as qi_start_:
rst_epilog = """ rst_epilog = """
.. |acapi| replace:: *Ansible Core API Guide* .. |acapi| replace:: *Ansible Core API Guide*
.. |acrn| replace:: *Ansible Core Release Notes* .. |acrn| replace:: *Ansible Core Release Notes*
@ -128,28 +128,28 @@ html_short_title = 'Ansible Documentation'
# The style sheet to use for HTML and HTML Help pages. A file of that name # The style sheet to use for HTML and HTML Help pages. A file of that name
# must exist either in Sphinx' static/ path, or in one of the custom paths # must exist either in Sphinx' static/ path, or in one of the custom paths
# given in html_static_path. # given in html_static_path.
#html_style = 'solar.css' # html_style = 'solar.css'
# The name for this set of Sphinx documents. If None, it defaults to # The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation". # "<project> v<release> documentation".
html_title = 'Ansible Documentation' html_title = 'Ansible Documentation'
# A shorter title for the navigation bar. Default is the same as html_title. # A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None # html_short_title = None
# The name of an image file (within the static path) to place at the top of # The name of an image file (within the static path) to place at the top of
# the sidebar. # the sidebar.
#html_logo = None # html_logo = None
# The name of an image file (within the static path) to use as favicon of the # The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large. # pixels large.
#html_favicon = 'favicon.ico' # html_favicon = 'favicon.ico'
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
#html_static_path = ['.static'] # html_static_path = ['.static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format. # using the given strftime format.
@ -157,23 +157,23 @@ html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to # If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities. # typographically correct entities.
#html_use_smartypants = True # html_use_smartypants = True
# Custom sidebar templates, maps document names to template names. # Custom sidebar templates, maps document names to template names.
#html_sidebars = {} # html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to # Additional templates that should be rendered to pages, maps page names to
# template names. # template names.
#html_additional_pages = {} # html_additional_pages = {}
# If false, no module index is generated. # If false, no module index is generated.
#html_use_modindex = True # html_use_modindex = True
# If false, no index is generated. # If false, no index is generated.
#html_use_index = True # html_use_index = True
# If true, the index is split into individual pages for each letter. # If true, the index is split into individual pages for each letter.
#html_split_index = False # html_split_index = False
# If true, the reST sources are included in the HTML build as _sources/<name>. # If true, the reST sources are included in the HTML build as _sources/<name>.
html_copy_source = False html_copy_source = False
@ -181,10 +181,10 @@ html_copy_source = False
# If true, an OpenSearch description file will be output, and all pages will # If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the # contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served. # base URL from which the finished HTML is served.
#html_use_opensearch = '' # html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = '' # html_file_suffix = ''
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'Poseidodoc' htmlhelp_basename = 'Poseidodoc'
@ -194,10 +194,10 @@ htmlhelp_basename = 'Poseidodoc'
# ------------------------ # ------------------------
# The paper size ('letter' or 'a4'). # The paper size ('letter' or 'a4').
#latex_paper_size = 'letter' # latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt'). # The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt' # latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, document class # (source start file, target name, title, author, document class
@ -208,20 +208,20 @@ latex_documents = [
# The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of
# the title page. # the title page.
#latex_logo = None # latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts, # For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters. # not chapters.
#latex_use_parts = False # latex_use_parts = False
# Additional stuff for the LaTeX preamble. # Additional stuff for the LaTeX preamble.
#latex_preamble = '' # latex_preamble = ''
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.
#latex_appendices = [] # latex_appendices = []
# If false, no module index is generated. # If false, no module index is generated.
#latex_use_modindex = True # latex_use_modindex = True
autoclass_content = 'both' autoclass_content = 'both'

@ -1,11 +1,6 @@
contrib/inventory/freeipa.py contrib/inventory/freeipa.py
contrib/inventory/rackhd.py contrib/inventory/rackhd.py
contrib/inventory/vmware_inventory.py contrib/inventory/vmware_inventory.py
docs/api/conf.py
docs/bin/dump_keywords.py
docs/bin/plugin_formatter.py
docs/docsite/rst/conf.py
docs/docsite/rst/intro_inventory.rst
lib/ansible/cli/__init__.py lib/ansible/cli/__init__.py
lib/ansible/cli/adhoc.py lib/ansible/cli/adhoc.py
lib/ansible/cli/console.py lib/ansible/cli/console.py

Loading…
Cancel
Save