Skip to content

Commit 72d4d59

Browse files
committed
Generate example rst files for inclusion in docstrings.
1 parent 63336fc commit 72d4d59

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

doc/conf.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,20 @@
230230
trim_doctests_flags = True
231231

232232

233+
def generate_example_rst(app, what, name, obj, options, lines):
234+
# generate empty examples files, so that we don't get
235+
# inclusion errors if there are no examples for a class / module
236+
examples_path = os.path.join(app.srcdir, "modules", "generated",
237+
"%s.examples" % name)
238+
if not os.path.exists(examples_path):
239+
# touch file
240+
open(examples_path, 'w').close()
241+
242+
233243
def setup(app):
234244
# to hide/show the prompt in code examples:
235245
app.add_javascript('js/copybutton.js')
246+
app.connect('autodoc-process-docstring', generate_example_rst)
236247

237248

238249
# The following is used by sphinx.ext.linkcode to provide links to github

0 commit comments

Comments
 (0)