mirror of https://github.com/ansible/ansible.git
Update ansible doc formats (#71070)
* Fix tty_ify bugs and refactor * Move tty_ify() and supporting attributes to the DocCLI class as that's the only thing using it. * Add unittest for the code. * Fix a bug where the substitution macros can be detected when they are a part of another word. * Add support for L(), R(), and HORIZONTALLINE which were added to the website docs many years ago. * Update test/units/cli/test_doc.py Co-authored-by: Matt Clay <matt@mystile.com> Co-authored-by: Matt Clay <matt@mystile.com>pull/71113/head
parent
662d34b9a7
commit
fb144c4414
@ -0,0 +1,7 @@
|
||||
minor_changes:
|
||||
- ansible-doc will now format, ``L()``, ``R()``, and ``HORIZONTALLINE`` in
|
||||
plugin docs just as the website docs do. https://github.com/ansible/ansible/pull/71070
|
||||
- Fixed ansible-doc to not substitute for words followed by parenthesis. For
|
||||
instance, ``IBM(International Business Machines)`` will no longer be
|
||||
substituted with a link to a non-existent module.
|
||||
https://github.com/ansible/ansible/pull/71070
|
@ -0,0 +1,35 @@
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import pytest
|
||||
|
||||
from ansible.cli.doc import DocCLI
|
||||
|
||||
|
||||
TTY_IFY_DATA = {
|
||||
# No substitutions
|
||||
'no-op': 'no-op',
|
||||
'no-op Z(test)': 'no-op Z(test)',
|
||||
# Simple cases of all substitutions
|
||||
'I(italic)': "`italic'",
|
||||
'B(bold)': '*bold*',
|
||||
'M(ansible.builtin.module)': '[ansible.builtin.module]',
|
||||
'U(https://docs.ansible.com)': 'https://docs.ansible.com',
|
||||
'L(the user guide,https://docs.ansible.com/user-guide.html)': 'the user guide <https://docs.ansible.com/user-guide.html>',
|
||||
'R(the user guide,user-guide)': 'the user guide',
|
||||
'C(/usr/bin/file)': "`/usr/bin/file'",
|
||||
'HORIZONTALLINE': '\n{0}\n'.format('-' * 13),
|
||||
# Multiple substitutions
|
||||
'The M(ansible.builtin.yum) module B(MUST) be given the C(package) parameter. See the R(looping docs,using-loops) for more info':
|
||||
"The [ansible.builtin.yum] module *MUST* be given the `package' parameter. See the looping docs for more info",
|
||||
# Problem cases
|
||||
'IBM(International Business Machines)': 'IBM(International Business Machines)',
|
||||
'L(the user guide, https://docs.ansible.com/)': 'the user guide <https://docs.ansible.com/>',
|
||||
'R(the user guide, user-guide)': 'the user guide',
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('text, expected', sorted(TTY_IFY_DATA.items()))
|
||||
def test_ttyify(text, expected):
|
||||
assert DocCLI.tty_ify(text) == expected
|
Loading…
Reference in New Issue