Skip to content

Commit 90ea4e7

Browse files
authored
Move label generating code to one place (#269)
* Move label generating code to one place. * Address other labels. Fix wrong/ambiguous labels used. * Also make HTML anchor unambiguous. * Fix internal option/return value links for simplified RST output.
1 parent a8f0773 commit 90ea4e7

File tree

48 files changed

+168
-81
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+168
-81
lines changed

changelogs/fragments/269-refs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bugfixes:
2+
- "Fix internal links to options and return values in simplified RST output (https://github.com/ansible-community/antsibull-docs/pull/269)."
3+
- "Include role in role attribute references (https://github.com/ansible-community/antsibull-docs/pull/269)."

src/antsibull_docs/data/docsite/ansible-docsite/macros/attributes.rst.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
{% from 'macros/version_added.rst.j2' import version_added_rst %}
88

9-
{% macro in_rst(attributes, role_entrypoint=None) %}
9+
{% macro in_rst(attributes, attribute_html_prefix='', role_entrypoint=None) %}
1010
.. tabularcolumns:: \X{2}{10}\X{3}{10}\X{5}{10}
1111

1212
.. list-table::
@@ -24,17 +24,17 @@
2424
* - .. raw:: html
2525

2626
<div class="ansible-option-cell">
27-
<div class="ansibleOptionAnchor" id="attribute-@{ attribute | e }@"></div>
27+
<div class="ansibleOptionAnchor" id="attribute-@{ parameter_html_prefix }@@{ attribute | e }@"></div>
2828

29-
.. _ansible_collections.@{plugin_name}@_@{plugin_type}@__attribute-@{ attribute }@:
29+
.. _@{ rst_attribute_ref(plugin_name, plugin_type, role_entrypoint=role_entrypoint, attribute=attribute) }@:
3030

3131
.. rst-class:: ansible-option-title
3232

3333
**@{ attribute }@**
3434

3535
.. raw:: html
3636

37-
<a class="ansibleOptionLink" href="#attribute-@{ attribute | e }@" title="Permalink to this attribute"></a>
37+
<a class="ansibleOptionLink" href="#attribute-@{ parameter_html_prefix }@@{ attribute | e }@" title="Permalink to this attribute"></a>
3838

3939
.. raw:: html
4040

src/antsibull_docs/data/docsite/ansible-docsite/macros/parameters.rst.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{% from 'macros/deprecates.rst.j2' import in_html as deprecates_html with context %}
1111
{% from 'macros/version_added.rst.j2' import version_added_rst, version_added_html %}
1212

13-
{% macro in_rst(elements, suboption_key='suboptions', parameter_html_prefix='', parameter_rst_prefix='', role_entrypoint=None) %}
13+
{% macro in_rst(elements, suboption_key='suboptions', parameter_html_prefix='', role_entrypoint=None) %}
1414
.. tabularcolumns:: \X{1}{3}\X{2}{3}
1515

1616
.. list-table::
@@ -38,7 +38,7 @@
3838
{% endif %}
3939

4040
{% for full_key in value['full_keys_rst'] %}
41-
.. _ansible_collections.@{plugin_name}@_@{plugin_type}@__parameter-@{ parameter_rst_prefix }@{% for part in full_key %}@{ part }@{% if not loop.last %}/{% endif %}{% endfor %}:
41+
.. _@{ rst_option_ref(plugin_name, plugin_type, role_entrypoint=role_entrypoint, option=full_key) }@:
4242
{% endfor %}
4343

4444
.. rst-class:: ansible-option-title
@@ -180,7 +180,7 @@
180180

181181
{##################################################################################################################}
182182

183-
{% macro in_html(elements, suboption_key='suboptions', parameter_html_prefix='', parameter_rst_prefix='', role_entrypoint=None) %}
183+
{% macro in_html(elements, suboption_key='suboptions', parameter_html_prefix='', role_entrypoint=None) %}
184184
.. raw:: html
185185

186186
<table class="colwidths-auto ansible-option-table docutils align-default" style="width: 100%">

src/antsibull_docs/data/docsite/ansible-docsite/macros/returnvalues.rst.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
{% endif %}
3737

3838
{% for full_key in value['full_keys_rst'] %}
39-
.. _ansible_collections.@{plugin_name}@_@{plugin_type}@__return-{% for part in full_key %}@{ part }@{% if not loop.last %}/{% endif %}{% endfor %}:
39+
.. _@{ rst_return_value_ref(plugin_name, plugin_type, role_entrypoint=role_entrypoint, return_value=full_key) }@:
4040
{% endfor %}
4141

4242
.. rst-class:: ansible-option-title

src/antsibull_docs/data/docsite/ansible-docsite/plugin-error.rst.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
.. Anchors
2020

21-
.. _ansible_collections.@{plugin_name}@_@{plugin_type}@:
21+
.. _@{ rst_plugin_ref(plugin_name, plugin_type) }@:
2222

2323
.. Title
2424

src/antsibull_docs/data/docsite/ansible-docsite/plugin-redirect.rst.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
.. Anchors
1515

16-
.. _ansible_collections.@{plugin_name}@_@{plugin_type}@:
16+
.. _@{ rst_plugin_ref(plugin_name, plugin_type) }@:
1717

1818
.. Title
1919

src/antsibull_docs/data/docsite/ansible-docsite/plugin-tombstone.rst.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
.. Anchors
1515

16-
.. _ansible_collections.@{plugin_name}@_@{plugin_type}@:
16+
.. _@{ rst_plugin_ref(plugin_name, plugin_type) }@:
1717

1818
.. Title
1919

src/antsibull_docs/data/docsite/ansible-docsite/plugin.rst.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
.. Anchors
3232

33-
.. _ansible_collections.@{plugin_name}@_@{plugin_type}@:
33+
.. _@{ rst_plugin_ref(plugin_name, plugin_type) }@:
3434

3535
.. Anchors: short name for ansible.builtin
3636

@@ -76,7 +76,7 @@
7676
To install it, use: @{ collection | collection_install | rst_code }@.
7777
{% if doc['requirements'] %}
7878
You need further requirements to be able to use this {% if plugin_type == 'module' %}module{% else %}@{ plugin_type }@ plugin{% endif %},
79-
see :ref:`Requirements <ansible_collections.@{plugin_name}@_@{plugin_type}@_requirements>` for details.
79+
see :ref:`Requirements <@{ rst_requirements_ref(plugin_name, plugin_type) }@>` for details.
8080
{% endif %}
8181

8282
To use it in a playbook, specify: :code:`@{plugin_name}@`.
@@ -150,7 +150,7 @@ Aliases: @{ ', '.join(doc['aliases'] | sort) }@
150150
.. Requirements
151151

152152
{% if doc['requirements'] -%}
153-
.. _ansible_collections.@{plugin_name}@_@{plugin_type}@_requirements:
153+
.. _@{ rst_requirements_ref(plugin_name, plugin_type) }@:
154154

155155
Requirements
156156
------------

src/antsibull_docs/data/docsite/ansible-docsite/role.rst.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
.. Anchors
2727

28-
.. _ansible_collections.@{plugin_name}@_@{plugin_type}@:
28+
.. _@{ rst_plugin_ref(plugin_name, plugin_type) }@:
2929

3030
.. Title
3131

@@ -130,9 +130,9 @@ Parameters
130130
^^^^^^^^^^
131131

132132
{% if use_html_blobs %}
133-
@{ parameters_html(ep_doc['options'] | dictsort, suboption_key='options', parameter_html_prefix=entry_point ~ '--', parameter_rst_prefix=entry_point ~ '__', role_entrypoint=entry_point) }@
133+
@{ parameters_html(ep_doc['options'] | dictsort, suboption_key='options', parameter_html_prefix=entry_point ~ '--', role_entrypoint=entry_point) }@
134134
{% else %}
135-
@{ parameters_rst(ep_doc['options'] | dictsort, suboption_key='options', parameter_html_prefix=entry_point ~ '--', parameter_rst_prefix=entry_point ~ '__', role_entrypoint=entry_point) }@
135+
@{ parameters_rst(ep_doc['options'] | dictsort, suboption_key='options', parameter_html_prefix=entry_point ~ '--', role_entrypoint=entry_point) }@
136136
{% endif %}
137137
{% endif %}
138138

@@ -143,7 +143,7 @@ Parameters
143143
Attributes
144144
----------
145145

146-
@{ attributes_rst(ep_doc['attributes'], role_entrypoint=entry_point) }@
146+
@{ attributes_rst(ep_doc['attributes'], attribute_html_prefix=entry_point ~ '--', role_entrypoint=entry_point) }@
147147
{% endif %}
148148

149149
.. Notes

src/antsibull_docs/data/docsite/simplified-rst/macros/attributes.rst.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
{% for attribute, data in attributes | dictsort %}
1818
{# attribute name #}
1919

20-
* - .. _ansible_collections.@{plugin_name}@_@{plugin_type}@__attribute-@{ attribute }@:
20+
* - .. _@{ rst_attribute_ref(plugin_name, plugin_type, role_entrypoint=role_entrypoint, attribute=attribute) }@:
2121

2222
**@{ attribute }@**
2323

0 commit comments

Comments
 (0)