Skip to content

Commit

Permalink
Add new semantic markup support to ansible-doc text output.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Mar 4, 2022
1 parent 8b2e628 commit 1263f55
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/ansible/cli/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <url>
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
Expand Down

0 comments on commit 1263f55

Please sign in to comment.