diff --git a/ansible_specdoc/cli.py b/ansible_specdoc/cli.py index 2a78ccd..d2011cd 100644 --- a/ansible_specdoc/cli.py +++ b/ansible_specdoc/cli.py @@ -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() diff --git a/tests/test_cli.py b/tests/test_cli.py index 3022369..ce4aaca 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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(): @@ -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 diff --git a/tests/test_modules/module_1.py b/tests/test_modules/module_1.py index 7cea715..1a10af7 100644 --- a/tests/test_modules/module_1.py +++ b/tests/test_modules/module_1.py @@ -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 = {