Skip to content

Commit c472be7

Browse files
committed
make json in example_block() optional
1 parent 80e7988 commit c472be7

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/ssvc/doc_helpers.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ def example_block_tabbed(dp: SsvcDecisionPoint, indent=4) -> str:
6969
return "\n".join(rows)
7070

7171

72-
def example_block(dp: SsvcDecisionPoint, indent=4) -> str:
72+
def example_block(
73+
dp: SsvcDecisionPoint, indent: int = 4, include_json: bool = True
74+
) -> str:
7375
"""Given a decision point, return a markdown block that contains an example of the decision point."""
7476

75-
indent_ = " " * 4
77+
indent_ = " " * indent
7678
rows = []
7779
rows.append(f'!!! note "{dp.name} v{dp.version}"')
7880
rows.append("")
@@ -81,12 +83,11 @@ def example_block(dp: SsvcDecisionPoint, indent=4) -> str:
8183
rows.append(indent_ + row)
8284
rows.append("")
8385

84-
rows.append(
85-
indent_ + f'??? example "{dp.name} v{dp.version} JSON Example"'
86-
)
87-
rows.append("")
88-
for row in json_example(dp, indent=4).splitlines():
89-
rows.append(indent_ + row)
86+
if include_json:
87+
rows.append(indent_ + f'??? example "{dp.name} v{dp.version} JSON Example"')
88+
rows.append("")
89+
for row in json_example(dp, indent=4).splitlines():
90+
rows.append(indent_ + row)
9091

9192
return "\n".join(rows)
9293

0 commit comments

Comments
 (0)