Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get back green tests ! #13

Merged
merged 10 commits into from
Oct 19, 2023
11 changes: 11 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// container instruction for codespace users
{
"name": "Python 3",
"image": "mcr.microsoft.com/devcontainers/python:1-3.10-bullseye",
"features": {
"ghcr.io/devcontainers-contrib/features/nox:2": {},
"ghcr.io/devcontainers-contrib/features/pre-commit:2": {},
"ghcr.io/rocker-org/devcontainer-features/pandoc:1": {}
},
"postCreateCommand": "pre-commit install"
}
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: nikeee/setup-pandoc@v1
# waiting for https://github.com/nikeee/setup-pandoc/pull/8
# using 12rambau fork until then
- uses: 12rambau/setup-pandoc@test
- name: Setup Python
uses: actions/setup-python@v4
with:
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@
"logo": {
"text": "PyData Theme",
"image_dark": "_static/logo-dark.svg",
"alt_text": "PyData Theme",
},
"use_edit_page_button": True,
"show_toc_level": 1,
Expand Down
2 changes: 2 additions & 0 deletions docs/examples/gallery.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ Thanks for your support!
link: https://docs.pyvista.org
- title: Pastas
link: https://pastas.readthedocs.io/
- title: DecentralChain
link: https://docs.decentralchain.io/en/master/
```
19 changes: 0 additions & 19 deletions docs/examples/pydata.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,6 @@
"## Matplotlib"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"nbsphinx": "hidden"
},
"outputs": [],
"source": [
"import matplotlib\n",
"\n",
"# avoid warnings upon doc build\n",
"matplotlib.set_loglevel(\"critical\")"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -69,11 +55,6 @@
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"matplotlib.set_loglevel(\"critical\")\n",
"\n",
"rng = np.random.default_rng()\n",
"data = rng.standard_normal((3, 100))\n",
"fig, ax = plt.subplots()\n",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"devDependencies": {
"axe-core": "^4.6.3",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^3.4.2",
"css-loader": "^6.8.1",
"css-minimizer-webpack-plugin": "^4.2.2",
"dedent": "^0.7.0",
"html-webpack-plugin": "^4.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

.form-control {
background-color: var(--pst-color-background);
color: var(--pst-color-text-base);

&:focus,
&:focus-visible {
Expand Down
165 changes: 165 additions & 0 deletions src/pydata_sphinx_theme/locale/ru/LC_MESSAGES/sphinx.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# English translations for pydata-sphinx-theme.
# Copyright (C) 2023 PyData developers
# This file is distributed under the same license as the pydata-sphinx-theme project.
#
# Translators:
# Rambaud Pierrick <[email protected]>, 2023
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-02-16 14:32-0500\n"
"PO-Revision-Date: 2023-04-14 14:57+0000\n"
"Last-Translator: Rambaud Pierrick <[email protected]>, 2023\n"
"Language-Team: Russian (https://app.transifex.com/12rambau/teams/166811/ru/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.11.0\n"
"Language: ru\n"
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html:50
msgid "Skip to main content"
msgstr "Перейти к основному содержанию"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/search-button.html:7
#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/search.html:5
#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/search.html:28
msgid "Search"
msgstr "Поиск"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/search.html:8
msgid "Error"
msgstr "Ошибка"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/search.html:9
msgid "Please activate JavaScript to enable the search functionality."
msgstr "Активируйте JavaScript, чтобы включить функцию поиска."

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/breadcrumbs.html:12
msgid "Breadcrumbs"
msgstr "Навигационная цепочка"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/breadcrumbs.html:13
msgid "Breadcrumb"
msgstr "Хлебная крошка"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/breadcrumbs.html:16
msgid "Home"
msgstr "Главная"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/copyright.html:4
#, python-format
msgid "© <a href=\"%(path)s\">Copyright</a> %(copyright)s."
msgstr "© <a href=\\\"%(path)s\\\">Копирайт</a> %(copyright)s."

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/copyright.html:7
#, python-format
msgid "© Copyright %(copyright)s."
msgstr "© Копирайт %(copyright)s."

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/edit-this-page.html:9
#, python-format
msgid "Edit on %(provider)s"
msgstr "Редактировать на %(provider)s"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/edit-this-page.html:11
msgid "Edit"
msgstr "Редактировать"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:31
msgid "GitHub"
msgstr "GitHub"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:32
msgid "GitLab"
msgstr "GitLab"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:33
msgid "Bitbucket"
msgstr "Bitbucket"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:34
msgid "Twitter"
msgstr "Twitter"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html:2
msgid "Indices"
msgstr ""

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html:9
msgid "General Index"
msgstr "Общий указатель"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html:13
msgid "Global Module Index"
msgstr "Глобальный индекс модулей"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html:17
msgid "Python Module Index"
msgstr "Индекс модулей Python"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/last-updated.html:2
#, python-format
msgid "Last updated on %(last_updated)s."
msgstr "Последнее обновление %(last_updated)s."

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/navbar-nav.html:5
#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/navbar-nav.html:6
msgid "Site Navigation"
msgstr "Навигация по сайту"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/page-toc.html:4
msgid "On this page"
msgstr "На этой странице"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/sidebar-nav-bs.html:2
#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/sidebar-nav-bs.html:3
msgid "Section Navigation"
msgstr "В этом разделе"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/sourcelink.html:4
msgid "Show Source"
msgstr "Просмотр исходного кода"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/sphinx-version.html:3
#, python-format
msgid ""
"Created using <a href=\"https://www.sphinx-doc.org/\">Sphinx</a> "
"%(sphinx_version)s."
msgstr ""
"Создано с помощью <a href=\\\"https://www.sphinx-doc.org/\\\">Sphinx</a> "
"%(sphinx_version)s."

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/theme-switcher.html:5
msgid "light/dark"
msgstr "светлая/темная"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/theme-version.html:2
#, python-format
msgid ""
"Built with the <a href=\"https://pydata-sphinx-"
"theme.readthedocs.io/en/stable/index.html\">PyData Sphinx Theme</a> "
"%(theme_version)s."
msgstr ""
"Собрано с использованием темы <a href=\\\"https://pydata-sphinx-"
"theme.readthedocs.io/en/stable/index.html\\\">PyData Sphinx</a> "
"%(theme_version)s."

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:6
msgid "previous page"
msgstr "предыдущая страница"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:9
msgid "previous"
msgstr "назад"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:17
msgid "next page"
msgstr "следующая страница"

#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:19
msgid "next"
msgstr "далее"
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
{# As the version switcher will only work when JavaScript is enabled, we add it through JavaScript.
#}
{%- set button_id = unique_html_id("pst-version-switcher-button") -%}
{%- set dropdown_id = unique_html_id("pst-version-switcher-list") -%}
{# As the version switcher will only work when JavaScript is enabled, we add it through JavaScript. #}
<script>
document.write(`
<div class="version-switcher__container dropdown">
<button id="versionswitcherbutton" type="button" role="button" class="version-switcher__button btn btn-sm navbar-btn dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="listbox" aria-controls="versionswitcherlist" aria-label="Version switcher list">
<button id="{{ button_id }}"
type="button"
class="version-switcher__button btn btn-sm navbar-btn dropdown-toggle"
data-bs-toggle="dropdown"
aria-haspopup="listbox"
aria-controls="{{ dropdown_id }}"
aria-label="Version switcher list"
>
Choose version <!-- this text may get changed later by javascript -->
<span class="caret"></span>
</button>
<div id="versionswitcherlist" class="version-switcher__menu dropdown-menu list-group-flush py-0" role="listbox" aria-labelledby="versionswitcherbutton">
<!-- dropdown will be populated by javascript on page load -->
<div id="{{ dropdown_id }}"
class="version-switcher__menu dropdown-menu list-group-flush py-0"
role="listbox" aria-labelledby="{{ button_id }}">
<!-- dropdown will be populated by javascript on page load -->
</div>
</div>
`);
Expand Down
69 changes: 48 additions & 21 deletions src/pydata_sphinx_theme/toctree.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Methods to build the toctree used in the html pages."""

from functools import lru_cache
from typing import List, Union
from itertools import count
from typing import Iterator, List, Union
from urllib.parse import urlparse

import sphinx
Expand Down Expand Up @@ -37,27 +38,24 @@ def add_toctree_functions(
"""Add functions so Jinja templates can add toctree objects."""

@lru_cache(maxsize=None)
def generate_header_nav_html(
n_links_before_dropdown: int = 5, dropdown_text: str = "More"
) -> str:
"""Generate top-level links that are meant for the header navigation.

We use this function instead of the TocTree-based one used for the
sidebar because this one is much faster for generating the links and
we don't need the complexity of the full Sphinx TocTree.

This includes two kinds of links:

- Links to pages described listed in the root_doc TocTrees
- External links defined in theme configuration
def get_or_create_id_generator(base_id: str) -> Iterator[str]:
for n in count(start=1):
if n == 1:
yield base_id
else:
yield f"{base_id}-{n}"

Additionally it will create a dropdown list for several links after
a cutoff.
def unique_html_id(base_id: str):
"""Create an id that is unique from other ids created by this function at build time.

Parameters:
n_links_before_dropdown:The number of links to show before nesting the remaining links in a Dropdown element.
dropdown_text:Text of the dropdown element button.
The function works by sequentially returning "<base_id>", "<base_id>-2",
"<base_id>-3", etc. each time it is called.
"""
return next(get_or_create_id_generator(base_id))

@lru_cache(maxsize=None)
def generate_header_nav_before_dropdown(n_links_before_dropdown):
"""The cacheable part."""
try:
n_links_before_dropdown = int(n_links_before_dropdown)
except Exception:
Expand Down Expand Up @@ -148,14 +146,42 @@ def generate_header_nav_html(
for html in links_html[n_links_before_dropdown:]
]

return out, links_dropdown

def generate_header_nav_html(
n_links_before_dropdown: int = 5, dropdown_text: str = "More"
) -> str:
"""Generate top-level links that are meant for the header navigation.

We use this function instead of the TocTree-based one used for the
sidebar because this one is much faster for generating the links and
we don't need the complexity of the full Sphinx TocTree.

This includes two kinds of links:

- Links to pages described listed in the root_doc TocTrees
- External links defined in theme configuration

Additionally it will create a dropdown list for several links after
a cutoff.

Parameters:
n_links_before_dropdown:The number of links to show before nesting the remaining links in a Dropdown element.
dropdown_text:Text of the dropdown element button.
"""
out, links_dropdown = generate_header_nav_before_dropdown(
n_links_before_dropdown
)

if links_dropdown:
dropdown_id = unique_html_id("pst-nav-more-links")
links_dropdown_html = "\n".join(links_dropdown)
out += f"""
<li class="nav-item dropdown">
<button class="btn dropdown-toggle nav-item" type="button" data-bs-toggle="dropdown" aria-expanded="false" aria-controls="pst-header-nav-more-links">
<button class="btn dropdown-toggle nav-item" type="button" data-bs-toggle="dropdown" aria-expanded="false" aria-controls="{dropdown_id}">
{_(dropdown_text)}
</button>
<ul id="pst-header-nav-more-links" class="dropdown-menu">
<ul id="{dropdown_id}" class="dropdown-menu">
{links_dropdown_html}
</ul>
</li>
Expand Down Expand Up @@ -314,6 +340,7 @@ def navbar_align_class() -> List[str]:
)
return align_options[align]

context["unique_html_id"] = unique_html_id
context["generate_header_nav_html"] = generate_header_nav_html
context["generate_toctree_html"] = generate_toctree_html
context["generate_toc_html"] = generate_toc_html
Expand Down
Loading