aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2022-01-09 19:59:29 +0200
committerGravatar Hassan Abouelela <[email protected]>2022-01-09 19:59:29 +0200
commit29189d599f7de9f87aeba3f565f0efd0aae5c690 (patch)
treebd331b7d287a4863d65102ee300b3f0f5706edee /docs
parentMerge pull request #12 from python-discord/add-code-block-regex (diff)
Add Doc Static Previews With Netlify
Adds a helper script which downloads and calls the netlify build script from the site project, to enable static previews for docs.
Diffstat (limited to 'docs')
-rw-r--r--docs/README.md6
-rw-r--r--docs/netlify_build.py32
2 files changed, 38 insertions, 0 deletions
diff --git a/docs/README.md b/docs/README.md
index 06c5a739..fa719292 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -43,3 +43,9 @@ You can use [this site][releases] to get the PR number you'll use for your entry
[next]: https://ichard26.github.io/next-pr-number/?owner=python-discord&name=bot-core
[releases]: https://releases.readthedocs.io/en/latest/concepts.html
+
+## Static Builds
+We deploy our docs to netlify to power static previews on PRs.
+Check out [python-discord/site][STATIC_BUILD_DOCS] for more info on the system.
+
+[STATIC_BUILD_DOCS]: https://github.com/python-discord/site/tree/main/static-builds
diff --git a/docs/netlify_build.py b/docs/netlify_build.py
new file mode 100644
index 00000000..ca8f6d2e
--- /dev/null
+++ b/docs/netlify_build.py
@@ -0,0 +1,32 @@
+# WARNING: This file must remain compatible with python 3.8
+
+# This script performs all the actions required to build and deploy our project on netlify
+# It depends on the following packages, which are set in the netlify UI:
+# httpx == 0.19.0
+
+import importlib
+from pathlib import Path
+
+import httpx
+
+SCRIPT_SOURCE = "https://raw.githubusercontent.com/python-discord/site/main/static-builds/netlify_build.py"
+OUTPUT = Path("docs/build.py")
+OUTPUT.unlink(missing_ok=True)
+
+build_script = httpx.get(SCRIPT_SOURCE)
+build_script.raise_for_status()
+OUTPUT.write_text(
+ build_script.text.replace(
+ "Build & Publish Static Preview",
+ "Build Docs"
+ ).replace(
+ "static-build",
+ "docs"
+ )
+)
+
+script = importlib.import_module(OUTPUT.name.replace(".py", "").replace("/", "."))
+
+if __name__ == "__main__":
+ print("Build started")
+ script.download_artifact(*script.get_build_artifact())