Skip to content

Commit

Permalink
feat(defaults): do not display a description if none exists
Browse files Browse the repository at this point in the history
  • Loading branch information
rndmh3ro committed Oct 10, 2024
1 parent 18f09c5 commit c8ade79
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion aar_doc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def parse_options(ctx: typer.Context) -> dict:
details["display_required"] = (
"yes" if details.get("required", False) else "no"
)
description = details["description"]
description = details["description"] if "description" in details else ""
details["display_description"] = (
(
description
Expand Down
3 changes: 1 addition & 2 deletions aar_doc/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,14 @@ def add_default(
self,
name: str,
value: Any,
description: str | list = "No description provided.",
description: str | list,
) -> None:
"""Add a default.
Args:
name (str): Variable name of the default.
value (Any): Value of the default.
description (str, optional): Description of the default.
Defaults to "No description provided.".
"""
if isinstance(value, str):
value = value.strip()
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/roles/generate_defaults/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ generate_defaults_dict:
value3: third value
# A string value that can be overwritten
generate_defaults_overwrite: original value
generate_defaults_no_description: foo
# A multiline string value
generate_defaults_str_multiline: |-
This is a multi line string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ generate_defaults_dict:
value3: third value
# A string value that was overwritten
generate_defaults_overwrite: overwritten value
generate_defaults_no_description: foo
# A multiline string value
generate_defaults_str_multiline: |-
This is a multi line string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ argument_specs:
type: str
required: true
description: An option without a default
generate_defaults_no_description:
type: str
required: true
default: "foo"
alternate:
short_description: The alternate entry point for the defaults role.
options:
Expand Down

0 comments on commit c8ade79

Please sign in to comment.