Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support examples for role entrypoints #244

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/244-role-entrypoint-examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- "Support examples for role entrypoints (https://github.com/ansible-community/antsibull-docs/pull/244)."
10 changes: 10 additions & 0 deletions src/antsibull_docs/data/docsite/ansible-docsite/role.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ See Also
{% endfor %}
{% endif %}

{% if ep_doc['examples'] -%}
Examples
--------

.. code-block:: @{ ep_doc['examples_format'] | rst_format(for_sphinx=true) }@

@{ ep_doc['examples'] | indent(4, True) }@

{% endif %}

{% if ep_doc['author'] -%}
Authors
^^^^^^^
Expand Down
10 changes: 10 additions & 0 deletions src/antsibull_docs/data/docsite/simplified-rst/role.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ See Also
{% endfor %}
{% endif %}

{% if ep_doc['examples'] -%}
Examples
--------

.. code-block:: @{ ep_doc['examples_format'] | rst_format }@

@{ ep_doc['examples'] | indent(4, True) }@

{% endif %}

{% if ep_doc['author'] -%}
Authors
^^^^^^^
Expand Down
3 changes: 2 additions & 1 deletion src/antsibull_docs/schemas/docs/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
SeeAlsoSchemaT,
list_from_scalars,
)
from .plugin import PluginExamplesSchema

_SENTINEL = object()

Expand All @@ -49,7 +50,7 @@ class RoleOptionsSchema(OptionsSchema):
options: dict[str, "InnerRoleOptionsSchema"] = {}


class RoleEntrypointSchema(BaseModel):
class RoleEntrypointSchema(PluginExamplesSchema, BaseModel):
"""Documentation for role entrypoints."""

