Skip to content

fixed bug#6681: RST default reference role tries docutils' default role ... #368

Closed
wants to merge 1 commit into from

5 participants

@jgsogo
jgsogo commented Sep 11, 2012

Fixes bug#6681 as described in https://code.djangoproject.com/ticket/6681

Docutils establish a ''DEFAULT_INTERPRETED_ROLE'' which is overriden by django with cmsreference role.

Django's role is intended to work on admin docs, but it's not suitable for general purpose as it needs some keys in ''inliner.document.settings''.

@apollo13 apollo13 commented on the diff Sep 16, 2012
django/contrib/admindocs/utils.py
@@ -92,13 +92,17 @@ def _role(name, rawtext, text, lineno, inliner, options=None, content=None):
docutils.parsers.rst.roles.register_canonical_role(rolename, _role)
def default_reference_role(name, rawtext, text, lineno, inliner, options=None, content=None):
- if options is None: options = {}
- if content is None: content = []
- context = inliner.document.settings.default_reference_context
- node = docutils.nodes.reference(rawtext, text, refuri=(ROLES[context] % (inliner.document.settings.link_base, text.lower())), **options)
- return [node], []
+ try:
+ if options is None: options = {}
+ if content is None: content = []
+ context = inliner.document.settings.default_reference_context
+ node = docutils.nodes.reference(rawtext, text, refuri=(ROLES[context] % (inliner.document.settings.link_base, text.lower())), **options)
+ return [node], []
+ except:
@apollo13
Django member
apollo13 added a note Sep 16, 2012

Is there really no alternative to a plain except? This would even catch KeyboardInterupt etc which we surely don't want. Which exceptions can occur here? As a last resort you can use except Exception, but I'd prefer it explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@timgraham
Django member

Ticket has been closed as contrib.markup has been deprecated.

@timgraham timgraham closed this May 31, 2013
@freakboy3742
Django member

Reopening, as this isn't a problem with contrib.markup, but a problem with contrib.admindocs.

@freakboy3742 freakboy3742 reopened this Jun 17, 2013
@mrmachine

An improved fix at #1277 -- no need to set a global default at all.

@timgraham timgraham closed this Jun 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.