Skip to content

Commit

Permalink
role argument spec: allow author, top-level description, and todo to …
Browse files Browse the repository at this point in the history
…be a string instead of a list of stings (#227)

* Allow author, top-level description, and todo to be a string instead of a list of strings.

* Extend tests.
  • Loading branch information
felixfontein authored Dec 16, 2023
1 parent 563cb6f commit f07e5ff
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
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

0 comments on commit f07e5ff

Please sign in to comment.