From c69246a8ed452f29f8d4f0c6a695fb33fecc3796 Mon Sep 17 00:00:00 2001 From: Tilly Woodfield <22456167+tillywoodfield@users.noreply.github.com> Date: Thu, 3 Oct 2024 15:41:25 +0300 Subject: [PATCH 01/10] ci: include docs directory in linting --- .github/workflows/ci.yml | 26 ++++++++++++++------------ README.md | 8 ++++---- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8582934..d4f92d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,15 +5,17 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: Install dev requirements - run: pip install -r requirements_dev.txt - - name: Check black - run: black --check iati_sphinx_theme - - name: Check isort - run: isort --check-only iati_sphinx_theme - - name: Check flake8 - run: flake8 iati_sphinx_theme + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Install dev requirements + run: pip install -r requirements_dev.txt + - name: Check black + run: black --check iati_sphinx_theme docs + - name: Check isort + run: isort --check-only iati_sphinx_theme docs + - name: Check flake8 + run: flake8 iati_sphinx_theme docs + - name: Check mypy + run: mypy iati_sphinx_theme docs diff --git a/README.md b/README.md index 5ce9ff0..7a57451 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,10 @@ pip install -r requirements_dev.txt ### Run linting ``` -black iati_sphinx_theme/ -isort iati_sphinx_theme/ -flake8 iati_sphinx_theme/ -mypy iati_sphinx_theme/ +black iati_sphinx_theme/ docs/ +isort iati_sphinx_theme/ docs/ +flake8 iati_sphinx_theme/ docs/ +mypy iati_sphinx_theme/ docs/ ``` ### Documentation with live preview From 09118e6f8173fe1fbeb271aab2cae12d1e5acbae Mon Sep 17 00:00:00 2001 From: Tilly Woodfield <22456167+tillywoodfield@users.noreply.github.com> Date: Tue, 8 Oct 2024 11:27:00 +0300 Subject: [PATCH 02/10] feat: make theme translatable --- .gitignore | 4 ++++ babel.cfg | 6 ++++++ docs/conf.py | 3 +-- docs/index.rst | 6 ++++++ iati_sphinx_theme/__init__.py | 2 ++ iati_sphinx_theme/footer.html | 12 ++++++------ iati_sphinx_theme/header.html | 24 ++++++++++++------------ iati_sphinx_theme/language-switcher.html | 2 +- iati_sphinx_theme/relations.html | 4 ++-- iati_sphinx_theme/search.html | 2 +- iati_sphinx_theme/theme.conf | 1 + pyproject.toml | 3 ++- requirements_dev.txt | 14 ++++++++++++-- 13 files changed, 56 insertions(+), 27 deletions(-) create mode 100644 babel.cfg diff --git a/.gitignore b/.gitignore index 9f60a5f..5196656 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ dist # Node node_modules + +# Translations +.doctrees +*.mo diff --git a/babel.cfg b/babel.cfg new file mode 100644 index 0000000..c835a5d --- /dev/null +++ b/babel.cfg @@ -0,0 +1,6 @@ +# See https://github.com/python-babel/babel/blob/2a1709a7768f6f07c3d2dbfdb03d3c8a6bd80aef/docs/messages.rst#extraction-method-mapping-and-configuration +[python: **.py] +[jinja2: **.html] +encoding = utf-8 +ignore_tags = script,style +include_attrs = alt title summary placeholder diff --git a/docs/conf.py b/docs/conf.py index 65dbebd..1292eee 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -7,7 +7,6 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information project = "IATI Sphinx Theme" -copyright = "2024 IATI Secretariat" author = "IATI Secretariat" language = "en" @@ -22,13 +21,13 @@ templates_path = ["_templates"] exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] - # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output html_theme = "iati_sphinx_theme" html_theme_options = { "github_repository": "https://github.com/IATI/sphinx-theme", + "header_title_text": "IATI Sphinx Theme", "languages": { "en": "English", }, diff --git a/docs/index.rst b/docs/index.rst index 2350c4d..1d654dc 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -36,6 +36,7 @@ This theme has multiple options, which can be configured using the :code:`html_t html_theme_options = { "github_repository": "https://github.com/organisation/repository", + "header_title_text": "Title", "plausible_domain": "example.com" } @@ -46,6 +47,11 @@ There is more information on each option below. This should be a link to the Github repository for the documentation site, and is used to link to the source code in the footer of the site. +:code:`header_title_text` +------------------------- + +The site's title to display in the header and navigation. + :code:`plausible_domain` ------------------------ diff --git a/iati_sphinx_theme/__init__.py b/iati_sphinx_theme/__init__.py index ef71b57..7b819ac 100644 --- a/iati_sphinx_theme/__init__.py +++ b/iati_sphinx_theme/__init__.py @@ -11,3 +11,5 @@ def setup(app: sphinx.application.Sphinx) -> None: app.config["html_favicon"] = "static/favicon-16x16.png" app.config["html_context"]["language"] = app.config["language"] app.add_js_file("language-switcher.js") + locale_path = path.join(path.abspath(path.dirname(__file__)), "locale") + app.add_message_catalog("sphinx", locale_path) diff --git a/iati_sphinx_theme/footer.html b/iati_sphinx_theme/footer.html index b30f300..030a53e 100644 --- a/iati_sphinx_theme/footer.html +++ b/iati_sphinx_theme/footer.html @@ -4,13 +4,13 @@