21
21
parse_plugin_name ,
22
22
parse_return_value ,
23
23
)
24
- from antsibull_docs .utils .rst import massage_rst_label
24
+ from antsibull_docs .rst_labels import (
25
+ get_option_ref ,
26
+ get_plugin_ref ,
27
+ get_return_value_ref ,
28
+ )
25
29
26
30
from .sphinx_helper import extract_explicit_title
27
31
28
32
logger = logging .getLogger (__name__ )
29
33
30
34
31
- def _plugin_ref (plugin_fqcn : str , plugin_type : str ) -> str :
32
- return f"ansible_collections.{ plugin_fqcn } _{ plugin_type } "
33
-
34
-
35
35
def _create_option_reference (
36
36
plugin_fqcn : str | None ,
37
37
plugin_type : str | None ,
@@ -40,9 +40,7 @@ def _create_option_reference(
40
40
) -> str | None :
41
41
if not plugin_fqcn or not plugin_type :
42
42
return None
43
- ref = massage_rst_label (option .replace ("." , "/" ))
44
- ep = f"{ entrypoint } __" if entrypoint is not None else ""
45
- return f"{ _plugin_ref (plugin_fqcn , plugin_type )} __parameter-{ ep } { ref } "
43
+ return get_option_ref (plugin_fqcn , plugin_type , entrypoint , option .split ("." ))
46
44
47
45
48
46
def _create_return_value_reference (
@@ -53,9 +51,9 @@ def _create_return_value_reference(
53
51
) -> str | None :
54
52
if not plugin_fqcn or not plugin_type :
55
53
return None
56
- ref = massage_rst_label ( return_value . replace ( "." , "/" ))
57
- ep = f" { entrypoint } __" if entrypoint is not None else ""
58
- return f" { _plugin_ref ( plugin_fqcn , plugin_type ) } __return- { ep } { ref } "
54
+ return get_return_value_ref (
55
+ plugin_fqcn , plugin_type , entrypoint , return_value . split ( "." )
56
+ )
59
57
60
58
61
59
def _create_ref_or_not (
@@ -277,7 +275,7 @@ def plugin_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
277
275
refnode = addnodes .pending_xref (
278
276
plugin_fqcn , nodes .inline (rawtext , title ), ** options
279
277
)
280
- refnode ["reftarget" ] = _plugin_ref (plugin_fqcn , plugin_type )
278
+ refnode ["reftarget" ] = get_plugin_ref (plugin_fqcn , plugin_type )
281
279
282
280
return [refnode ], []
283
281
0 commit comments