Skip to content
Merged
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
18 changes: 15 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@


def get_file_from_url(url, fname):
r = requests.get(url)
# Fail the build on an HTTP error instead of writing an error page to fname.
r = requests.get(url, timeout=60)
r.raise_for_status()
with open(fname, "wb") as f:
f.write(r.content)

Expand Down Expand Up @@ -177,6 +179,11 @@ def setup(app):
)
with open("contrib/GitGuideAdapter.md", "r") as f:
adapter_content = f.read()
if "## Creating a branch" not in content:
raise RuntimeError(
"contrib/GitGuide.md: heading '## Creating a branch' not found; "
"check OpenROAD docs/contrib/GitGuide.md"
)
content = content.replace(
"## Creating a branch", adapter_content + "\n## Creating a branch"
)
Expand All @@ -196,7 +203,11 @@ def setup(app):

match = re.search(f"{start_pattern}(.*?){end_pattern}", markdown_content, re.DOTALL)

assert match is not None, "No match found, check the OR Doc pattern on index.md"
if match is None:
raise RuntimeError(
f"SupportedOS.md: '{start_pattern}' followed by '{end_pattern}' "
"not found; check the headings in OpenROAD docs/index.md"
)
extracted_content = match.group(1)
extracted_content = "\n#### Supported Operating Systems" + extracted_content
print(extracted_content)
Expand All @@ -205,7 +216,8 @@ def setup(app):
with open("index2.md", "r") as f:
existing_content = f.read()
match = re.search(r"### Setup", existing_content)
assert match is not None, "Check search keyword."
if match is None:
raise RuntimeError("docs/index.md: heading '### Setup' not found")
with open("index2.md", "w") as f:
insert_position = match.end() + 1
before_insert = existing_content[:insert_position]
Expand Down