Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Start a sitemap.#99

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JulienPalard merged 2 commits intopython:masterfromJulienPalard:sitemap
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
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
26 changes: 26 additions & 0 deletionsbuild_docs.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,6 +48,8 @@
import sys
from datetime import datetime

import jinja2

HERE = Path(__file__).resolve().parent

try:
Expand DownExpand Up@@ -80,6 +82,10 @@ def __init__(self, name, branch, status, sphinx_version=DEFAULT_SPHINX_VERSION):
self.status = status
self.sphinx_version = sphinx_version

@property
def changefreq(self):
return {"EOL": "never", "security-fixes": "yearly"}.get(self.status, "daily")

@property
def url(self):
return "https://docs.python.org/{}/".format(self.name)
Expand DownExpand Up@@ -484,6 +490,24 @@ def build_venv(build_root, version):
return venv_path


def build_robots_txt(www_root):
with open(HERE / "templates" / "robots.txt") as robots_txt_template_file:
with open(os.path.join(www_root, "robots.txt"), "w") as robots_txt_file:
template = jinja2.Template(robots_txt_template_file.read())
robots_txt_file.write(
template.render(languages=LANGUAGES, versions=VERSIONS) + "\n"
)


def build_sitemap(www_root):
with open(HERE / "templates" / "sitemap.xml") as sitemap_template_file:
with open(os.path.join(www_root, "sitemap.xml"), "w") as sitemap_file:
template = jinja2.Template(sitemap_template_file.read())
sitemap_file.write(
template.render(languages=LANGUAGES, versions=VERSIONS) + "\n"
)


def copy_build_to_webroot(
build_root,
version,
Expand DownExpand Up@@ -768,6 +792,8 @@ def main():
)
if sentry_sdk:
sentry_sdk.capture_exception(err)
build_sitemap(args.www_root)
build_robots_txt(args.www_root)


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletionsrequirements.in
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
sentry-sdk
jinja2
22 changes: 22 additions & 0 deletionstemplates/robots.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
Sitemap: https://docs.python.org/sitemap.xml

# Prevent development and old documentation from showing up in search results.
User-agent: *
Disallow: /dev
Disallow: /release

# Disallow EOL versions
Disallow: /2/
Disallow: /2.0/
Disallow: /2.1/
Disallow: /2.2/
Disallow: /2.3/
Disallow: /2.4/
Disallow: /2.5/
Disallow: /2.6/
Disallow: /2.7/
Disallow: /3.0/
Disallow: /3.1/
Disallow: /3.2/
Disallow: /3.3/
Disallow: /3.4/
22 changes: 22 additions & 0 deletionstemplates/sitemap.xml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
{% for version in versions %}
{%- if version.status != "EOL" %}
<url>
<loc>https://docs.python.org/{{ version.name }}/</loc>
{% for language in languages -%}
<xhtml:link rel="alternate" hreflang="{{ language.iso639_tag.replace('_', '-') }}" href="https://docs.python.org/{{ language.tag }}/{{ version.name }}/"/>
{% endfor -%}
<changefreq>{{ version.changefreq }}</changefreq>
</url>
{% endif -%}
{% endfor %}
<url>
<loc>https://docs.python.org/3/</loc>
{% for language in languages -%}
<xhtml:link rel="alternate" hreflang="{{ language.iso639_tag.replace('_', '-') }}" href="https://docs.python.org/{{ language.tag }}/3/"/>
{% endfor -%}
<changefreq>daily</changefreq>
</url>
</urlset>

[8]ページ先頭

©2009-2025 Movatter.jp