Skip to content

Commit 119459e

Browse files
committed
Start a sitemap.
1 parent c23b401 commit 119459e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

build_docs.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
import sys
4949
from datetime import datetime
5050

51+
import jinja2
52+
5153
HERE = Path(__file__).resolve().parent
5254

5355
try:
@@ -80,6 +82,10 @@ def __init__(self, name, branch, status, sphinx_version=DEFAULT_SPHINX_VERSION):
8082
self.status = status
8183
self.sphinx_version = sphinx_version
8284

85+
@property
86+
def changefreq(self):
87+
return {"EOL": "never", "security-fixes": "yearly"}.get(self.status, "daily")
88+
8389
@property
8490
def url(self):
8591
return "https://docs.python.org/{}/".format(self.name)
@@ -484,6 +490,13 @@ def build_venv(build_root, version):
484490
return venv_path
485491

486492

493+
def build_sitemap(www_root):
494+
with open(HERE / "templates" / "sitemap.xml") as sitemap_template_file:
495+
with open(os.path.join(www_root, "sitemap.xml"), "w") as sitemap_file:
496+
template = jinja2.Template(sitemap_template_file.read())
497+
sitemap_file.write(template.render(languages=LANGUAGES, versions=VERSIONS))
498+
499+
487500
def copy_build_to_webroot(
488501
build_root,
489502
version,
@@ -768,6 +781,7 @@ def main():
768781
)
769782
if sentry_sdk:
770783
sentry_sdk.capture_exception(err)
784+
build_sitemap(args.www_root)
771785

772786

773787
if __name__ == "__main__":

requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
sentry-sdk
2+
jinja2

0 commit comments

Comments
 (0)