mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Closes #933: Do not crash if an `:option:` value is malformed (contains spaces
but no option name).
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -30,6 +30,9 @@ Bugs fixed
|
|||||||
|
|
||||||
* #932: autodoc: Do not crash if ``__doc__`` is not a string.
|
* #932: autodoc: Do not crash if ``__doc__`` is not a string.
|
||||||
|
|
||||||
|
* #933: Do not crash if an ``:option:`` value is malformed (contains spaces
|
||||||
|
but no option name).
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|||||||
@@ -190,17 +190,26 @@ class Program(Directive):
|
|||||||
class OptionXRefRole(XRefRole):
|
class OptionXRefRole(XRefRole):
|
||||||
innernodeclass = addnodes.literal_emphasis
|
innernodeclass = addnodes.literal_emphasis
|
||||||
|
|
||||||
|
def _split(self, text, refnode, env):
|
||||||
|
try:
|
||||||
|
program, target = re.split(' (?=-|--|/)', text, 1)
|
||||||
|
except ValueError:
|
||||||
|
env.warn_node('Malformed :option: %r, does not contain option '
|
||||||
|
'marker - or -- or /' % text, refnode)
|
||||||
|
return None, text
|
||||||
|
else:
|
||||||
|
program = ws_re.sub('-', program)
|
||||||
|
return program, target
|
||||||
|
|
||||||
def process_link(self, env, refnode, has_explicit_title, title, target):
|
def process_link(self, env, refnode, has_explicit_title, title, target):
|
||||||
program = env.temp_data.get('std:program')
|
program = env.temp_data.get('std:program')
|
||||||
if not has_explicit_title:
|
if not has_explicit_title:
|
||||||
if ' ' in title and not (title.startswith('/') or
|
if ' ' in title and not (title.startswith('/') or
|
||||||
title.startswith('-')):
|
title.startswith('-')):
|
||||||
program, target = re.split(' (?=-|--|/)', title, 1)
|
program, target = self._split(title, refnode, env)
|
||||||
program = ws_re.sub('-', program)
|
|
||||||
target = target.strip()
|
target = target.strip()
|
||||||
elif ' ' in target:
|
elif ' ' in target:
|
||||||
program, target = re.split(' (?=-|--|/)', target, 1)
|
program, target = self._split(target, refnode, env)
|
||||||
program = ws_re.sub('-', program)
|
|
||||||
refnode['refprogram'] = program
|
refnode['refprogram'] = program
|
||||||
return title, target
|
return title, target
|
||||||
|
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ Adding \n to test unescaping.
|
|||||||
* :doc:`subdir/includes`
|
* :doc:`subdir/includes`
|
||||||
* ``:download:`` is tested in includes.txt
|
* ``:download:`` is tested in includes.txt
|
||||||
* :option:`Python -c option <python -c>`
|
* :option:`Python -c option <python -c>`
|
||||||
|
* This used to crash: :option:`Python c option`
|
||||||
|
|
||||||
Test :abbr:`abbr (abbreviation)` and another :abbr:`abbr (abbreviation)`.
|
Test :abbr:`abbr (abbreviation)` and another :abbr:`abbr (abbreviation)`.
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ http://www.python.org/logo.png
|
|||||||
reading included file u'.*?wrongenc.inc' seems to be wrong, try giving an \
|
reading included file u'.*?wrongenc.inc' seems to be wrong, try giving an \
|
||||||
:encoding: option\\n?
|
:encoding: option\\n?
|
||||||
%(root)s/includes.txt:4: WARNING: download file not readable: .*?nonexisting.png
|
%(root)s/includes.txt:4: WARNING: download file not readable: .*?nonexisting.png
|
||||||
|
%(root)s/markup.txt:142: WARNING: Malformed :option: u'Python c option', does \
|
||||||
|
not contain option marker - or -- or /
|
||||||
%(root)s/objects.txt:\\d*: WARNING: using old C markup; please migrate to \
|
%(root)s/objects.txt:\\d*: WARNING: using old C markup; please migrate to \
|
||||||
new-style markup \(e.g. c:function instead of cfunction\), see \
|
new-style markup \(e.g. c:function instead of cfunction\), see \
|
||||||
http://sphinx-doc.org/domains.html
|
http://sphinx-doc.org/domains.html
|
||||||
|
|||||||
Reference in New Issue
Block a user