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

Change injection to use rich text blocks #38

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ansible_specdoc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def _inject_docs(self, module_content: str) -> str:
f"an empty {field_info[0]} field must be specified"
)

doc_field.parent.value.value = f"'''\n{field_info[1]}'''"
doc_field.parent.value.value = f'r"""\n{field_info[1]}"""'

return red.dumps()

Expand Down
12 changes: 6 additions & 6 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ def test_docs_file_injection():

output = cli._inject_docs(module_contents)

assert f"DOCUMENTATION = '''\n{docs}'''" in output
assert f"EXAMPLES = '''\n{examples}'''" in output
assert f"RETURN = '''\n{returns}'''" in output
assert f'DOCUMENTATION = r"""\n{docs}"""' in output
assert f'EXAMPLES = r"""\n{examples}"""' in output
assert f'RETURN = r"""\n{returns}"""' in output

@staticmethod
def test_docs_file_clear():
Expand All @@ -183,6 +183,6 @@ def test_docs_file_clear():

output = cli._inject_docs(module_contents)

assert "DOCUMENTATION = '''\n'''" in output
assert "EXAMPLES = '''\n'''" in output
assert "RETURN = '''\n'''" in output
assert 'DOCUMENTATION = r"""\n"""' in output
assert 'EXAMPLES = r"""\n"""' in output
assert 'RETURN = r"""\n"""' in output
6 changes: 3 additions & 3 deletions tests/test_modules/module_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
SpecReturnValue,
)

DOCUMENTATION = """
DOCUMENTATION = r"""
really cool non-empty docstring
"""

RETURN = """
RETURN = r"""
really cool non-empty return string
"""

EXAMPLES = """
EXAMPLES = r"""
really cool non-empty examples"""

MY_MODULE_DICT_SPEC = {
Expand Down