diff --git a/pyproject.toml b/pyproject.toml index f0d5357..6d263a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] diff --git a/tests/docs/sample_module.py b/tests/docs/sample_module.py index 3738b24..c7c933f 100644 --- a/tests/docs/sample_module.py +++ b/tests/docs/sample_module.py @@ -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 @@ -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""", + ) diff --git a/tests/docs/source/autotrait/help.rst b/tests/docs/source/autotrait/help.rst index be5e876..8181b99 100644 --- a/tests/docs/source/autotrait/help.rst +++ b/tests/docs/source/autotrait/help.rst @@ -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: diff --git a/tests/test_autodoc_traits.py b/tests/test_autodoc_traits.py index 7018f46..063d6f5 100644 --- a/tests/test_autodoc_traits.py +++ b/tests/test_autodoc_traits.py @@ -99,6 +99,7 @@ def test_sphinx_build_all_docs(temp_docs_dir, monkeypatch): "SampleConfigurableSubclass docstring", "SampleNonConfigurable docstring", "SampleNonConfigurableSubclass docstring", + "TraitTypesSampleConfigurable docstring", ], [], ), @@ -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", ], [], ),