Repository navigation
Conversation
felixfontein
marked this pull request as draft
October 13, 2026 10:29
Roles can now document the variables they set via an optional `return:` key per entry point in meta/argument_specs.yml, reusing the module return schema. These render as a "Return Variables" table on the role page, with RV() references resolving against them. Roles without a `return:` block are unaffected. - RoleEntrypointSchema inherits PluginReturnSchema so `return` is parsed - augment_docs computes full keys for role return values (for RV()) - ansible-docsite and simplified-rst role templates render the section, titled "Return Variables" (vs modules' "Return Values") - add a return: block to the ns2.col.foo test fixture and regenerate baselines; extend the role schema snapshot fixture Part of ansible-community#491 Discussion: https://forum.ansible.com/t/proposal-document-role-return-variables-in-argument-specs-yml-like-module-return/46469 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
spetrosi
force-pushed
the
role-return-values
branch
from
October 13, 2026 10:49
f0a9f5b to
dcef106
Compare
spetrosi
added a commit
to spetrosi/bootloader
that referenced
this pull request
Oct 13, 2026
Add a native return: block to meta/argument_specs.yml so the variables the role sets are documented as a typed "Return Variables" table, the same way modules document their return values, and render it into README.md. - meta/argument_specs.yml: add a return: block for bootloader_reboot_required and bootloader_facts, with contains: describing each kernel-fact field (args, default, id, index, initrd, kernel, root, title) sourced from library/bootloader_facts.py's RETURN. Remove the old notes: "Values returned by the role" workaround now that the table is first-class. - .html_to_md.py: render the Return Values table as a Markdown pipe table (Key / Description). Extract the shared name-column logic (contains: nesting via bullet depth markers, **name** *type*) from param_label into a reusable nested_label helper used by both Parameters and Return Values; add a build_returns table-builder (the return table folds Returned:/Sample: into the description, unlike Parameters' Choices/Default), and dispatch to it on the return- anchor id. - .build_docs.sh: build with the patched antsibull-docs that renders role return variables (not yet in a released antsibull-docs), installed from the fork branch into a dedicated venv (ANTSIBULL_RV_VENV, created once/reused). - .ansible-lint: temporarily skip schema[role-arg-spec]; the released ansible-lint role-arg-spec schema rejects the return: key (schema rules cannot be disabled with inline noqa, only via skip_list). - Regenerate README.md and sphinx_html/ with the Return Variables table. The .build_docs.sh venv and the ansible-lint skip are temporary until role return: support is released upstream; remove both then. Refs: ansible-community/antsibull-docs#491 ansible-community/antsibull-docs#492 https://forum.ansible.com/t/proposal-document-role-return-variables-in-argument-specs-yml-like-module-return/46469 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Render a Return Variables table on role documentation pages, so roles can document the variables they set the same way modules document their return values. Implements the renderer half of #491.
Roles declare an optional
return:block per entry point inmeta/argument_specs.yml(same structure as moduleRETURN).ansible-doc -t role --jsonalready passes this key through untouched, so no ansible-core change is needed for the data to arrive — this PR makes antsibull-docs ingest and render it. Roles without areturn:block are completely unaffected.Changes
RoleEntrypointSchemanow inheritsPluginReturnSchema, so thereturnfield is parsed for role entry points.augment_docscomputes full keys for role return values (soRV()references resolve).ansible-docsiteandsimplified-rstrole templates render the section using the existingreturnvalues.rst.j2macro.RV(fqcn#role:entrypoint:name)markup already worked (groundwork from Support semantic markup for roles #113) and now has real targets to resolve against.Tests
return:block to thens2.col.foofixture role (aboolplus alist/contains, exercisingO()andRV()cross-references) and regenerated all baselines.nox -e formatters,codeqa,typing, andtestall pass.Context / status
This is part of a cross-repo effort (companion PRs planned for ansible-lint's
role-arg-spec.jsonschema and, optionally, ansible-core'sansible-doctext output).As discussed in #491, whether roles should document "return values" is an ecosystem question that needs Core-team / community buy-in. There is an open discussion on the Ansible Forum: https://forum.ansible.com/t/proposal-document-role-return-variables-in-argument-specs-yml-like-module-return/46469 — this PR is offered as the working implementation to support that discussion, and should not be merged ahead of consensus there.
Part of #491.
🤖 Generated with Claude Code