Skip to content

Commit 50e783a

Browse files
doc: conf: cd into doctest dir and back
The example code in the documentation expects the example configs/python files in the current working directory. Signed-off-by: Bastian Krause <bst@pengutronix.de>
1 parent becc65a commit 50e783a

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

doc/conf.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,20 @@ def setup(app):
207207

208208
# -- Options for doctest --------------------------------------------------
209209

210+
doctest_global_setup = '''
211+
import os
212+
213+
doctest_dir = '.build/doctest'
214+
215+
if not os.getcwd().endswith(doctest_dir):
216+
os.chdir(doctest_dir)
217+
'''
218+
219+
doctest_global_cleanup = '''
220+
if os.getcwd().endswith(doctest_dir):
221+
os.chdir('../..')
222+
'''
223+
210224
def write_literal_blocks(app, doctree):
211225
"""
212226
Writes named literal blocks to a file with that respective name in the temporary doctest build

0 commit comments

Comments
 (0)