feat(aar-doc): add patch containing ansible-doc-markup filter

This commit is contained in:
s3lph 2025-03-01 02:57:08 +01:00
parent f886de73b7
commit 3e1f8036ee
Signed by: s3lph
GPG key ID: 0AA29A52FB33CFB5

View file

@ -48,7 +48,7 @@ jobs:
+ elif isinstance(value, str):
+ if value in ("yes", "no"):
+ return SingleQuotedScalarString(value)
+ elif "\n" in value:
+ elif "\\n" in value:
+ return LiteralScalarString(value)
+ elif ":" in value:
+ return SingleQuotedScalarString(value)
@ -64,7 +64,7 @@ jobs:
- if isinstance(value, str):
- if value in ("yes", "no"):
- value = SingleQuotedScalarString(value)
- if "\n" in value:
- if "\\n" in value:
- value = LiteralScalarString(value)
+ value = self.safe_quote_recursive(role_default.value)
commented_defaults[role_default.name] = value
@ -87,18 +87,18 @@ jobs:
+def ansible_doc_markup(text):
+ # Regular expressions copied from ansible-doc:
+ # https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/doc.py#L436
+ out = re.sub(r'\bI\(([^)]+)\)', r'*\1*', text) # I(text) -> *text*
+ out = re.sub(r'\bB\(([^)]+)\)', r'**\1**', out) # B(text) -> **text**
+ out = re.sub(r'\bC\(([^)]+)\)', r'`\1`', out) # C(text) -> `text`
+ out = re.sub(r'\bM\(([^)]+)\)', r'`\1`', out) # M(module) -> `module`
+ out = re.sub(r'\bO\(((?:[^\\)]+|\\.)+)\)', r'`\1`', out) # O(option) -> `option`
+ out = re.sub(r'\bV\(((?:[^\\)]+|\\.)+)\)', r'`\1`', out) # V(value) -> `value`
+ out = re.sub(r'\bV\(((?:[^\\)]+|\\.)+)\)', r'`\1`', out) # E(env) -> `env`
+ out = re.sub(r'\bV\(((?:[^\\)]+|\\.)+)\)', r'`\1`', out) # RV(retval) -> `retval`
+ out = re.sub(r'\bU\(([^)]+)\)', r'[\1]', out) # U(url) -> [url]
+ out = re.sub(r'\bL\(([^)]+), *([^)]+)\)', r'[\1](\2)', out) # L(text,url) -> [text](url)
+ out = re.sub(r'\bR\(([^)]+), *([^)]+)\)', r'[\1](#\2)', out) # R(text,frag) -> [text](#frag)
+ out = re.sub(r'\bHORIZONTALLINE\b', r'\n\n---\n', out) # HORIZONTALLINE -> ---
+ out = re.sub(r'\\bI\\(([^)]+)\\)', r'*\\1*', text) # I(text) -> *text*
+ out = re.sub(r'\\bB\\(([^)]+)\\)', r'**\\1**', out) # B(text) -> **text**
+ out = re.sub(r'\\bC\\(([^)]+)\\)', r'`\\1`', out) # C(text) -> `text`
+ out = re.sub(r'\\bM\\(([^)]+)\\)', r'`\\1`', out) # M(module) -> `module`
+ out = re.sub(r'\\bO\\(((?:[^\\\\)]+|\\\\.)+)\\)', r'`\\1`', out) # O(option) -> `option`
+ out = re.sub(r'\\bV\\(((?:[^\\\\)]+|\\\\.)+)\\)', r'`\\1`', out) # V(value) -> `value`
+ out = re.sub(r'\\bV\\(((?:[^\\\\)]+|\\\\.)+)\\)', r'`\\1`', out) # E(env) -> `env`
+ out = re.sub(r'\\bV\\(((?:[^\\\\)]+|\\\\.)+)\\)', r'`\\1`', out) # RV(retval) -> `retval`
+ out = re.sub(r'\\bU\\(([^)]+)\\)', r'[\\1]', out) # U(url) -> [url]
+ out = re.sub(r'\\bL\\(([^)]+), *([^)]+)\\)', r'[\\1](\\2)', out) # L(text,url) -> [text](url)
+ out = re.sub(r'\\bR\\(([^)]+), *([^)]+)\\)', r'[\\1](#\\2)', out) # R(text,frag) -> [text](#frag)
+ out = re.sub(r'\\bHORIZONTALLINE\\b', r'\\n\\n---\\n', out) # HORIZONTALLINE -> ---
+ return out
+
+