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

role argument spec: allow author, top-level description, and todo to be a string instead of a list of stings #227

Merged
merged 2 commits into from
Dec 16, 2023
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/227-role-argspec-str-to-list.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "For role argument specs, allow ``author``, ``description``, and ``todo`` to be a string instead of a list of strings, similarly as with ansible-doc and with modules and plugins (https://github.com/ansible-community/antsibull-docs/pull/227)."
11 changes: 11 additions & 0 deletions src/antsibull_docs/schemas/docs/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
SeeAlsoLinkSchema,
SeeAlsoModSchema,
SeeAlsoRefSchema,
list_from_scalars,
)

_SENTINEL = object()
Expand Down Expand Up @@ -69,6 +70,16 @@ class RoleEntrypointSchema(BaseModel):

options: dict[str, RoleOptionsSchema] = {}

@p.validator(
"author",
"description",
"todo",
pre=True,
)
# pylint:disable=no-self-argument
def list_from_scalars(cls, obj):
return list_from_scalars(obj)


class RoleSchema(BaseModel):
"""Documentation for roles."""
Expand Down
10 changes: 10 additions & 0 deletions tests/functional/schema/good_data/one_role.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,17 @@
}
},
"short_description": "Do account key rollover",
"todo": [
"something",
"something else"
],
"version_added": "0.1.0"
},
"other": {
"author": "Felix Fontein (@felixfontein)",
"description": "This is a one-paragraph description",
"short_description": "Do nothing",
"todo": "something"
}
},
"path": "/path/to/ansible_collections/felixfontein/acme"
Expand Down
16 changes: 16 additions & 0 deletions tests/functional/schema/good_data/one_role_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,23 @@
}
},
"short_description": "Do account key rollover",
"todo": [
"something",
"something else"
],
"version_added": "0.1.0"
},
"other": {
"author": [
"Felix Fontein (@felixfontein)"
],
"description": [
"This is a one-paragraph description"
],
"short_description": "Do nothing",
"todo": [
"something"
]
}
},
"path": "/path/to/ansible_collections/felixfontein/acme"
Expand Down