@@ -244,9 +244,8 @@ def _run(
244
244
rst_id = (
245
245
f"ansible_collections.{ content .fqcn } _{ content .plugin_type } _requirements"
246
246
)
247
- ref_title = (
248
- f"Requirements of the { _plugin_name (content .fqcn , content .plugin_type )} "
249
- )
247
+ plugin_name = _plugin_name (content .fqcn , content .plugin_type )
248
+ ref_title = f"Requirements of the { plugin_name } "
250
249
if content .role_entrypoint is not None and content .plugin_type == "role" :
251
250
rst_id = (
252
251
f"ansible_collections.{ content .fqcn } _role"
@@ -278,13 +277,14 @@ def _run(self, content_str: str, content: AnsibleAttribute) -> list[nodes.Node]:
278
277
node = ansible_attribute (
279
278
"" , content .name , classes = ["ansible-option-title" ], ids = [html_id ]
280
279
)
280
+ plugin_name = _plugin_name (content .fqcn , content .plugin_type )
281
281
self .state .document .note_explicit_target (node )
282
282
std = t .cast (StandardDomain , self .env .get_domain ("std" ))
283
283
std .note_hyperlink_target (
284
284
rst_id ,
285
285
self .env .docname ,
286
286
html_id ,
287
- f"{ content .name } attribute of { _plugin_name ( content . fqcn , content . plugin_type ) } " ,
287
+ f"{ content .name } attribute of { plugin_name } " ,
288
288
)
289
289
permalink = nodes .raw (
290
290
"" ,
@@ -309,7 +309,7 @@ def _compile_ids(
309
309
role_entrypoint : str | None ,
310
310
full_keys : list [list [str ]],
311
311
prefix_type : str ,
312
- ) -> tuple [dict [str , tuple [str , str ]], list [str ]]:
312
+ ) -> tuple [dict [str , tuple [str , str , str ]], list [str ]]:
313
313
rst_id_prefix = f"ansible_collections.{ fqcn } _{ plugin_type } __{ prefix_type } -"
314
314
html_id_prefix = f"{ prefix_type } -"
315
315
if role_entrypoint is not None :
@@ -321,7 +321,7 @@ def _compile_ids(
321
321
html_id = html_id_prefix + "/" .join ([_percent_encode (k ) for k in full_key ])
322
322
rst_id = rst_id_prefix + "/" .join ([massage_rst_label (k ) for k in full_key ])
323
323
html_ids .append (html_id )
324
- rst_ids [rst_id ] = (html_id , "." .join (full_key ))
324
+ rst_ids [rst_id ] = (html_id , "." .join (full_key ), "." . join ( full_key [ 1 :]) )
325
325
return rst_ids , _make_unique (html_ids )
326
326
327
327
@@ -342,19 +342,41 @@ def _run(self, content_str: str, content: AnsibleOption) -> list[nodes.Node]:
342
342
classes = ["ansible-option-title" ],
343
343
ids = html_ids ,
344
344
)
345
+ what_title = "{key} option of"
346
+ what_perma = "this option"
347
+ if content .plugin_type in ("lookup" , "filter" , "test" ):
348
+ what_title = "{key} keyword option of"
349
+ what_perma = "this keyword option"
350
+ if content .special == "positional" :
351
+ what_title = "{key} positional option of"
352
+ what_perma = "this positional option"
353
+ if content .special == "input" :
354
+ what_title = "input of"
355
+ what_perma = f"the { content .plugin_type } 's input"
356
+ if len (content .full_keys [0 ]) > 1 :
357
+ what_title = "nested input field {subkey} of"
358
+ what_perma = f"this nested field of the { content .plugin_type } 's input"
359
+ if content .special == "terms" :
360
+ what_title = "terms for the"
361
+ what_perma = f"the { content .plugin_type } 's terms"
362
+ if len (content .full_keys [0 ]) > 1 :
363
+ what_title = "nested term field {subkey} for the"
364
+ what_perma = f"this nested field of the { content .plugin_type } 's term"
365
+ plugin_name = _plugin_name (content .fqcn , content .plugin_type )
345
366
self .state .document .note_explicit_target (node )
346
367
std = t .cast (StandardDomain , self .env .get_domain ("std" ))
347
- for rst_id , (html_id , key ) in rst_ids .items ():
368
+ for rst_id , (html_id , key , subkey ) in rst_ids .items ():
369
+ rst_title = f"{ what_title .format (key = key , subkey = subkey )} { plugin_name } "
348
370
std .note_hyperlink_target (
349
371
rst_id ,
350
372
self .env .docname ,
351
373
html_id ,
352
- f" { key } option of { _plugin_name ( content . fqcn , content . plugin_type ) } " ,
374
+ rst_title ,
353
375
)
354
376
permalink = nodes .raw (
355
377
"" ,
356
378
f' <a class="ansibleOptionLink" href="#{ html_ids [0 ]} "'
357
- ' title="Permalink to this option "></a>' ,
379
+ f ' title="Permalink to { what_perma } "></a>' ,
358
380
format = "html" ,
359
381
)
360
382
return [node , permalink ]
@@ -377,19 +399,32 @@ def _run(self, content_str: str, content: AnsibleReturnValue) -> list[nodes.Node
377
399
classes = ["ansible-option-title" ],
378
400
ids = html_ids ,
379
401
)
402
+ what_title = "{key} return value of"
403
+ what_perma = "this return value"
404
+ if content .special == "facts" :
405
+ what_title = "{key} returned fact of"
406
+ what_perma = "this returned fact"
407
+ if content .special == "return-value" :
408
+ what_title = "return value of the"
409
+ what_perma = f"the { content .plugin_type } 's return value"
410
+ if len (content .full_keys [0 ]) > 1 :
411
+ what_title = "nested return value field {subkey} of the"
412
+ what_perma = f"this nested return value of this { content .plugin_type } "
413
+ plugin_name = _plugin_name (content .fqcn , content .plugin_type )
380
414
self .state .document .note_explicit_target (node )
381
415
std = t .cast (StandardDomain , self .env .get_domain ("std" ))
382
- for rst_id , (html_id , key ) in rst_ids .items ():
416
+ for rst_id , (html_id , key , subkey ) in rst_ids .items ():
417
+ ref_title = f"{ what_title .format (key = key , subkey = subkey )} { plugin_name } "
383
418
std .note_hyperlink_target (
384
419
rst_id ,
385
420
self .env .docname ,
386
421
html_id ,
387
- f" { key } return value of { _plugin_name ( content . fqcn , content . plugin_type ) } " ,
422
+ ref_title ,
388
423
)
389
424
permalink = nodes .raw (
390
425
"" ,
391
426
f' <a class="ansibleOptionLink" href="#{ html_ids [0 ]} "'
392
- ' title="Permalink to this return value "></a>' ,
427
+ f ' title="Permalink to { what_perma } "></a>' ,
393
428
format = "html" ,
394
429
)
395
430
return [node , permalink ]
0 commit comments