From 010dff2f9ddf0a5a861efcdacac2cb0c248ee26a Mon Sep 17 00:00:00 2001 From: Andrew Smirnov Date: Thu, 29 Apr 2021 21:08:11 +0300 Subject: [PATCH] Fix model docs and enchant spelling tokenizer --- docs/source/conf.py | 44 ++++++++++++++++++++------------------------ main/models.py | 8 ++++++-- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 1495347..b4be21c 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -16,10 +16,8 @@ import inspect import enchant import django - sys.path.insert(0, os.path.abspath('../../')) - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'access_controller.settings') os.environ.setdefault('DJANGO_CONFIGURATION', 'Dev') @@ -37,7 +35,6 @@ from django.db.models.query import QuerySet QuerySet.__repr__ = lambda self: self.__class__.__name__ - django.setup() # -- Project information ----------------------------------------------------- @@ -87,6 +84,7 @@ def process_django_models(app, what, name, obj, options, lines): lines.append(':type %s: %s.%s' % (field.attname, module, field_type.__name__)) if enchant is not None: lines += spelling_white_list + lines.append('') return lines @@ -113,15 +111,17 @@ def skip_queryset(app, what, name, obj, skip, options): return True return skip -def fix_sig(app, what, name, obj, options, signature, return_annotation): - return ("", "") -# def setup(app): -# # Register the docstring processor with sphinx -# app.connect('autodoc-process-docstring', process_django_models) -# app.connect('autodoc-skip-member', skip_queryset) -# app.connect('autodoc-process-docstring', process_modules) -# app.connect("autodoc-process-signature", fix_sig) +def fix_sig(app, what, name, obj, options, signature, return_annotation): + return "", "" + + +def setup(app): + # Register the docstring processor with sphinx + app.connect('autodoc-process-docstring', process_django_models) + app.connect('autodoc-skip-member', skip_queryset) + app.connect('autodoc-process-docstring', process_modules) + app.connect("autodoc-process-signature", fix_sig) # Add any Sphinx extension module names here, as strings. They can be @@ -139,7 +139,6 @@ extensions = { 'sphinxcontrib.spelling', } - # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -186,17 +185,17 @@ autodoc_typehints = "description" # spell checking spelling_lang = 'ru_RU' -tokenizer_lang = 'ru_RU' -spelling_exclude_patterns=['ignored_*', '../../main/models.py'] +tokenizer_lang = 'en_US' +spelling_exclude_patterns = ['ignored_*', '../../main/models.py'] spelling_show_suggestions = True -spelling_show_whole_line=True -spelling_warning=True +spelling_show_whole_line = True +spelling_warning = True spelling_ignore_pypi_package_names = True -spelling_ignore_wiki_words=True -spelling_ignore_acronyms=True -spelling_ignore_python_builtins=True -spelling_ignore_importable_modules=True -spelling_ignore_contributor_names=True +spelling_ignore_wiki_words = True +spelling_ignore_acronyms = True +spelling_ignore_python_builtins = True +spelling_ignore_importable_modules = True +spelling_ignore_contributor_names = True # -- Options for todo extension ---------------------------------------------- @@ -206,6 +205,3 @@ set_type_checking_flag = True typehints_fully_qualified = True always_document_param_types = True typehints_document_rtype = True - - - diff --git a/main/models.py b/main/models.py index fcde327..6515fe5 100644 --- a/main/models.py +++ b/main/models.py @@ -17,6 +17,7 @@ class UserProfile(models.Model): Модель профиля пользователя. Профиль создается и изменяется при создании и изменении модель User. + """ class Meta: @@ -33,7 +34,9 @@ class UserProfile(models.Model): @property def zendesk_role(self) -> str: """ - Функция возвращает роль пользователя в Zendesk в формате str, либо UNDERFINED, если пользователь не найден. + Функция возвращает роль пользователя в Zendesk. + + В формате str, либо UNDEFINED, если пользователь не найден :return: Роль пользователя в Zendesk """ @@ -72,7 +75,7 @@ def save_user_profile(instance, **kwargs) -> None: class RoleChangeLogs(models.Model): """ - Модель для логирования изменений ролей пользователя. + Модель для логгирования изменений ролей пользователя """ user = models.ForeignKey(to=User, on_delete=models.CASCADE, help_text='Пользователь, которому присвоили другую роль') @@ -105,6 +108,7 @@ class UnassignedTicketStatus(models.IntegerChoices): class UnassignedTicket(models.Model): """ Модель не распределенного тикета. + """ assignee = models.ForeignKey(to=User, on_delete=models.CASCADE, related_name='tickets', help_text='Пользователь, с которого снят тикет')