Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Conditional removal of changelogs (#4943)

Kanishka Bansode6e9b893e0049
diff --git a/documentation/conf.py b/documentation/conf.py
index 560b9ff13..eb41a7784 100644
--- a/documentation/conf.py
+++ b/documentation/conf.py
@@ -1,3 +1,4 @@
+import os
import sys
from pathlib import Path
@@ -43,7 +44,26 @@ todo_include_todos = True
source_suffix = {".rst": "restructuredtext", ".md": "markdown"}
-exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".venv", "README.md"]
+
+# CI will be True if the CI environment variable is defined, otherwise False
+CI = os.getenv("CI") is not None
+
+# INCLUDE_CHANGELOGS will be True if the INCLUDE_CHANGELOGS environment variable is set to a truthy value.
+# If INCLUDE_CHANGELOGS is not set, it will fall back to the value of CI.
+INCLUDE_CHANGELOGS = bool(os.getenv("INCLUDE_CHANGELOGS", CI))
+
+_default_exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".venv", "README.md"]
+
+# If INCLUDE_CHANGELOGS is True, no additional patterns are excluded, so changelogs will be included.
+# If INCLUDE_CHANGELOGS is False, "changelogs" will be added to the exclusion list.
+exclude_patterns = _default_exclude_patterns + (
+ [] if INCLUDE_CHANGELOGS else ["changelogs"]
+)
+
+# Result: exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".venv", "README.md"]
+# If INCLUDE_CHANGELOGS is False, the result will also include "changelogs".
+
+
suppress_warnings = [
# Pygments does not fully support language features we use
# in code blocks in the documentation. Unfortunately the best
@@ -87,6 +107,10 @@ githubusermention = True
# so the prefix should be the root
notfound_urls_prefix = "/"
+nitpick_ignore_regex = (
+ () if INCLUDE_CHANGELOGS else (("myst", ".*/changelogs/index.*"),)
+)
+
redirects = {
"meta/traffic/index": "/meta/monitoring/traffic/index.html",
"meta/traffic/runbooks/identifying-and-blocking-traffic-anomalies": "/meta/monitoring/traffic/runbooks/identifying-and-blocking-traffic-anomalies.html", # noqa: E501
@@ -116,4 +140,8 @@ redirects = {
"packages/openverse_attribution/index": "/packages/python/openverse_attribution/index.html",
}
+if "changelogs" in exclude_patterns:
+ # temporary placeholder for now
+ redirects["changelogs/index"] = "/meta/missing_changelogs.html"
+
myst_enable_extensions = ["linkify"]
diff --git a/documentation/meta/missing_changelogs.md b/documentation/meta/missing_changelogs.md
new file mode 100644
index 000000000..af172d4a9
--- /dev/null
+++ b/documentation/meta/missing_changelogs.md
@@ -0,0 +1,19 @@
+---
+orphan: true
+---
+
+# Changelogs missing from local build
+
+The documentation build excludes changelogs unless it is in a CI environment or
+explicitly instructed to include changelogs. This significantly reduces the
+number of files processed for local preview builds, which cuts startup time of
+the documentation preview by half and improving the ergonomics of working with
+preview documentation locally.
+
+To force the inclusion of the changelogs, run the documentation build with
+`INCLUDE_CHANGELOGS=1` in your environment. For example, the following will run
+the preview build, including changelogs:
+
+```shell
+ov env INCLUDE_CHANGELOGS=1 just documentation/serve
+```