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

🔧 test fixes for sphinx 7.4 #945

Merged
merged 10 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
40 changes: 20 additions & 20 deletions .github/workflows/test-formats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@ jobs:
- name: Build docs
run: |
sphinx-build -nW --keep-going -b ${{ matrix.format }} docs/ docs/_build/${{ matrix.format }}

- name: Make PDF
uses: xu-cheng/latex-action@v2
with:
working_directory: docs/_build/latex
root_file: "mystparser.tex"
# https://github.com/marketplace/actions/github-action-for-latex#it-fails-due-to-xindy-cannot-be-found
pre_compile: |
ln -sf /opt/texlive/texdir/texmf-dist/scripts/xindy/xindy.pl /opt/texlive/texdir/bin/x86_64-linuxmusl/xindy
ln -sf /opt/texlive/texdir/texmf-dist/scripts/xindy/texindy.pl /opt/texlive/texdir/bin/x86_64-linuxmusl/texindy
wget https://sourceforge.net/projects/xindy/files/xindy-source-components/2.4/xindy-kernel-3.0.tar.gz
tar xf xindy-kernel-3.0.tar.gz
cd xindy-kernel-3.0/src
apk add make
apk add clisp --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
make
cp -f xindy.mem /opt/texlive/texdir/bin/x86_64-linuxmusl/
cd ../../
env:
XINDYOPTS: -L english -C utf8 -M sphinx.xdy
# TODO https://github.com/sphinx-doc/sphinx/issues/12594
# - name: Make PDF
# uses: xu-cheng/latex-action@v2
# with:
# working_directory: docs/_build/latex
# root_file: "mystparser.tex"
# # https://github.com/marketplace/actions/github-action-for-latex#it-fails-due-to-xindy-cannot-be-found
# pre_compile: |
# ln -sf /opt/texlive/texdir/texmf-dist/scripts/xindy/xindy.pl /opt/texlive/texdir/bin/x86_64-linuxmusl/xindy
# ln -sf /opt/texlive/texdir/texmf-dist/scripts/xindy/texindy.pl /opt/texlive/texdir/bin/x86_64-linuxmusl/texindy
# wget https://sourceforge.net/projects/xindy/files/xindy-source-components/2.4/xindy-kernel-3.0.tar.gz
# tar xf xindy-kernel-3.0.tar.gz
# cd xindy-kernel-3.0/src
# apk add make
# apk add clisp --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
# make
# cp -f xindy.mem /opt/texlive/texdir/bin/x86_64-linuxmusl/
# cd ../../
# env:
# XINDYOPTS: -L english -C utf8 -M sphinx.xdy
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repos:
args: [--config-file=pyproject.toml]
additional_dependencies:
- types-urllib3
- sphinx~=7.3
- sphinx~=7.4
- markdown-it-py~=3.0
- mdit-py-plugins~=0.4.0
files: >
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Full Changelog: [v0.18.1...v0.19.0](https://github.com/executablebooks/MyST-Pars
### 📚 Rewritten documentation

The documentation has been almost completely rewritten,
with a clearer structure, many more examples, rich hover tips, and a new live preview page ⚡️ (powered by [pyscript](https://pyscript.readthedocs.io/), <gh-pr:717>).
with a clearer structure, many more examples, rich hover tips, and a new live preview page (powered by [pyscript](https://pyscript.readthedocs.io/), <gh-pr:717>).

The code base API is also now fully documented by [sphinx-autodoc2](https://sphinx-autodoc2.readthedocs.io/), which even allows for MyST docstrings! (<gh-pr:704>).

Expand Down
2 changes: 1 addition & 1 deletion docs/develop/background.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ but there is no community standard around various syntactic choices for these fe
Sphinx is a documentation generation framework written in Python. It heavily-utilizes
reStructuredText syntax, which is another markup language for writing documents. In
particular, Sphinx defines two extension points that are extremely useful:
**{ref}`in-line roles<sphinx:rst-roles-alt>`** and **{ref}`block-level directives <sphinx:rst-directives>`**.
**{ref}`in-line roles<sphinx:rst-roles>`** and **{ref}`block-level directives <sphinx:rst-directives>`**.

**This project is an attempt at combining the simplicity and readability of Markdown
with the power and flexibility of reStructuredText and the Sphinx platform.** It
Expand Down
2 changes: 1 addition & 1 deletion docs/live-preview.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ py-config:
- pygments
---

# ⚡ Live Preview
# ⚡ Live Preview

This is a live preview of the MyST Markdown [docutils renderer](docutils.md).
You can edit the text/configuration below and see the live output.
Expand Down
2 changes: 1 addition & 1 deletion myst_parser/mdit_to_docutils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ def render_dl(self, token: SyntaxTreeNode) -> None:
term = make_glossary_term(
self.sphinx_env, # type: ignore[arg-type]
term.children,
None, # type: ignore[arg-type]
None,
term.source,
term.line,
node_id=None,
Expand Down
9 changes: 6 additions & 3 deletions myst_parser/sphinx_ext/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from typing import Any

import sphinx
from docutils import nodes
from sphinx.application import Sphinx

Expand Down Expand Up @@ -42,9 +43,11 @@ def setup_sphinx(app: Sphinx, load_parser: bool = False) -> None:

# override only the html writer visit methods for rubric, to use the "level" attribute
# this allows for nested headers to be correctly rendered
app.add_node(
nodes.rubric, override=True, html=(visit_rubric_html, depart_rubric_html)
)
if sphinx.version_info < (7, 4):
# This is now added in sphinx: https://github.com/sphinx-doc/sphinx/pull/12506
app.add_node(
nodes.rubric, override=True, html=(visit_rubric_html, depart_rubric_html)
)
# override only the html writer visit methods for container,
# to remove the "container" class for divs
# this avoids CSS clashes with the bootstrap theme
Expand Down
4 changes: 2 additions & 2 deletions myst_parser/sphinx_ext/mathjax.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

if "mathjax3_config" in app.config:
# sphinx 4 + mathjax 3
app.config.mathjax3_config = app.config.mathjax3_config or {} # type: ignore[attr-defined]
app.config.mathjax3_config = app.config.mathjax3_config or {}
app.config.mathjax3_config.setdefault("options", {})
if (
"processHtmlClass" in app.config.mathjax3_config["options"]
Expand All @@ -77,7 +77,7 @@
app.config.mathjax3_config["options"]["processHtmlClass"] = mjax_classes
elif "mathjax_config" in app.config:
# sphinx 3 + mathjax 2
app.config.mathjax_config = app.config.mathjax_config or {} # type: ignore[attr-defined]
app.config.mathjax_config = app.config.mathjax_config or {}

Check warning on line 80 in myst_parser/sphinx_ext/mathjax.py

View check run for this annotation

Codecov / codecov/patch

myst_parser/sphinx_ext/mathjax.py#L80

Added line #L80 was not covered by tests
app.config.mathjax_config.setdefault("tex2jax", {})
if (
"processClass" in app.config.mathjax_config["tex2jax"]
Expand Down
4 changes: 4 additions & 0 deletions tests/test_sphinx/test_sphinx_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ def test_gettext(
output = re.sub(r"POT-Creation-Date: [0-9: +-]+", "POT-Creation-Date: ", output)
output = re.sub(r"Copyright \(C\) [0-9]{4}", "Copyright (C) XXXX", output)

if sphinx.version_info < (7, 4):
output = output.replace("Python ", "Project name not set ")
file_regression.check(output, extension=".pot")


Expand Down Expand Up @@ -512,6 +514,8 @@ def test_gettext_additional_targets(
output = re.sub(r"POT-Creation-Date: [0-9: +-]+", "POT-Creation-Date: ", output)
output = re.sub(r"Copyright \(C\) [0-9]{4}", "Copyright (C) XXXX", output)

if sphinx.version_info < (7, 4):
output = output.replace("Python ", "Project name not set ")
file_regression.check(output, extension=".pot")


Expand Down
4 changes: 2 additions & 2 deletions tests/test_sphinx/test_sphinx_builds/test_gettext.pot
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) XXXX, Executable Book Project
# This file is distributed under the same license as the Python package.
# This file is distributed under the same license as the Project name not set package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python \n"
"Project-Id-Version: Project name not set \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) XXXX, Executable Book Project
# This file is distributed under the same license as the Python package.
# This file is distributed under the same license as the Project name not set package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python \n"
"Project-Id-Version: Project name not set \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: \n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ commands = pytest {posargs}
extras =
linkify
rtd
whitelist_externals =
allowlist_externals =
rm
echo
passenv =
Expand Down