mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fixes #873: do not raise assertion errors on empty "only" directives.
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -51,6 +51,8 @@ Release 1.1.3 (in development)
|
||||
* #892: Fix single-HTML builder misbehaving with the master document in a
|
||||
subdirectory.
|
||||
|
||||
* #873: Fix assertion errors with empty ``only`` directives.
|
||||
|
||||
|
||||
Release 1.1.2 (Nov 1, 2011) -- 1.1.1 is a silly version number anyway!
|
||||
======================================================================
|
||||
|
||||
@@ -1512,19 +1512,21 @@ class BuildEnvironment:
|
||||
self.warn_node(msg % {'target': target}, node)
|
||||
|
||||
def process_only_nodes(self, doctree, builder, fromdocname=None):
|
||||
# A comment on the comment() nodes being inserted: replacing by [] would
|
||||
# result in a "Losing ids" exception if there is a target node before
|
||||
# the only node, so we make sure docutils can transfer the id to
|
||||
# something, even if it's just a comment and will lose the id anyway...
|
||||
for node in doctree.traverse(addnodes.only):
|
||||
try:
|
||||
ret = builder.tags.eval_condition(node['expr'])
|
||||
except Exception, err:
|
||||
self.warn_node('exception while evaluating only '
|
||||
'directive expression: %s' % err, node)
|
||||
node.replace_self(node.children)
|
||||
node.replace_self(node.children or nodes.comment())
|
||||
else:
|
||||
if ret:
|
||||
node.replace_self(node.children)
|
||||
node.replace_self(node.children or nodes.comment())
|
||||
else:
|
||||
# replacing by [] would result in an "Losing ids" exception
|
||||
# if there is a target node before the only node
|
||||
node.replace_self(nodes.comment())
|
||||
|
||||
def assign_section_numbers(self):
|
||||
|
||||
Reference in New Issue
Block a user