description: list[str]
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/ansible-doc-cache-all-others.json
Original file line number Diff line number Diff line change
Expand Up @@ -23395,6 +23395,7 @@
"description": [
"This is the baz entrypoint of the bar role."
],
"examples": "An example.",
"short_description": "Bar role, baz entrypoint \u30c6\u30b9\u30c8\u30ed\u30fc\u30eb"
},
"main": {
Expand Down Expand Up @@ -23448,6 +23449,7 @@
"This is the foo role.",
"If you set O(foo_param_1) while O(foo_param_2=3), this might behave funny."
],
"examples": "- name: Use role\n include_role: ns2.col.foo\n vars:\n foo_param_1: foobar\n foo_param_2: 23",
"options": {
"foo_param_1": {
"description": [
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/ansible-doc-cache-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -23312,6 +23312,7 @@
"description": [
"This is the baz entrypoint of the bar role."
],
"examples": "An example.",
"short_description": "Bar role, baz entrypoint \u30c6\u30b9\u30c8\u30ed\u30fc\u30eb"
},
"main": {
Expand Down Expand Up @@ -23365,6 +23366,7 @@
"This is the foo role.",
"If you set O(foo_param_1) while O(foo_param_2=3), this might behave funny."
],
"examples": "- name: Use role\n include_role: ns2.col.foo\n vars:\n foo_param_1: foobar\n foo_param_2: 23",
"options": {
"foo_param_1": {
"description": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23194,6 +23194,7 @@
"description": [
"This is the baz entrypoint of the bar role."
],
"examples": "An example.",
"short_description": "Bar role, baz entrypoint \u30c6\u30b9\u30c8\u30ed\u30fc\u30eb"
},
"main": {
Expand Down Expand Up @@ -23247,6 +23248,7 @@
"This is the foo role.",
"If you set O(foo_param_1) while O(foo_param_2=3), this might behave funny."
],
"examples": "- name: Use role\n include_role: ns2.col.foo\n vars:\n foo_param_1: foobar\n foo_param_2: 23",
"options": {
"foo_param_1": {
"description": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22835,6 +22835,7 @@
"This is the foo role.",
"If you set O(foo_param_1) while O(foo_param_2=3), this might behave funny."
],
"examples": "- name: Use role\n include_role: ns2.col.foo\n vars:\n foo_param_1: foobar\n foo_param_2: 23",
"options": {
"foo_param_1": {
"description": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,7 @@
"description": [
"This is the baz entrypoint of the bar role."
],
"examples": "An example.",
"short_description": "Bar role, baz entrypoint \u30c6\u30b9\u30c8\u30ed\u30fc\u30eb"
},
"main": {
Expand Down Expand Up @@ -1920,6 +1921,7 @@
"This is the foo role.",
"If you set O(foo_param_1) while O(foo_param_2=3), this might behave funny."
],
"examples": "- name: Use role\n include_role: ns2.col.foo\n vars:\n foo_param_1: foobar\n foo_param_2: 23",
"options": {
"foo_param_1": {
"description": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,7 @@
"This is the foo role.",
"If you set O(foo_param_1) while O(foo_param_2=3), this might behave funny."
],
"examples": "- name: Use role\n include_role: ns2.col.foo\n vars:\n foo_param_1: foobar\n foo_param_2: 23",
"options": {
"foo_param_1": {
"description": [
Expand Down
1 change: 1 addition & 0 deletions tests/functional/ansible-doc-cache-ns.col2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,7 @@
"description": [
"This is the baz entrypoint of the bar role."
],
"examples": "An example.",
"short_description": "Bar role, baz entrypoint \u30c6\u30b9\u30c8\u30ed\u30fc\u30eb"
},
"main": {
Expand Down
1 change: 1 addition & 0 deletions tests/functional/ansible-doc-cache-ns2.col.json
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,7 @@
"This is the foo role.",
"If you set O(foo_param_1) while O(foo_param_2=3), this might behave funny."
],
"examples": "- name: Use role\n include_role: ns2.col.foo\n vars:\n foo_param_1: foobar\n foo_param_2: 23",
"options": {
"foo_param_1": {
"description": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ Synopsis
.. Seealso


Examples
--------

.. code-block:: yaml+jinja

An example.




.. Entry point title
Expand Down Expand Up @@ -114,6 +122,7 @@ See Also
\ :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_lookup>`\ lookup plugin
The official documentation on the **ns2.col.foo** lookup plugin.


Authors
^^^^^^^

Expand Down
12 changes: 12 additions & 0 deletions tests/functional/baseline-default/collections/ns2/col/foo_role.rst
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,18 @@ See Also
\ :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_module>`\
The official documentation on the **ns2.col.foo** module.

Examples
--------

.. code-block:: yaml+jinja

- name: Use role
include_role: ns2.col.foo
vars:
foo_param_1: foobar
foo_param_2: 23


Authors
^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ Synopsis
.. Seealso


Examples
--------

.. code-block:: yaml+jinja

An example.




.. Entry point title
Expand Down Expand Up @@ -114,6 +122,7 @@ See Also
\ :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_lookup>`\ lookup plugin
The official documentation on the **ns2.col.foo** lookup plugin.


Authors
^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,18 @@ See Also
\ :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_module>`\
The official documentation on the **ns2.col.foo** module.

Examples
--------

.. code-block:: yaml+jinja

- name: Use role
include_role: ns2.col.foo
vars:
foo_param_1: foobar
foo_param_2: 23


Authors
^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,18 @@ See Also
\ :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_module>`\
The official documentation on the **ns2.col.foo** module.

Examples
--------

.. code-block:: yaml+jinja

- name: Use role
include_role: ns2.col.foo
vars:
foo_param_1: foobar
foo_param_2: 23


Authors
^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ See Also

The official documentation on the **ns2.col.foo** module.

Examples
--------

.. code-block:: yaml

- name: Use role
include_role: ns2.col.foo
vars:
foo_param_1: foobar
foo_param_2: 23


Authors
^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ Synopsis



Examples
--------

.. code-block:: yaml

An example.




Entry point ``main`` -- Bar role
Expand Down Expand Up @@ -62,6 +70,7 @@ See Also

The official documentation on the **ns2.col.foo** lookup plugin.


Authors
^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ See Also

The official documentation on the **ns2.col.foo** module.

Examples
--------

.. code-block:: yaml

- name: Use role
include_role: ns2.col.foo
vars:
foo_param_1: foobar
foo_param_2: 23


Authors
^^^^^^^

Expand Down
12 changes: 12 additions & 0 deletions tests/functional/baseline-squash-hierarchy/foo_role.rst
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,18 @@ See Also
\ :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_module>`\
The official documentation on the **ns2.col.foo** module.

Examples
--------

.. code-block:: yaml+jinja

- name: Use role
include_role: ns2.col.foo
vars:
foo_param_1: foobar
foo_param_2: 23


Authors
^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,18 @@ See Also
\ :ref:`ns2.col.foo <ansible_collections.ns2.col.foo_module>`\
The official documentation on the **ns2.col.foo** module.

Examples
--------

.. code-block:: yaml+jinja

- name: Use role
include_role: ns2.col.foo
vars:
foo_param_1: foobar
foo_param_2: 23


Authors
^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ argument_specs:
short_description: Bar role, baz entrypoint テストロール
description:
- This is the baz entrypoint of the bar role.
examples: An example.
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ argument_specs:
I don't know
of any
alternative.
examples: |-
- name: Use role
include_role: ns2.col.foo
vars:
foo_param_1: foobar
foo_param_2: 23