Opened 4 hours ago

Closed 3 hours ago

#36124 closed Cleanup/optimization (needsinfo)

Importing from django.contrib.admindocs.views modifies docutils rst parser

Reported by: Michal Čihař Owned by:
Component: contrib.admindocs Version: dev
Severity: Normal Keywords: docutils simplify_regex roles register_canonical_role
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Doing from django.contrib.admindocs.views import simplify_regex is enough to make admindocs customize docutils rst parser what might have undesired side effects. I've ran into this via django-rest-framework (https://github.com/encode/django-rest-framework/issues/9626), but there are apparently more users of this function (https://github.com/search?q=%22from+django.contrib.admindocs.views+import+simplify_regex%22&type=code). Not sure if this interface is considered public or not, but apparently it got some users.

Docutils lack of local registry (https://sourceforge.net/p/docutils/feature-requests/38/) so there is currently no way to make the customization local to admindocs.

Would it be possible to separate simplify_regex logic to some utility module that could be reused by others and would not suffer such side effects? Any other ideas how to address this?

Change History (1)

in reply to:  description comment:1 by Natalia Bidart, 3 hours ago

Keywords: docutils simplify_regex roles register_canonical_role added
Resolution: needsinfo
Status: newclosed
Type: UncategorizedCleanup/optimization
Version: 5.1dev

Replying to Michal Čihař:

Hello Michal, thank you for taking the time to create this ticket.

Doing from django.contrib.admindocs.views import simplify_regex is enough to make admindocs customize docutils rst parser what might have undesired side effects.

I see your point, but I also see that Django registers a specific role, with a non common name cmsreference. Could you provide more details on how this would produce undesired side effects (other than having a new role defined)?

Not sure if this interface is considered public or not, but apparently it got some users.

This interface is definitely NOT considered public, is not documented nor advertised in any way.

Would it be possible to separate simplify_regex logic to some utility module that could be reused by others and would not suffer such side effects? Any other ideas how to address this?

For questions like this, the Django Forum would be a great place to seek feedback and suggestions. The forum is read by a broader audience, including contributors and users who can provide a wider range of insights and potential solutions. This ticket tracker, on the other hand, is primarily followed by the Django Fellows, so you might not receive as much input from the broader community here.

I'll be closing this ticket as needsinfo following the ticket triaging process. To me, while the potential for undesirable side effects exists, these appear to be theoretical at this point. In order to fully understand the scope of the issue, we would need to investigate specific use cases and determine under what conditions this could become problematic, so please reopen when you can provide further details.

Thanks again!

Note: See TracTickets for help on using tickets.
Back to Top