|
15 | 15 | # sys.path.insert(0, os.path.abspath('.')) |
16 | 16 | from datetime import datetime |
17 | 17 | import subprocess |
| 18 | +import os |
18 | 19 |
|
19 | 20 | current_year = datetime.now().year |
20 | 21 | organization_name = "pyOpenSci" |
|
26 | 27 | copyright = f"{current_year}, {organization_name}" |
27 | 28 | author = "pyOpenSci Community" |
28 | 29 |
|
29 | | -language = "en" |
30 | | -languages = ["es", "jp"] |
31 | | -# languages excluding english |
32 | | -# (english is built without a subdirectory to not break already-existing inbound links) |
| 30 | +# language can later be overridden (eg with the -D flag) |
| 31 | +# but we need it set here so it can make it into the html_context |
| 32 | +language = os.environ.get("SPHINX_LANG", "en") |
| 33 | +languages = ["en", "es", "jp"] |
33 | 34 |
|
34 | 35 | # Get the latest Git tag - there might be a prettier way to do this but... |
35 | 36 | try: |
|
76 | 77 | {"href": "https://www.pyopensci.org/images/favicon.ico"}, |
77 | 78 | ] |
78 | 79 |
|
79 | | -# Link to our repo for easy PR/ editing |
| 80 | +html_baseurl = "https://www.pyopensci.org/python-package-guide/" |
| 81 | +if os.environ.get("SPHINX_DEV", False): |
| 82 | + # for links in language selector when developing locally |
| 83 | + html_baseurl = "/" |
| 84 | + |
80 | 85 | html_theme_options = { |
81 | 86 | "announcement": "<p><a href='https://www.pyopensci.org/about-peer-review/index.html'>We run peer review of scientific Python software. Learn more.</a></p>", |
82 | 87 | # "navbar_center": ["nav"], this can be a way to override the default navigation structure |
|
116 | 121 | "github_url": "https://github.com/pyopensci/python-package-guide", |
117 | 122 | "footer_start": ["code_of_conduct", "copyright"], |
118 | 123 | "footer_end": [], |
| 124 | + "navbar_persistent": ["language-selector", "search-button"] |
119 | 125 | } |
120 | 126 |
|
121 | 127 | html_context = { |
122 | 128 | "github_user": "pyopensci", |
123 | 129 | "github_repo": "python-package-guide", |
124 | 130 | "github_version": "main", |
125 | | - 'language': language, |
126 | | - 'languages': languages |
| 131 | + "language": language, |
| 132 | + "languages": languages, |
| 133 | + "base_url": html_baseurl, |
127 | 134 | } |
128 | 135 |
|
129 | 136 | # Add any paths that contain templates here, relative to this directory. |
|
147 | 154 | ] |
148 | 155 |
|
149 | 156 | # For sitemap generation |
150 | | -html_baseurl = "https://www.pyopensci.org/python-package-guide/" |
| 157 | + |
151 | 158 | sitemap_url_scheme = "{link}" |
152 | 159 |
|
153 | 160 | # -- Options for HTML output ------------------------------------------------- |
|
159 | 166 | html_static_path = ["_static"] |
160 | 167 | html_css_files = ["pyos.css"] |
161 | 168 | html_title = "Python Packaging Guide" |
162 | | -html_js_files = ["matomo.js"] |
| 169 | +html_js_files = ["matomo.js", "language_select.js"] |
163 | 170 |
|
164 | 171 |
|
165 | 172 | # Social cards |
|
0 commit comments