Skip to content
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
3 changes: 2 additions & 1 deletion scanpydoc/definition_list_typed_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def handle_item(

field_name = nodes.field_name("", self.label)
assert not self.can_collapse
body_node = self.list_type()
# “simple” for pydata sphinx theme
body_node = self.list_type(classes=["simple"])
for field_arg, content in items:
body_node += handle_item(field_arg, content)
field_body = nodes.field_body("", body_node)
Expand Down
20 changes: 0 additions & 20 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@
import linecache
import sys
import typing as t
from tempfile import NamedTemporaryFile
from textwrap import dedent
from uuid import uuid4

import pytest
from docutils.nodes import document
from docutils.writers import Writer
from sphinx.application import Sphinx
from sphinx.io import read_doc
from sphinx.testing.fixtures import make_app, test_params # noqa
from sphinx.testing.path import path as STP
from sphinx.util import rst
from sphinx.util.docutils import sphinx_domains


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


@pytest.fixture
def parse() -> t.Callable[[Sphinx, str], document]:
def _parse(app: Sphinx, code: str) -> document:
with NamedTemporaryFile("w+", suffix=".rst", dir=app.env.srcdir) as f:
f.write(code)
f.flush()
app.env.prepare_settings(f.name)
with sphinx_domains(app.env), rst.default_role(
f.name, app.config.default_role
):
return read_doc(app, app.env, f.name)

return _parse


@pytest.fixture
def render() -> t.Callable[[Sphinx, document], str]:
def _render(app: Sphinx, doc: document) -> str:
Expand Down
5 changes: 3 additions & 2 deletions tests/test_definition_list_typed_field.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from sphinx.application import Sphinx
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.testing.restructuredtext import parse
from sphinx.writers.html import HTMLTranslator
from sphinx.writers.html5 import HTML5Translator

Expand Down Expand Up @@ -38,7 +39,7 @@ def test_apps_separate(app, make_app_setup):


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

@pytest.mark.parametrize("translator", [HTMLTranslator, HTML5Translator])
@pytest.mark.parametrize("code", [params_code, params_code_single])
def test_render_params_html4(app, parse, render, translator, code):
def test_render_params_html4(app, render, translator, code):
app.config.html4_writer = translator is HTMLTranslator
assert app.builder.__class__ is StandaloneHTMLBuilder
assert app.builder.default_translator_class is translator
Expand Down
7 changes: 4 additions & 3 deletions tests/test_elegant_typehints.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@


try: # 3.8 additions
from typing import Literal, get_args, get_origin
from typing import Literal, get_origin
except ImportError:
from typing_extensions import Literal, get_args, get_origin
from typing_extensions import Literal, get_origin

import pytest
import sphinx_autodoc_typehints as sat
from sphinx.application import Sphinx
from sphinx.testing.restructuredtext import parse

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


def test_classes_get_added(app, parse):
def test_classes_get_added(app):
doc = parse(app, r":annotation-full:`:py:class:\`str\``")
assert doc[0].tagname == "paragraph"
assert doc[0][0].tagname == "inline"
Expand Down