Skip to content

Commit d90835b

Browse files
authored
Fix DLTypedField for pydata sphinx theme (#68)
1 parent 62a0648 commit d90835b

File tree

4 files changed

+9
-26
lines changed

4 files changed

+9
-26
lines changed

scanpydoc/definition_list_typed_field.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def handle_item(
6464

6565
field_name = nodes.field_name("", self.label)
6666
assert not self.can_collapse
67-
body_node = self.list_type()
67+
# “simple” for pydata sphinx theme
68+
body_node = self.list_type(classes=["simple"])
6869
for field_arg, content in items:
6970
body_node += handle_item(field_arg, content)
7071
field_body = nodes.field_body("", body_node)

tests/conftest.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
import linecache
33
import sys
44
import typing as t
5-
from tempfile import NamedTemporaryFile
65
from textwrap import dedent
76
from uuid import uuid4
87

98
import pytest
109
from docutils.nodes import document
11-
from docutils.writers import Writer
1210
from sphinx.application import Sphinx
13-
from sphinx.io import read_doc
1411
from sphinx.testing.fixtures import make_app, test_params # noqa
1512
from sphinx.testing.path import path as STP
16-
from sphinx.util import rst
17-
from sphinx.util.docutils import sphinx_domains
1813

1914

2015
@pytest.fixture
@@ -26,21 +21,6 @@ def make_app_setup(**conf) -> Sphinx:
2621
return make_app_setup
2722

2823

29-
@pytest.fixture
30-
def parse() -> t.Callable[[Sphinx, str], document]:
31-
def _parse(app: Sphinx, code: str) -> document:
32-
with NamedTemporaryFile("w+", suffix=".rst", dir=app.env.srcdir) as f:
33-
f.write(code)
34-
f.flush()
35-
app.env.prepare_settings(f.name)
36-
with sphinx_domains(app.env), rst.default_role(
37-
f.name, app.config.default_role
38-
):
39-
return read_doc(app, app.env, f.name)
40-
41-
return _parse
42-
43-
4424
@pytest.fixture
4525
def render() -> t.Callable[[Sphinx, document], str]:
4626
def _render(app: Sphinx, doc: document) -> str:

tests/test_definition_list_typed_field.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22
from sphinx.application import Sphinx
33
from sphinx.builders.html import StandaloneHTMLBuilder
4+
from sphinx.testing.restructuredtext import parse
45
from sphinx.writers.html import HTMLTranslator
56
from sphinx.writers.html5 import HTML5Translator
67

@@ -38,7 +39,7 @@ def test_apps_separate(app, make_app_setup):
3839

3940

4041
@pytest.mark.parametrize("code,n", [(params_code, 2), (params_code_single, 1)])
41-
def test_convert_params(app, parse, code, n):
42+
def test_convert_params(app, code, n):
4243
# the directive class is PyModuleLevel → PyObject → ObjectDescription
4344
# ObjectDescription.run uses a DocFieldTransformer to transform members
4445
# the signature of each Directive(
@@ -69,7 +70,7 @@ def test_convert_params(app, parse, code, n):
6970

7071
@pytest.mark.parametrize("translator", [HTMLTranslator, HTML5Translator])
7172
@pytest.mark.parametrize("code", [params_code, params_code_single])
72-
def test_render_params_html4(app, parse, render, translator, code):
73+
def test_render_params_html4(app, render, translator, code):
7374
app.config.html4_writer = translator is HTMLTranslator
7475
assert app.builder.__class__ is StandaloneHTMLBuilder
7576
assert app.builder.default_translator_class is translator

tests/test_elegant_typehints.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66

77

88
try: # 3.8 additions
9-
from typing import Literal, get_args, get_origin
9+
from typing import Literal, get_origin
1010
except ImportError:
11-
from typing_extensions import Literal, get_args, get_origin
11+
from typing_extensions import Literal, get_origin
1212

1313
import pytest
1414
import sphinx_autodoc_typehints as sat
1515
from sphinx.application import Sphinx
16+
from sphinx.testing.restructuredtext import parse
1617

1718
from scanpydoc.elegant_typehints.formatting import (
1819
_format_full,
@@ -182,7 +183,7 @@ def test_fully_qualified(app, _testmod):
182183
assert _format_full(t.Union[_testmod.Class, str], app.config) is None
183184

184185

185-
def test_classes_get_added(app, parse):
186+
def test_classes_get_added(app):
186187
doc = parse(app, r":annotation-full:`:py:class:\`str\``")
187188
assert doc[0].tagname == "paragraph"
188189
assert doc[0][0].tagname == "inline"

0 commit comments

Comments
 (0)