ansible-doc: avoid problems with YAML anchors when formatting man page (#70045)
* Avoid problems with YAML anchors when formatting man page. * Add changelog.
This commit is contained in:
parent
74bedab8a9
commit
5e4f708241
2 changed files with 8 additions and 2 deletions
2
changelogs/fragments/70045-ansible-doc-yaml-anchors.yml
Normal file
2
changelogs/fragments/70045-ansible-doc-yaml-anchors.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- "ansible-doc - improve man page formatting to avoid problems when YAML anchors are used (https://github.com/ansible/ansible/pull/70045)."
|
|
@ -513,7 +513,8 @@ class DocCLI(CLI):
|
|||
def add_fields(text, fields, limit, opt_indent, return_values=False, base_indent=''):
|
||||
|
||||
for o in sorted(fields):
|
||||
opt = fields[o]
|
||||
# Create a copy so we don't modify the original (in case YAML anchors have been used)
|
||||
opt = dict(fields[o])
|
||||
|
||||
required = opt.pop('required', False)
|
||||
if not isinstance(required, bool):
|
||||
|
@ -562,7 +563,8 @@ class DocCLI(CLI):
|
|||
conf = {}
|
||||
for config in ('env', 'ini', 'yaml', 'vars', 'keywords'):
|
||||
if config in opt and opt[config]:
|
||||
conf[config] = opt.pop(config)
|
||||
# Create a copy so we don't modify the original (in case YAML anchors have been used)
|
||||
conf[config] = [dict(item) for item in opt.pop(config)]
|
||||
for ignore in DocCLI.IGNORE:
|
||||
for item in conf[config]:
|
||||
if ignore in item:
|
||||
|
@ -593,6 +595,8 @@ class DocCLI(CLI):
|
|||
|
||||
@staticmethod
|
||||
def get_man_text(doc):
|
||||
# Create a copy so we don't modify the original
|
||||
doc = dict(doc)
|
||||
|
||||
DocCLI.IGNORE = DocCLI.IGNORE + (context.CLIARGS['type'],)
|
||||
opt_indent = " "
|
||||
|
|
Loading…
Reference in a new issue