Skip to content

Commit

Permalink
Merge branch 'dev' into feature/terrain_metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
sclaw committed Dec 20, 2024
2 parents e274e1c + 71c5122 commit d19b5d1
Show file tree
Hide file tree
Showing 41 changed files with 1,044 additions and 909 deletions.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
exclude production/*
include ripple1d\api\templates\*
recursive-include ripple1d\api\static\ *
18 changes: 18 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Define variables for Sphinx
SPHINXAPIDOC = sphinx-apidoc
SPHINXBUILD = sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Target to run sphinx-apidoc to generate .rst files
apidoc:
$(SPHINXAPIDOC) -o $(SOURCEDIR)/api ../ripple1d/

# Target to run sphinx-build to generate HTML docs
html: apidoc
$(SPHINXBUILD) -b html $(SOURCEDIR) $(BUILDDIR)

# Clean up the generated files
clean:
rm -rf $(BUILDDIR)/*
rm -rf $(SOURCEDIR)/api
70 changes: 70 additions & 0 deletions docs/build_release_changelog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import re
from io import TextIOWrapper
from pathlib import Path

import requests

CHANGE_LOG_PATH = str(Path(__file__).parent.resolve() / "source" / "change_log.rst")


def get_content() -> dict:
"""Get the content of the changelog from the GitHub API."""
url = "https://api.github.com/repos/Dewberry/ripple1d/releases"
headers = {"Accept": "application/vnd.github.v3+json"}
response = requests.get(url, headers=headers)
response.raise_for_status()
return response.json()


def add_heading(file: TextIOWrapper):
"""Add the heading for the changelog."""
file.write(".. note::\n")
file.write(
" Go to the `Releases <https://github.com/Dewberry/ripple1d/releases.html>`__ page for a list of all releases.\n\n"
)


def add_release_body(file: TextIOWrapper, body: str):
"""Add the body of a release to the changelog."""
lines = body.split("\n")
for l in lines:
if l.startswith("# "):
file.write(f"{l[2:]}")
file.write(f"{'-' * len(l[2:])}\n")
elif l.startswith("## "):
file.write(f"{l[3:]}")
file.write(f"{'^' * len(l[3:])}\n")
elif l.startswith("### "):
file.write(f"{l[4:]}")
underline = '"' * len(l[4:])
file.write(f"{underline}\n")
else:
l = re.sub(r"\[([^\]]+)\]\(([^)]+)\)", r"`\1 <\2>`_", l) # fix links
file.write(f"{l}\n")


def add_release(file: TextIOWrapper, release: dict):
"""Add a release to the changelog."""
file.write(f"{release['name']}\n")
file.write(f"{'=' * len(release['name'])}\n\n")
file.write(f"**Tag:** {release['tag_name']}\n\n")
file.write(f"**Published at:** {release['published_at']}\n\n")
file.write(f"**Author:** {release['author']['login']}\n\n")
file.write(f"**Release Notes:**\n\n")
add_release_body(file, release["body"])
file.write("\n\n")


def build_changelog():
"""Build the changelog for the documentation."""
releases = get_content()

# Write release information to an .rst file
with open(CHANGE_LOG_PATH, "w") as file:
add_heading(file)
for release in releases:
add_release(file, release)


if __name__ == "__main__":
build_changelog()
247 changes: 0 additions & 247 deletions docs/change_log.rst

This file was deleted.

Loading

0 comments on commit d19b5d1

Please sign in to comment.