Codebase list python-pallets-sphinx-themes / 8f9d5fc
Update upstream source from tag 'upstream/2.0.2' Update to upstream version '2.0.2' with Debian dir 0fe45c31ae552f14d6f194f4fcb10243a3816cfe Piotr Ożarowski 1 year, 7 months ago
7 changed file(s) with 119 addition(s) and 88 deletion(s). Raw diff Collapse all Expand all
0 Version 2.0.2
1 -------------
2
3 Released 2021-11-10
4
5 - Detect if Sphinx dirhtml builder is generating canonical URLs with
6 ".html" and replace with the correct dir URL. :issue:`47`
7 - ``canonical_url`` config is deprecated. Use Sphinx's built-in
8 ``html_baseurl`` config instead. :pr:`53`
9 - Address deprecations in Jinja 2.0. :pr:`54`
10
11
012 Version 2.0.1
113 -------------
214
00 Metadata-Version: 2.1
11 Name: Pallets-Sphinx-Themes
2 Version: 2.0.1
2 Version: 2.0.2
33 Summary: Sphinx themes for Pallets and related projects.
44 Home-page: https://github.com/pallets/pallets-sphinx-themes/
55 Author: Pallets
1010 Project-URL: Issue Tracker, https://github.com/pallets/pallets-sphinx-themes/issues/
1111 Project-URL: Twitter, https://twitter.com/PalletsTeam
1212 Project-URL: Chat, https://discord.gg/pallets
13 Description: Pallets Sphinx Themes
14 =====================
15
16 Themes for the Pallets projects. If you're writing an extension, use the
17 appropriate theme to make your documentation look consistent.
18
19 Available themes:
20
21 - flask
22 - jinja
23 - werkzeug
24 - click
25
26 Install this package:
27
28 .. code-block:: text
29
30 pip install Pallets-Sphinx-Themes
31
32 Enable the extension and choose the theme in ``docs/conf.py``:
33
34 .. code-block:: python
35
36 extensions = [
37 "pallets_sphinx_themes",
38 ...
39 ]
40
41 html_theme = "flask"
42
4313 Platform: UNKNOWN
4414 Classifier: Development Status :: 5 - Production/Stable
4515 Classifier: Framework :: Sphinx
5323 Classifier: Topic :: Software Development :: Documentation
5424 Requires-Python: >=3.6
5525 Description-Content-Type: text/x-rst
26 License-File: LICENSE.rst
27
28 Pallets Sphinx Themes
29 =====================
30
31 Themes for the Pallets projects. If you're writing an extension, use the
32 appropriate theme to make your documentation look consistent.
33
34 Available themes:
35
36 - flask
37 - jinja
38 - werkzeug
39 - click
40
41 Install this package:
42
43 .. code-block:: text
44
45 pip install Pallets-Sphinx-Themes
46
47 Enable the extension and choose the theme in ``docs/conf.py``:
48
49 .. code-block:: python
50
51 extensions = [
52 "pallets_sphinx_themes",
53 ...
54 ]
55
56 html_theme = "flask"
57
58
00 [metadata]
11 name = Pallets-Sphinx-Themes
2 version = 2.0.1
2 version = 2.0.2
33 url = https://github.com/pallets/pallets-sphinx-themes/
44 project_urls =
55 Donate = https://palletsprojects.com/donate
00 Metadata-Version: 2.1
11 Name: Pallets-Sphinx-Themes
2 Version: 2.0.1
2 Version: 2.0.2
33 Summary: Sphinx themes for Pallets and related projects.
44 Home-page: https://github.com/pallets/pallets-sphinx-themes/
55 Author: Pallets
1010 Project-URL: Issue Tracker, https://github.com/pallets/pallets-sphinx-themes/issues/
1111 Project-URL: Twitter, https://twitter.com/PalletsTeam
1212 Project-URL: Chat, https://discord.gg/pallets
13 Description: Pallets Sphinx Themes
14 =====================
15
16 Themes for the Pallets projects. If you're writing an extension, use the
17 appropriate theme to make your documentation look consistent.
18
19 Available themes:
20
21 - flask
22 - jinja
23 - werkzeug
24 - click
25
26 Install this package:
27
28 .. code-block:: text
29
30 pip install Pallets-Sphinx-Themes
31
32 Enable the extension and choose the theme in ``docs/conf.py``:
33
34 .. code-block:: python
35
36 extensions = [
37 "pallets_sphinx_themes",
38 ...
39 ]
40
41 html_theme = "flask"
42
4313 Platform: UNKNOWN
4414 Classifier: Development Status :: 5 - Production/Stable
4515 Classifier: Framework :: Sphinx
5323 Classifier: Topic :: Software Development :: Documentation
5424 Requires-Python: >=3.6
5525 Description-Content-Type: text/x-rst
26 License-File: LICENSE.rst
27
28 Pallets Sphinx Themes
29 =====================
30
31 Themes for the Pallets projects. If you're writing an extension, use the
32 appropriate theme to make your documentation look consistent.
33
34 Available themes:
35
36 - flask
37 - jinja
38 - werkzeug
39 - click
40
41 Install this package:
42
43 .. code-block:: text
44
45 pip install Pallets-Sphinx-Themes
46
47 Enable the extension and choose the theme in ``docs/conf.py``:
48
49 .. code-block:: python
50
51 extensions = [
52 "pallets_sphinx_themes",
53 ...
54 ]
55
56 html_theme = "flask"
57
58
44 import textwrap
55 from collections import namedtuple
66
7 from sphinx.application import Sphinx
78 from sphinx.builders._epub_base import EpubBuilder
9 from sphinx.builders.dirhtml import DirectoryHTMLBuilder
810 from sphinx.builders.singlehtml import SingleFileHTMLBuilder
911 from sphinx.errors import ExtensionError
1012
7173
7274
7375 @only_pallets_theme()
74 def canonical_url(app, pagename, templatename, context, doctree):
75 """Build the canonical URL for a page. Appends the path for the
76 page to the base URL specified by the
77 ``html_context["canonical_url"]`` config and stores it in
78 ``html_context["page_canonical_url"]``.
76 def canonical_url(app: Sphinx, pagename, templatename, context, doctree):
77 """Sphinx 1.8 builds a canonical URL if ``html_baseurl`` config is
78 set. However, it builds a URL ending with ".html" when using the
79 dirhtml builder, which is incorrect. Detect this and generate the
80 correct URL for each page.
81
82 Also accepts the custom, deprecated ``canonical_url`` config as the
83 base URL. This will be removed in version 2.1.
7984 """
80 base = context.get("canonical_url")
85 base = app.config.html_baseurl
8186
82 if not base:
87 if not base and context.get("canonical_url"):
88 import warnings
89
90 warnings.warn(
91 "'canonical_url' config is deprecated and will be removed"
92 " in Pallets-Sphinx-Themes 2.1. Set Sphinx's 'html_baseurl'"
93 " config instead.",
94 DeprecationWarning,
95 )
96 base = context["canonical_url"]
97
98 if (
99 not base
100 or not isinstance(app.builder, DirectoryHTMLBuilder)
101 or not context["pageurl"]
102 or not context["pageurl"].endswith(".html")
103 ):
83104 return
84105
106 # Fix pageurl for dirhtml builder if this version of Sphinx still
107 # generates .html URLs.
85108 target = app.builder.get_target_uri(pagename)
86 context["page_canonical_url"] = base + target
109 context["pageurl"] = base + target
87110
88111
89112 @only_pallets_theme()
156179 version = ".".join(release.split(".", version_length)[:version_length])
157180
158181 if placeholder:
159 version = "{}.{}".format(version, placeholder)
182 version = f"{version}.{placeholder}"
160183
161184 return release, version
162185
33 {{- metatags }}
44 <meta name="viewport" content="width=device-width, initial-scale=1">
55 {%- endset %}
6
7 {% block extrahead %}
8 {%- if page_canonical_url %}
9 <link rel="canonical" href="{{ page_canonical_url }}">
10 {%- endif %}
11 {{ super() }}
12 {%- endblock %}
136
147 {% block sidebarlogo %}
158 {% if pagename != "index" or theme_index_sidebar_logo %}
0 import io
10 import json
21 import os
32 from collections import namedtuple
43
5 from jinja2 import contextfunction
4 from jinja2 import pass_context
65 from packaging import version as pv
76
87 from .theme_check import only_pallets_theme
2625
2726 if isinstance(config_versions, str):
2827 if os.path.isfile(config_versions):
29 with io.open(config_versions, "rt", encoding="utf8") as f:
28 with open(config_versions, encoding="utf8") as f:
3029 config_versions = json.load(f)
3130 else:
3231 config_versions = json.loads(config_versions)
9695
9796
9897 def _is_version(value, placeholder="x"):
99 if value.endswith(".{}".format(placeholder)):
98 if value.endswith(f".{placeholder}"):
10099 value = value[: -(len(placeholder) + 1)]
101100
102101 try:
118117 if _is_version(slug):
119118 name = "Version " + name
120119
121 return super(DocVersion, cls).__new__(
122 cls, name, slug, version, latest, dev, current
123 )
120 return super().__new__(cls, name, slug, version, latest, dev, current)
124121
125 @contextfunction
122 @pass_context
126123 def href(self, context):
127124 pathto = context["pathto"]
128125 master_doc = context["master_doc"]
133130 path = builder.get_target_uri(pagename)
134131 return "/".join((master, "..", self.slug, path))
135132
136 @contextfunction
133 @pass_context
137134 def banner(self, context):
138135 if self.latest:
139136 return