Skip to content

Commit

Permalink
Allow Sphinx 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Mar 15, 2024
1 parent 9f17c89 commit 21c41b2
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 18 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
@@ -1,7 +1,7 @@
default-values>=0.5.0
dict2css>=0.2.3
docutils==0.16
docutils>=0.16
domdf-python-tools>=2.9.0
sphinx<3.6.0,>=3.2.0
sphinx<5,>=3.2.0
sphinx-panels>=0.5.1
sphinx-toolbox>=2.13.0
2 changes: 1 addition & 1 deletion tests/conftest.py
Expand Up @@ -6,4 +6,4 @@
import types
types.Union = types.UnionType

pytest_plugins = ("coincidence", )
pytest_plugins = ("coincidence", "sphinx_toolbox.testing")
18 changes: 11 additions & 7 deletions tests/test_output/test_output.py
Expand Up @@ -8,7 +8,7 @@
from coincidence.regressions import AdvancedFileRegressionFixture
from domdf_python_tools.paths import PathPlus
from domdf_python_tools.stringlist import StringList
from sphinx_toolbox.testing import check_html_regression
from sphinx_toolbox.testing import HTMLRegressionFixture, LaTeXRegressionFixture, check_html_regression


def test_build_example(app):
Expand All @@ -18,20 +18,24 @@ def test_build_example(app):

@pytest.mark.sphinx("html", srcdir="test-root")
@pytest.mark.parametrize("page", ["index.html"], indirect=True)
def test_html_output(page: BeautifulSoup, advanced_file_regression: AdvancedFileRegressionFixture):
check_html_regression(page, advanced_file_regression)
def test_html_output(page: BeautifulSoup, html_regression: HTMLRegressionFixture):
html_regression.check(page, jinja2=True)


@pytest.mark.sphinx("latex", srcdir="test-root")
def test_latex_output(app, advanced_file_regression: AdvancedFileRegressionFixture):
def test_latex_output(
app,
latex_regression: LaTeXRegressionFixture,
):
random.seed("5678")

assert app.builder.name.lower() == "latex"
app.build()

output_file = PathPlus(app.outdir / "sphinx-highlights-demo.tex")
content = str(StringList(output_file.read_lines())).replace("\\sphinxAtStartPar\n", '')
advanced_file_regression.check(
re.sub(r"\\date{.*}", r"\\date{Mar 11, 2021}", content),
extension=".tex",
latex_regression.check(
# re.sub(r"\\date{.*}", r"\\date{Mar 11, 2021}", content),
content,
jinja2=True,
)
15 changes: 10 additions & 5 deletions tests/test_output/test_output_/test_html_output_index_html_.html
@@ -1,9 +1,14 @@
{% set section = ("section", "section") if docutils_version >= (0, 17) else ('div class="section"', "div") -%}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title>
{% if docutils_version[1] == 18 %}<meta content="Docutils 0.18.1: http://docutils.sourceforge.net/" name="generator"/>
{% elif docutils_version[1] == 17 %}<meta content="Docutils 0.17.1: http://docutils.sourceforge.net/" name="generator"/>
{% elif docutils_version[1] == 19 %}<meta content="Docutils 0.19: https://docutils.sourceforge.io/" name="generator"/>
{% elif docutils_version[1] == 20 %}<meta content="width=device-width, initial-scale=1" name="viewport"/>
{% endif %}<title>
domdf_python_tools — sphinx-highlights-demo documentation
</title>
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js">
Expand All @@ -21,14 +26,14 @@
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="domdf-python-tools">
<{{ section[0] }} id="domdf-python-tools">
<h1>
domdf_python_tools
<a class="headerlink" href="#domdf-python-tools" title="Permalink to this headline">
</a>
</h1>
<div class="section" id="highlights">
<{{ section[0] }} id="highlights">
<h2>
Highlights
<a class="headerlink" href="#highlights" title="Permalink to this headline">
Expand Down Expand Up @@ -176,8 +181,8 @@ <h2>
</div>
<p>
</p>
</div>
</div>
</{{ section[1] }}>
</{{ section[1] }}>
</div>
</div>
</div>
Expand Down
23 changes: 20 additions & 3 deletions tests/test_output/test_output_/test_latex_output.tex
Expand Up @@ -4,7 +4,15 @@
\ifdefined\pdfpxdimen
\let\sphinxpxdimen\pdfpxdimen\else\newdimen\sphinxpxdimen
\fi \sphinxpxdimen=.75bp\relax

<% if sphinx_version >= (4, 0) %>\ifdefined\pdfimageresolution
\pdfimageresolution= \numexpr \dimexpr1in\relax/\sphinxpxdimen\relax
\fi
%% let collapsable pdf bookmarks panel have high depth per default
\PassOptionsToPackage{bookmarksdepth=5}{hyperref}<% if sphinx_version >= (5, 3) %>
<% endif %><% if sphinx_version >= (6, 0) %>
\PassOptionsToPackage{booktabs}{sphinx}
\PassOptionsToPackage{colorrows}{sphinx}<% endif %>
<% endif %>
\PassOptionsToPackage{warn}{textcomp}
\usepackage[utf8]{inputenc}
\ifdefined\DeclareUnicodeCharacter
Expand All @@ -26,7 +34,13 @@
\usepackage{amsmath,amssymb,amstext}
\usepackage{babel}

<%+ if sphinx_version >= (4, 0) %>

\usepackage{tgtermes}
\usepackage{tgheros}
\renewcommand{\ttdefault}{txtt}

<% else %>

\usepackage{times}
\expandafter\ifx\csname T@LGR\endcsname\relax
Expand All @@ -50,12 +64,15 @@
\substitutefont{X2}{\sfdefault}{cmss}
\substitutefont{X2}{\ttdefault}{cmtt}
\fi

<% endif %>

\usepackage[Bjarne]{fncychap}
\usepackage{sphinx}

<% if sphinx_version >= (4, 0) %>
\fvset{fontsize=auto}
<% else %>
\fvset{fontsize=\small}
<% endif -%>
\usepackage{geometry}


Expand Down

0 comments on commit 21c41b2

Please sign in to comment.