Skip to content

Commit

Permalink
Merge pull request #3065 from jessica-mitchell/add-check-docext
Browse files Browse the repository at this point in the history
Modify doc extensions to check for correct files
  • Loading branch information
jessica-mitchell authored Jan 26, 2024
2 parents 9ce52bf + 76d1f87 commit ca61b4a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
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

0 comments on commit ca61b4a

Please sign in to comment.