Skip to content

django-rest-framework modifies global docutils rst parserย #9626

@nijel

Description

@nijel

django-rest-framework relies on django.contrib.admindocs on some regex cleanups:

from django.contrib.admindocs.views import simplify_regex

Unfortunately, importing django.contrib.admindocs.views imports django.contrib.admindocs.utils which has a side effect that it customizes the rst parser in docutils:

https://github.com/django/django/blob/c28f821c9067050ba0d099349a4dfea2b29faf99/django/contrib/admindocs/utils.py#L164-L170

The root cause of this being that docutils does only have a global registry (https://sourceforge.net/p/docutils/feature-requests/38/ is open for more than 10 years).

Would it be possible to use a different way to simplify regular expressions that doesn't have such side effects?

Checklist

  • Raised initially as discussion #...
  • This is not a feature request suitable for implementation outside this project. Please elaborate what it is:
    • compatibility fix for new Django/Python version ...
    • other type of bug fix
    • other type of improvement that does not touch existing code or change existing behavior (e.g. wrapper for new Django field)
  • I have reduced the issue to the simplest possible case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions