From 1263f55f526bd20239fcb227389f8c5142a56f36 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 8 Jun 2021 17:46:50 +0200 Subject: [PATCH] Add new semantic markup support to ansible-doc text output. --- lib/ansible/cli/doc.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py index d1c49765d81439..874608d2c84fcb 100755 --- a/lib/ansible/cli/doc.py +++ b/lib/ansible/cli/doc.py @@ -350,10 +350,14 @@ class DocCLI(CLI, RoleMixin): _ITALIC = re.compile(r"\bI\(([^)]+)\)") _BOLD = re.compile(r"\bB\(([^)]+)\)") _MODULE = re.compile(r"\bM\(([^)]+)\)") + _PLUGIN = re.compile(r"\bP\(([^#)]+)#([a-z]+)\)") _LINK = re.compile(r"\bL\(([^)]+), *([^)]+)\)") _URL = re.compile(r"\bU\(([^)]+)\)") _REF = re.compile(r"\bR\(([^)]+), *([^)]+)\)") _CONST = re.compile(r"\bC\(([^)]+)\)") + _SEM_OPTION_NAME = re.compile(r"\bO\(([^)]+)\)") + _SEM_OPTION_VALUE = re.compile(r"\bV\(([^)]+)\)") + _SEM_ENV_VARIABLE = re.compile(r"\bE\(([^)]+)\)") _RULER = re.compile(r"\bHORIZONTALLINE\b") # rst specific @@ -376,8 +380,12 @@ def tty_ify(cls, text): t = cls._MODULE.sub("[" + r"\1" + "]", t) # M(word) => [word] t = cls._URL.sub(r"\1", t) # U(word) => word t = cls._LINK.sub(r"\1 <\2>", t) # L(word, url) => word + t = cls._PLUGIN.sub("[" + r"\1" + "]", t) # P(word#type) => [word] t = cls._REF.sub(r"\1", t) # R(word, sphinx-ref) => word t = cls._CONST.sub(r"`\1'", t) # C(word) => `word' + t = cls._SEM_OPTION_NAME.sub(r"`\1'", t) # O(word) => `word' + t = cls._SEM_OPTION_VALUE.sub(r"`\1'", t) # V(word) => `word' + t = cls._SEM_ENV_VARIABLE.sub(r"`\1'", t) # E(word) => `word' t = cls._RULER.sub("\n{0}\n".format("-" * 13), t) # HORIZONTALLINE => ------- # remove rst