diff options
| author | Georg Brandl <georg@python.org> | 2012-03-10 19:36:22 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2012-03-10 19:36:22 +0100 |
| commit | 39f0a0ad50de5cde9f4bbdc7de581aaa697ff282 (patch) | |
| tree | 0468167f66c8e33667c0c31677c523d475bf9c70 | |
| parent | 41142b5914ea4d86e3c546461c12b3af5e8b7efd (diff) | |
| download | sphinx-39f0a0ad50de5cde9f4bbdc7de581aaa697ff282.tar.gz | |
Fixes #873: do not raise assertion errors on empty "only" directives.
| -rw-r--r-- | CHANGES | 2 | ||||
| -rw-r--r-- | sphinx/environment.py | 10 |
2 files changed, 8 insertions, 4 deletions
@@ -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! ====================================================================== diff --git a/sphinx/environment.py b/sphinx/environment.py index 09e0f1d3..a4bbbe3b 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -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): |
