Skip to content

Commit 5099c3d

Browse files
committed
fixed a bug where it would show anchor values
1 parent c25cf10 commit 5099c3d

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

generate_argument_specs.py

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,9 +1814,25 @@ def ignore_aliases(self, data):
18141814
# Disable YAML references/anchors (like *id001) for cleaner output
18151815
return True
18161816

1817+
def generate_anchor(self, node):
1818+
# Prevent anchor generation entirely
1819+
return None
1820+
1821+
def ignore_aliases(self, data):
1822+
# Disable YAML references/anchors (like *id001) for cleaner output
1823+
return True
1824+
1825+
def generate_anchor(self, node):
1826+
# Prevent anchor generation entirely
1827+
return None
1828+
1829+
# Deep copy the specs to avoid any shared object references that could create anchors
1830+
import copy
1831+
specs_copy = copy.deepcopy(specs)
1832+
18171833
# Configure YAML output for better readability
18181834
yaml_content = yaml.dump(
1819-
specs,
1835+
specs_copy,
18201836
Dumper=CustomDumper,
18211837
default_flow_style=False,
18221838
sort_keys=False,
@@ -1825,6 +1841,7 @@ def ignore_aliases(self, data):
18251841
allow_unicode=True,
18261842
)
18271843

1844+
18281845
# Add document markers
18291846
return f"---\n{yaml_content}...\n"
18301847

@@ -2575,9 +2592,21 @@ def write_line_break(self, data=None):
25752592
def increase_indent(self, flow=False, indentless=False):
25762593
return super().increase_indent(flow, False)
25772594

2595+
def ignore_aliases(self, data):
2596+
# Disable YAML references/anchors (like *id001) for cleaner output
2597+
return True
2598+
2599+
def generate_anchor(self, node):
2600+
# Prevent anchor generation entirely
2601+
return None
2602+
2603+
# Deep copy the specs to avoid any shared object references that could create anchors
2604+
import copy
2605+
specs_copy = copy.deepcopy(specs)
2606+
25782607
# Configure YAML output for better readability
25792608
yaml_content = yaml.dump(
2580-
specs,
2609+
specs_copy,
25812610
Dumper=CustomDumper,
25822611
default_flow_style=False,
25832612
sort_keys=False,
@@ -2586,6 +2615,7 @@ def increase_indent(self, flow=False, indentless=False):
25862615
allow_unicode=True,
25872616
)
25882617

2618+
25892619
# Add YAML document markers and ensure proper formatting
25902620
return f"---\n{yaml_content}...\n"
25912621

@@ -2654,10 +2684,26 @@ def create_example_config():
26542684
}
26552685
}
26562686

2657-
return yaml.dump(
2658-
example_config, default_flow_style=False, sort_keys=False, indent=2
2687+
# Deep copy to avoid any shared references
2688+
import copy
2689+
config_copy = copy.deepcopy(example_config)
2690+
2691+
yaml_content = yaml.dump(
2692+
config_copy, default_flow_style=False, sort_keys=False, indent=2
26592693
)
26602694

2695+
# Remove any YAML anchor/reference lines that may have slipped through
2696+
lines = yaml_content.split('\n')
2697+
cleaned_lines = []
2698+
for line in lines:
2699+
# Skip lines that are just YAML anchors (&id001) or references (*id001)
2700+
stripped = line.strip()
2701+
if not (stripped.startswith('&') and len(stripped.split()) == 1) and \
2702+
not (stripped.startswith('*') and len(stripped.split()) == 1):
2703+
cleaned_lines.append(line)
2704+
2705+
return '\n'.join(cleaned_lines)
2706+
26612707

26622708
def main():
26632709
parser = argparse.ArgumentParser(

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "ansible-argument-spec-generator"
7-
version = "1.0.0.post1"
7+
version = "1.0.1"
88
authors = [
99
{name = "David Danielsson", email = "djdanielsson@users.noreply.github.com"},
1010
]

0 commit comments

Comments
 (0)