From 6093e2646938c8478e5b63d1a6052663583ae38b Mon Sep 17 00:00:00 2001 From: Jarrod Millman Date: Tue, 26 Mar 2024 11:48:56 -0700 Subject: [PATCH] Add links to preview sites for PRs --- Makefile | 8 ++++++-- README.md | 15 --------------- tools/add_preview_links.py | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 tools/add_preview_links.py diff --git a/Makefile b/Makefile index ddbd0c42..dc60c8d5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: doc-serve shortcode-docs docs scipy main blog learn tools serve-dev +.PHONY: doc-serve shortcode-docs netlify-preview preview-theme theme docs scipy main blog learn tools serve-dev .DEFAULT_GOAL := doc-serve GH_ORG = scientific-python @@ -32,12 +32,16 @@ doc-serve: doc/content/shortcodes.md # The following is for use on netlify # ----------------------------------- -netlify-preview: theme scipy main blog learn tools +netlify-preview: preview-theme theme scipy main blog learn tools mv scipy/public doc/public/scipy mv main/public doc/public/main mv blog/public doc/public/blog mv learn/public doc/public/learn mv tools/public doc/public/tools + git restore doc/content/_index.md + +preview-theme: + python tools/add_preview_links.py theme: doc/content/shortcodes.md (cd doc ; hugo --themesDir="../..") diff --git a/README.md b/README.md index 6abdc3a9..60793986 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,3 @@ The **Scientific Python Hugo Theme** is a theme for the Please see the [theme documentation](https://theme.scientific-python.org), especially the [get started](https://theme.scientific-python.org/getstarted/) page. - -## Theme development - -When making PRs against this repository, a site preview of the theme -documentation will be rendered. From there, you can browse preview -builds of a few other community websites: `scipy`, `main` -(scientific-python.org), `blog`, and `learn`. E.g., if the preview link is - -https://deploy-preview-301--scientific-python-hugo-theme.netlify.app/ - -browse to - -https://deploy-preview-301--scientific-python-hugo-theme.netlify.app/blog - -to see how the blog rendered. diff --git a/tools/add_preview_links.py b/tools/add_preview_links.py new file mode 100644 index 00000000..9d9d49f4 --- /dev/null +++ b/tools/add_preview_links.py @@ -0,0 +1,14 @@ +filename = "doc/content/_index.md" +preview_links = """ +{{< admonition attention >}} +See scientific python, [blog](blog), learn, [tools](tools), scipy, and numpy. +{{< /admonition >}} +""" + +with open(filename, "r") as f: + index = f.readlines() + +with open(filename, "w") as f: + index.insert(3, preview_links) + index = "".join(index) + f.write(index)