Skip to content

Commit 647012f

Browse files
authored
fix: restore missing function (#475)
1 parent 9189010 commit 647012f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

doc/source/conf.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,39 @@ def copy_examples_to_output_dir(app: sphinx.application.Sphinx, exception: Excep
402402
destination_file.write_text(file.read_text(encoding="utf-8"), encoding="utf-8")
403403

404404

405+
def copy_examples_files_to_source_dir(app: sphinx.application.Sphinx):
406+
"""
407+
Copy the examples directory to the source directory of the documentation.
408+
409+
Parameters
410+
----------
411+
app : sphinx.application.Sphinx
412+
Sphinx application instance containing the all the doc build configuration.
413+
414+
"""
415+
SOURCE_EXAMPLES = pathlib.Path(app.srcdir) / "examples"
416+
if not SOURCE_EXAMPLES.exists():
417+
SOURCE_EXAMPLES.mkdir(parents=True, exist_ok=True)
418+
419+
EXAMPLES_DIRECTORY = SOURCE_EXAMPLES.parent.parent.parent / "examples"
420+
421+
all_examples = list(EXAMPLES_DIRECTORY.glob("*.py"))
422+
examples = [file for file in all_examples if f"{file.name}" not in exclude_examples]
423+
424+
print(f"BUILDER: {app.builder.name}")
425+
426+
for file in status_iterator(
427+
examples,
428+
f"Copying example to doc/source/examples/",
429+
"green",
430+
len(examples),
431+
verbosity=1,
432+
stringify_func=(lambda file: file.name),
433+
):
434+
destination_file = SOURCE_EXAMPLES / file.name
435+
destination_file.write_text(file.read_text(encoding="utf-8"), encoding="utf-8")
436+
437+
405438
def remove_examples_from_source_dir(app: sphinx.application.Sphinx, exception: Exception):
406439
"""
407440
Remove the example files from the documentation source directory.

0 commit comments

Comments
 (0)