Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions sphinx_selective_exclude/eager_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#
import sphinx
from docutils.parsers.rst import directives
from sphinx.util import logging


logger = sphinx.util.logging.getLogger(__name__)


class EagerOnly(sphinx.directives.other.Only):
Expand All @@ -31,9 +35,13 @@ def run(self, *args):
env = self.state.document.settings.env
env.app.builder.tags.add('TRUE')
#print(repr(self.arguments[0]))
if not env.app.builder.tags.eval_condition(self.arguments[0]):
return []

try:
if not env.app.builder.tags.eval_condition(self.arguments[0]):
return []
except Exception as err:
logger.critical("Exception while evaluating 'only' directive expression: %r", err,
location=(self.env.docname, self.lineno))
raise err
# Otherwise, do the usual processing
nodes = super(EagerOnly, self).run()
if len(nodes) == 1:
Expand Down