Skip to content

Commit a7788cc

Browse files
committed
doc: ensure Python examples are included in output html files
1 parent 9465a63 commit a7788cc

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

doc/source/conf.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,17 +262,25 @@ def remove_directory_recursive(directory_path):
262262
directory_path.rmdir()
263263

264264

265-
def copy_examples_to_source_dir(app):
265+
def copy_directory(origin, destination):
266266
logger = logging.getLogger(__name__)
267-
logger.info("\nCopying examples/ to doc/source/ directory...")
267+
logger.info(f"\nCopying {origin}/ to {destination}/...")
268+
copy_directory_recursive(origin, destination)
269+
270+
def copy_examples_to_source_dir(app):
268271
SOURCE_DIRECTORY = pathlib.Path(app.srcdir)
269272
EXAMPLES_DIRECTORY = pathlib.Path().parent.parent / "examples"
270-
copy_directory_recursive(EXAMPLES_DIRECTORY, SOURCE_DIRECTORY / "examples")
273+
copy_directory(EXAMPLES_DIRECTORY, SOURCE_DIRECTORY / "examples")
274+
275+
def copy_examples_to_output_dir(app):
276+
OUTPUT_DIRECTORY = pathlib.Path(app.outdir)
277+
EXAMPLES_DIRECTORY = pathlib.Path().parent.parent / "examples"
278+
copy_directory(EXAMPLES_DIRECTORY, OUTPUT_DIRECTORY / "examples")
271279

272280
def remove_examples_from_source_dir(app, exception):
273-
logger = logging.getLogger(__name__)
274-
logger.info("\nRemoving examples/ from doc/source/ directory...")
275281
SOURCE_DIRECTORY = pathlib.Path(app.srcdir)
282+
logger = logging.getLogger(__name__)
283+
logger.info(f"\nRemoving examples/ from {SOURCE_DIRECTORY} directory...")
276284
remove_directory_recursive(SOURCE_DIRECTORY / "examples")
277285

278286
def setup(app):
@@ -285,3 +293,4 @@ def setup(app):
285293
import os
286294
app.connect("builder-inited", copy_examples_to_source_dir)
287295
app.connect("build-finished", remove_examples_from_source_dir)
296+
app.connect("build-finished", copy_examples_to_output_dir)

0 commit comments

Comments
 (0)