Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the everest doc generator #8822

Merged
merged 1 commit into from
Oct 1, 2024
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
22 changes: 16 additions & 6 deletions src/everest/docs/__main__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import sys
from pathlib import Path

from everest.docs.generate_docs_from_config_spec import generate_docs_pydantic_to_rst

committed_file = (
Path(__file__).parents[3] / "docs" / "everest" / "config_generated.rst"
).resolve()
GENERATED_FILE = Path("docs") / "everest" / "config_generated.rst"

parts = GENERATED_FILE.parts
while parts and not Path(*parts).exists():
parts = parts[1:]
if not parts:
print(
f"""The file to update ('{GENERATED_FILE}') was not found.
The generator must be run from one of the parent directories of
'{GENERATED_FILE.parts[-1]}' within the ERT source directory.
Please change the current directory accordingly and re-run."""
)
sys.exit()

print(f"Writing new docs contents to {committed_file}")
docs_content = generate_docs_pydantic_to_rst()
with open(committed_file, "w", encoding="utf-8") as fp:
with Path(*parts).open("w", encoding="utf-8") as fp:
fp.write(docs_content)

print(f"Writing updated docs to {committed_file} complete, you may now commit it.")
print(f"Generated docs written to {GENERATED_FILE}")
print("Please commit the generated file.")