Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions doc/htmldoc/_ext/add_button_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,22 @@ def add_button_to_examples(app, env, docnames):

lines = f.readlines()

# find the first heading of the file.
for i, item in enumerate(lines):
if item.startswith("-----"):
break

# insert prolog into rst file after heading
lines.insert(i + 1, prolog + "\n")

with open(file, "w") as f:
lines = "".join(lines)
f.write(lines)
# make sure rst file is auto generated Python file
check_line = lines[1]
if check_line.startswith(".."):
# find the first heading of the file.
for i, item in enumerate(lines):
if item.startswith("-----"):
break

# insert prolog into rst file after heading
lines.insert(i + 1, prolog + "\n")

with open(file, "w") as f:
lines = "".join(lines)
f.write(lines)
else:
continue


def setup(app):
Expand Down
10 changes: 6 additions & 4 deletions doc/htmldoc/_ext/list_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ def ModelMatchExamples():
continue
with open(filename, "r", errors="ignore") as file:
content = file.read()
for model_file in model_files:
if model_file in content:
matches.setdefault(model_file, []).append(filename)

if "AUTOMATICALLY GENERATED" in content:
for model_file in model_files:
if model_file in content:
matches.setdefault(model_file, []).append(filename)
else:
continue
return matches


Expand Down