From 2458b553eb0d3b8d81c3a5fb6029e3b72243e45a Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Thu, 14 Dec 2023 07:54:54 +0100 Subject: [PATCH 1/2] Allow author, top-level description, and todo to be a string instead of a list of strings. --- changelogs/fragments/227-role-argspec-str-to-list.yml | 2 ++ src/antsibull_docs/schemas/docs/role.py | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 changelogs/fragments/227-role-argspec-str-to-list.yml diff --git a/changelogs/fragments/227-role-argspec-str-to-list.yml b/changelogs/fragments/227-role-argspec-str-to-list.yml new file mode 100644 index 00000000..9d350d94 --- /dev/null +++ b/changelogs/fragments/227-role-argspec-str-to-list.yml @@ -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)." diff --git a/src/antsibull_docs/schemas/docs/role.py b/src/antsibull_docs/schemas/docs/role.py index 5fd62e24..8b800063 100644 --- a/src/antsibull_docs/schemas/docs/role.py +++ b/src/antsibull_docs/schemas/docs/role.py @@ -26,6 +26,7 @@ SeeAlsoLinkSchema, SeeAlsoModSchema, SeeAlsoRefSchema, + list_from_scalars, ) _SENTINEL = object() @@ -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.""" From 06f78630eb677c422fe283ff20f79573fb3fe46c Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Thu, 14 Dec 2023 13:32:00 +0100 Subject: [PATCH 2/2] Extend tests. --- tests/functional/schema/good_data/one_role.json | 10 ++++++++++ .../schema/good_data/one_role_results.json | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/tests/functional/schema/good_data/one_role.json b/tests/functional/schema/good_data/one_role.json index ac369f91..454e3f8b 100644 --- a/tests/functional/schema/good_data/one_role.json +++ b/tests/functional/schema/good_data/one_role.json @@ -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" diff --git a/tests/functional/schema/good_data/one_role_results.json b/tests/functional/schema/good_data/one_role_results.json index c73fcf60..6c16115a 100644 --- a/tests/functional/schema/good_data/one_role_results.json +++ b/tests/functional/schema/good_data/one_role_results.json @@ -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"