Skip to content

Commit fb5db0c

Browse files
committed
Avoid rendering empty blocks.
DoctestSkipDirective inherits from SphinxDirective, which does not render empty blocks when content is empty.
1 parent c2ca08a commit fb5db0c

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

pytest_doctestplus/sphinx/doctestplus.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,26 @@
1010
tests.
1111
"""
1212
import re
13-
from docutils.nodes import literal_block
1413
from docutils.parsers.rst import Directive
15-
14+
from sphinx.util.docutils import SphinxDirective
1615

1716
class NoRunDirective(Directive):
1817
def run(self):
1918
# Simply do not add any content when this directive is encountered
2019
return []
2120

2221

23-
class DoctestSkipDirective(Directive):
22+
class DoctestSkipDirective(SphinxDirective):
2423
has_content = True
2524

2625
def run(self):
2726
# Check if there is any valid argument, and skip it. Currently only
2827
# 'win32' is supported.
2928
if len(self.content) > 0 and re.match("win32", self.content[0]):
3029
self.content = self.content[2:]
31-
code = '\n'.join(self.content)
32-
return [literal_block(code, code)]
3330

31+
nodes = self.parse_content_to_nodes()
32+
return nodes
3433

3534
class DoctestOmitDirective(NoRunDirective):
3635
has_content = True

0 commit comments

Comments
 (0)