Skip to content

Commit

Permalink
Conditional removal of changelogs (#4943)
Browse files Browse the repository at this point in the history
* conditional removal on changelogs

* Revert "conditional removal on changelogs"

This reverts commit f365e6d.

* conditional changelogs removal

* lint

* fixed small error

* suggested changes added
  • Loading branch information
kb-0311 authored Sep 18, 2024
1 parent 3ac6477 commit 6e9b893
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
30 changes: 29 additions & 1 deletion documentation/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sys
from pathlib import Path

Expand Down Expand Up @@ -43,7 +44,26 @@ def add_ext_to_path():

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
Expand Down Expand Up @@ -87,6 +107,10 @@ def add_ext_to_path():
# 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
Expand Down Expand Up @@ -116,4 +140,8 @@ def add_ext_to_path():
"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"]
19 changes: 19 additions & 0 deletions documentation/meta/missing_changelogs.md
Original file line number Diff line number Diff line change
@@ -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
```

0 comments on commit 6e9b893

Please sign in to comment.