mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
better handling for weird doc corner cases (abscense of options, bad text objects, etc)
also updated extras to get some docfixes on the module side
This commit is contained in:
parent
0d7d22d530
commit
a78fdde32c
2 changed files with 18 additions and 9 deletions
|
@ -36,6 +36,7 @@ from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
from ansible.utils import module_docs
|
from ansible.utils import module_docs
|
||||||
from ansible.utils.vars import merge_hash
|
from ansible.utils.vars import merge_hash
|
||||||
|
from ansible.errors import AnsibleError
|
||||||
|
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
# constants and paths
|
# constants and paths
|
||||||
|
@ -67,11 +68,14 @@ NOTCORE = " (E)"
|
||||||
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 '''
|
||||||
|
|
||||||
t = _ITALIC.sub(r'*' + r"\1" + r"*", text)
|
try:
|
||||||
t = _BOLD.sub(r'**' + r"\1" + r"**", t)
|
t = _ITALIC.sub(r'*' + r"\1" + r"*", text)
|
||||||
t = _MODULE.sub(r':ref:`' + r"\1 <\1>" + r"`", t)
|
t = _BOLD.sub(r'**' + r"\1" + r"**", t)
|
||||||
t = _URL.sub(r"\1", t)
|
t = _MODULE.sub(r':ref:`' + r"\1 <\1>" + r"`", t)
|
||||||
t = _CONST.sub(r'``' + r"\1" + r"``", t)
|
t = _URL.sub(r"\1", t)
|
||||||
|
t = _CONST.sub(r'``' + r"\1" + r"``", t)
|
||||||
|
except Exception as e:
|
||||||
|
raise AnsibleError("Could not process (%s) : %s" % (str(text), str(e)))
|
||||||
|
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
@ -286,7 +290,7 @@ def process_module(module, options, env, template, outputname, module_map, alias
|
||||||
if too_old(added):
|
if too_old(added):
|
||||||
del doc['version_added']
|
del doc['version_added']
|
||||||
|
|
||||||
if 'options' in doc:
|
if 'options' in doc and doc['options']:
|
||||||
for (k,v) in doc['options'].iteritems():
|
for (k,v) in doc['options'].iteritems():
|
||||||
# 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']):
|
||||||
|
@ -308,7 +312,12 @@ def process_module(module, options, env, template, outputname, module_map, alias
|
||||||
|
|
||||||
# here is where we build the table of contents...
|
# here is where we build the table of contents...
|
||||||
|
|
||||||
text = template.render(doc)
|
try:
|
||||||
|
import q
|
||||||
|
q(doc)
|
||||||
|
text = template.render(doc)
|
||||||
|
except Exception as e:
|
||||||
|
raise AnsibleError("Failed to render doc for %s: %s" % (fname, str(e)))
|
||||||
write_data(text, options, outputname, module)
|
write_data(text, options, outputname, module)
|
||||||
return doc['short_description']
|
return doc['short_description']
|
||||||
|
|
||||||
|
@ -326,7 +335,7 @@ def print_modules(module, category_file, deprecated, core, options, env, templat
|
||||||
result = process_module(modname, options, env, template, outputname, module_map, aliases)
|
result = process_module(modname, options, env, template, outputname, module_map, aliases)
|
||||||
|
|
||||||
if result != "SKIPPED":
|
if result != "SKIPPED":
|
||||||
category_file.write(" %s - %s <%s_module>\n" % (modstring, result, module))
|
category_file.write(" %s - %s <%s_module>\n" % (modstring, rst_ify(result), module))
|
||||||
|
|
||||||
def process_category(category, categories, options, env, template, outputname):
|
def process_category(category, categories, options, env, template, outputname):
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1d06ee6e2d6da6de158c538cf451aa075384c450
|
Subproject commit e30d8b84fe7ff3be427a46ff67629cce55252594
|
Loading…
Reference in a new issue