From 3324733882357121fed20668495e49a82819ba90 Mon Sep 17 00:00:00 2001 From: Andrey Shpak Date: Thu, 15 Jun 2023 00:09:19 +0300 Subject: [PATCH] Return default app CHOICES_LIMIT to old location --- sphinxcontrib_django/docstrings/__init__.py | 6 +++--- sphinxcontrib_django/docstrings/config.py | 4 ++++ tests/roots/test-docstrings/dummy_django_app/models.py | 3 +-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sphinxcontrib_django/docstrings/__init__.py b/sphinxcontrib_django/docstrings/__init__.py index 5405526..673270b 100644 --- a/sphinxcontrib_django/docstrings/__init__.py +++ b/sphinxcontrib_django/docstrings/__init__.py @@ -23,7 +23,7 @@ from .. import __version__ from .attributes import improve_attribute_docstring from .classes import improve_class_docstring -from .config import EXCLUDE_MEMBERS, INCLUDE_MEMBERS +from .config import CHOICES_LIMIT, EXCLUDE_MEMBERS, INCLUDE_MEMBERS from .data import improve_data_docstring from .methods import improve_method_docstring @@ -62,7 +62,7 @@ def setup(app): # Set default of django_show_db_tables to False app.add_config_value("django_show_db_tables", False, True) # Integer amount of model field choices to show - app.add_config_value("django_choices_to_show", 10, True) + app.add_config_value("django_choices_to_show", CHOICES_LIMIT, True) # Setup Django after config is initialized app.connect("config-inited", setup_django) @@ -109,7 +109,7 @@ def setup_django(app, config): raise ConfigError( "The module you specified in the configuration 'django_settings' in your" " conf.py cannot be imported. Make sure the module path is correct and the" - " source directoy is added to sys.path." + " source directory is added to sys.path." ) from e os.environ["DJANGO_SETTINGS_MODULE"] = config.django_settings django.setup() diff --git a/sphinxcontrib_django/docstrings/config.py b/sphinxcontrib_django/docstrings/config.py index acfacf9..855487b 100644 --- a/sphinxcontrib_django/docstrings/config.py +++ b/sphinxcontrib_django/docstrings/config.py @@ -21,3 +21,7 @@ "polymorphic_primary_key_name", "polymorphic_super_sub_accessors_replaced", } + +#: How many choices should be shown for model fields by default, +#: used as default for ``django_choices_to_show`` option +CHOICES_LIMIT = 10 diff --git a/tests/roots/test-docstrings/dummy_django_app/models.py b/tests/roots/test-docstrings/dummy_django_app/models.py index 08bae5a..bfcf9be 100644 --- a/tests/roots/test-docstrings/dummy_django_app/models.py +++ b/tests/roots/test-docstrings/dummy_django_app/models.py @@ -2,8 +2,7 @@ from django.contrib.contenttypes.models import ContentType from django.db import models -#: Default value of ``django_choices_to_show`` -CHOICES_LIMIT = 10 +from sphinxcontrib_django.docstrings.config import CHOICES_LIMIT try: from phonenumber_field.modelfields import PhoneNumberField