Skip to content

Commit ac5f40b

Browse files
committed
address PR comments
1 parent a217195 commit ac5f40b

2 files changed

Lines changed: 35 additions & 16 deletions

File tree

scripts/docs/generate_nav.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import logging
1111
import sys
1212

13+
from datetime import datetime, timezone
1314
from pathlib import Path
1415

1516
from generate_all_doc_stubs import discover_clients
@@ -26,6 +27,19 @@
2627
NAV_START_MARKER = "# >>> AUTO-NAV >>>"
2728
NAV_END_MARKER = "# <<< AUTO-NAV <<<"
2829

30+
# Markers in zensical.toml that bound the generated `copyright` line.
31+
COPYRIGHT_START_MARKER = "# >>> AUTO-COPYRIGHT >>>"
32+
COPYRIGHT_END_MARKER = "# <<< AUTO-COPYRIGHT <<<"
33+
34+
35+
def _replace_block(config: str, start: str, end: str, body: str) -> str:
36+
"""Replace the content between two markers (inclusive of newlines)."""
37+
if start not in config or end not in config:
38+
raise ValueError(f"Markers not found. Expected '{start}' and '{end}'.")
39+
before, _, rest = config.partition(start)
40+
_, _, after = rest.partition(end)
41+
return f"{before}{start}\n{body}\n{end}{after}"
42+
2943

3044
def _toml_key(value: str) -> str:
3145
"""Quote a string for use as a TOML key, escaping as a basic string."""
@@ -91,18 +105,22 @@ def generate_nav(repo_root: Path) -> bool:
91105
logger.error(f"Failed to read {config_path.name}: {e}")
92106
return False
93107

94-
if NAV_START_MARKER not in config or NAV_END_MARKER not in config:
95-
logger.error(
96-
f"AUTO-NAV markers not found in {config_path.name}. "
97-
f"Expected '{NAV_START_MARKER}' and '{NAV_END_MARKER}'."
108+
year = datetime.now(timezone.utc).year
109+
copyright_line = (
110+
f'copyright = "&copy; {year}, Amazon Web Services, Inc. '
111+
f'or its affiliates. All rights reserved."'
112+
)
113+
try:
114+
updated = _replace_block(
115+
config, NAV_START_MARKER, NAV_END_MARKER, build_nav_block(clients_dir)
98116
)
117+
updated = _replace_block(
118+
updated, COPYRIGHT_START_MARKER, COPYRIGHT_END_MARKER, copyright_line
119+
)
120+
except ValueError as e:
121+
logger.error(f"Failed to update {config_path.name}: {e}")
99122
return False
100-
101-
nav_block = build_nav_block(clients_dir)
102-
103-
before, _, rest = config.partition(NAV_START_MARKER)
104-
_, _, after = rest.partition(NAV_END_MARKER)
105-
updated = f"{before}{NAV_START_MARKER}\n{nav_block}\n{NAV_END_MARKER}{after}"
123+
logger.info(f"Set copyright year to {year}")
106124

107125
try:
108126
config_path.write_text(updated)

zensical.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ site_name = "AWS SDK for Python"
55
site_description = "Documentation for AWS SDK for Python Clients"
66
site_author = "Amazon Web Services"
77
site_url = "https://docs.aws.amazon.com/sdk-for-python/v1/reference/"
8-
copyright = """
9-
Copyright &copy; 2026, Amazon Web Services, Inc
10-
"""
8+
# Copyright. The year below is regenerated by scripts/docs/generate_nav.py
9+
# (run via `make docs-generate`). Do not edit the year by hand.
10+
# >>> AUTO-COPYRIGHT >>>
11+
copyright = "&copy; 2026, Amazon Web Services, Inc. or its affiliates. All rights reserved."
12+
# <<< AUTO-COPYRIGHT <<<
1113

1214
# Repository
1315
repo_name = "awslabs/aws-sdk-python"
@@ -197,6 +199,8 @@ combine_header_slug = true
197199
[project.markdown_extensions.pymdownx.tasklist]
198200
custom_checkbox = true
199201
[project.markdown_extensions.pymdownx.tilde]
202+
[project.markdown_extensions.pymdownx.snippets]
203+
check_paths = true
200204

201205

202206
[project.plugins.mkdocstrings.handlers.python]
@@ -224,6 +228,3 @@ filters = [
224228
"!^deserialize",
225229
"!^serialize"
226230
]
227-
228-
[project.markdown_extensions.pymdownx.snippets]
229-
check_paths = true

0 commit comments

Comments
 (0)