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

Feature/generate defaults #81

Merged
merged 29 commits into from
Oct 10, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
914689b
refactor: rename write to write_doc
moritzrp Oct 4, 2024
c7e9191
feat: add method to generate defaults dict
moritzrp Oct 4, 2024
2460a1c
feat: add method to write defaults dict to a file
moritzrp Oct 4, 2024
59ab56c
feat: add defaults command
moritzrp Oct 4, 2024
36e9607
enhancement: specify output style parameters
moritzrp Oct 5, 2024
3747432
enhancement: check for None instead
moritzrp Oct 5, 2024
67afc50
enhancement: don't sort the resulting defaults by keys
moritzrp Oct 5, 2024
85a5316
feat: add defaults_file option for defaults command
moritzrp Oct 5, 2024
d77e3e7
tests: add test case for generating defaults
moritzrp Oct 5, 2024
7dd1fe5
style: format file
moritzrp Oct 5, 2024
7a7ce9e
tests: add option without a default value
moritzrp Oct 5, 2024
bdfccee
refactor: change default style when dumping defaults
moritzrp Oct 6, 2024
a51b2d9
tests: add additional cases for types
moritzrp Oct 6, 2024
4cf91da
enhancement: add custom dumper to dump lists with indent
moritzrp Oct 6, 2024
1ede63f
tests: add truthy and umask string
moritzrp Oct 6, 2024
de10585
feat: exit defaults command early if no defaults configured
moritzrp Oct 6, 2024
23afb19
refactor: fix linting and formatting errors
moritzrp Oct 7, 2024
aac0f73
fix: handle case where no options are configured in argument_specs
moritzrp Oct 7, 2024
8409705
style: add docstring to test cases
moritzrp Oct 7, 2024
abf151f
refactor: restructure project
moritzrp Oct 7, 2024
b45abb7
refactor: defaults command use output_file option
moritzrp Oct 8, 2024
7919c24
Merge branch 'main' into feature/generate-defaults
rndmh3ro Oct 8, 2024
01e1d22
feat: add description comment to generated defaults
moritzrp Oct 9, 2024
99ef5f7
docs: add defaults information
moritzrp Oct 9, 2024
7e79e88
refactor: move overwrite up to manager class
moritzrp Oct 9, 2024
d178dd4
refactor: pass arguments instead of context
moritzrp Oct 9, 2024
9e65882
fix: dump truthy strings as strings
moritzrp Oct 9, 2024
7a042f5
refactor: bubble up exceptions
moritzrp Oct 9, 2024
07c1a76
Merge branch 'main' into feature/generate-defaults
rndmh3ro Oct 10, 2024
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
Prev Previous commit
Next Next commit
fix: handle case where no options are configured in argument_specs
  • Loading branch information
moritzrp committed Oct 7, 2024

Verified

This commit was signed with the committer’s verified signature.
richardlau Richard Lau
commit aac0f73417f0cea5e19e31f18196bbd1d954dd4c
5 changes: 4 additions & 1 deletion aar_doc/cli.py
Original file line number Diff line number Diff line change
@@ -477,7 +477,10 @@ def generate_defaults(ctx: typer.Context) -> dict[str, Any]:
argument_spec_data = ctx.obj["data"]["argument_specs"]

for entry_point in argument_spec_data:
for name, spec in argument_spec_data[entry_point]["options"].items():
options = argument_spec_data.get(entry_point, {}).get("options")
if not options:
continue
for name, spec in options.items():
value = spec.get("default")
if isinstance(value, str):
value = value.strip()
17 changes: 17 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -460,3 +460,20 @@ def test_generate_defaults_no_defaults():
result.output
== "No defaults configured in argument_specs. Nothing to do." + os.linesep
)


def test_generate_defaults_no_options():
"""
This test ensures that generating defaults for an argument_spec
without any options is handled as expected.
"""
role_path = ROLES_DIR / "no_options"
role_path = str(role_path)

result = runner.invoke(app, [role_path, "defaults"])

assert result.exit_code == 0
assert (
result.output
== "No defaults configured in argument_specs. Nothing to do." + os.linesep
)