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

Bound traitlets<5.10 and add test for issue observed in newer versions #54

Merged
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
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ dynamic = ["version"]
requires-python = ">=3.7"
dependencies = [
"sphinx>=4",
"traitlets>=4",
# FIXME: traitlets are upper bounded as a workaround to
# https://github.com/jupyterhub/autodoc-traits/issues/55
"traitlets>=4,<5.10",
]

[project.optional-dependencies]
Expand Down
67 changes: 66 additions & 1 deletion tests/docs/sample_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
autodoc_traits against. It does not contain tests.
"""

from traitlets import Bool
from traitlets import Bool, Dict, Instance, Integer, Unicode, Union
from traitlets.config.configurable import Configurable


Expand Down Expand Up @@ -81,3 +81,68 @@ def subclass_non_trait_property(self):

def subclass_method(self):
"""subclass_method docstring"""


class TraitTypesSampleConfigurable(Configurable):
"""TraitTypesSampleConfigurable docstring"""

trait_integer = Integer(
help="""trait_integer help text""",
config=True,
)
trait_integer_nohelp = Integer(
config=True,
)
trait_integer_noconfig = Integer(
help="""trait_integer_noconfig help text""",
)

trait_unicode = Unicode(
help="""trait_unicode help text""",
config=True,
)
trait_unicode_nohelp = Unicode(
config=True,
)
trait_unicode_noconfig = Unicode(
help="""trait_unicode_noconfig help text""",
)

trait_dict = Dict(
help="""trait_dict help text""",
config=True,
)
trait_dict_nohelp = Dict(
config=True,
)
trait_dict_noconfig = Dict(
help="""trait_dict_noconfig help text""",
)

trait_instance = Instance(
klass=SampleConfigurable,
help="""trait_instance help text""",
config=True,
)
trait_instance_nohelp = Instance(
klass=SampleConfigurable,
config=True,
)
trait_instance_noconfig = Instance(
klass=SampleConfigurable,
help="""trait_instance_noconfig help text""",
)

trait_union = Union(
[Integer(), Unicode()],
help="""trait_union help text""",
config=True,
)
trait_union_nohelp = Union(
[Integer(), Unicode()],
config=True,
)
trait_union_noconfig = Union(
[Integer(), Unicode()],
help="""trait_union_noconfig help text""",
)
15 changes: 15 additions & 0 deletions tests/docs/source/autotrait/help.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,18 @@ Test that we present the trait's provided ``help``.

.. autotrait:: sample_module.SampleConfigurable.trait
:noindex:

.. autotrait:: sample_module.TraitTypesSampleConfigurable.trait_integer
:noindex:

.. autotrait:: sample_module.TraitTypesSampleConfigurable.trait_unicode
:noindex:

.. autotrait:: sample_module.TraitTypesSampleConfigurable.trait_dict
:noindex:

.. autotrait:: sample_module.TraitTypesSampleConfigurable.trait_instance
:noindex:

.. autotrait:: sample_module.TraitTypesSampleConfigurable.trait_union
:noindex:
6 changes: 6 additions & 0 deletions tests/test_autodoc_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_sphinx_build_all_docs(temp_docs_dir, monkeypatch):
"SampleConfigurableSubclass docstring",
"SampleNonConfigurable docstring",
"SampleNonConfigurableSubclass docstring",
"TraitTypesSampleConfigurable docstring",
],
[],
),
Expand All @@ -107,6 +108,11 @@ def test_sphinx_build_all_docs(temp_docs_dir, monkeypatch):
[
"c.SampleConfigurable.trait",
"trait help text",
"trait_integer help text",
"trait_unicode help text",
"trait_dict help text",
"trait_instance help text",
"trait_union help text",
],
[],
),
Expand Down