Skip to content

Commit

Permalink
Implement P() in RST. (Was missing until now.)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Feb 1, 2022
1 parent 6cc0a58 commit d01b5c9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/antsibull/jinja2/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ def _rst_ify_module(m: 're.Match') -> str:
return f"\\ :ref:`{rst_escape(fqcn)} <ansible_collections.{fqcn}_module>`\\ "


def _rst_ify_plugin(m: 're.Match') -> str:
fqcn = f'{m.group(1)}.{m.group(2)}.{m.group(3)}'
plugin_type = m.group(4)
return f"\\ :ref:`{rst_escape(fqcn)} <ansible_collections.{fqcn}_{plugin_type}>`\\ "


def _escape_url(url: str) -> str:
# We include '<>[]{}' in safe to allow urls such as 'https://<HOST>:[PORT]/v{version}/' to
# remain unmangled by percent encoding
Expand Down Expand Up @@ -280,6 +286,7 @@ def rst_ify(context: Context, text: str) -> str:
text, _counts['italic'] = _ITALIC.subn(_rst_ify_italic, text)
text, _counts['bold'] = _BOLD.subn(_rst_ify_bold, text)
text, _counts['module'] = _MODULE.subn(_rst_ify_module, text)
text, _counts['plugin'] = _PLUGIN.subn(_rst_ify_plugin, text)
text, _counts['link'] = _LINK.subn(_rst_ify_link, text)
text, _counts['url'] = _URL.subn(_rst_ify_url, text)
text, _counts['ref'] = _REF.subn(_rst_ify_ref, text)
Expand Down

0 comments on commit d01b5c9

Please sign in to comment.