Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Publish release notes in the cuML documentation
  • Loading branch information
csadorf committed Sep 18, 2026
commit 5349b7aebe83c6ab4715fda94aa5ae1885b82ae1
1 change: 1 addition & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ jobs:
- '!ci/test_python*.sh'
- '!ci/test_wheel*.sh'
- '!codecov.yml'
- 'CHANGELOG.md'
test_cpp:
- '**'
- '!**/*/agents.md'
Expand Down
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"IPython.sphinxext.ipython_directive",
"nbsphinx",
"recommonmark",
"release_notes",
"sphinx_markdown_tables",
"sphinx_copybutton",
"sphinx_design",
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ Community & Support
user_guide.rst
Zero Code Change Acceleration <cuml-accel/index.rst>
api/index
Release notes <release_notes>
developer_guide/index
5 changes: 5 additions & 0 deletions docs/source/release_notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!--
This page is replaced with the repository's canonical CHANGELOG.md by the
release_notes Sphinx extension. Keep the file so Sphinx discovers the page;
do not copy changelog content here.
-->
83 changes: 83 additions & 0 deletions docs/source/sphinxext/release_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""Render the repository changelog as the Sphinx release-notes page."""

from __future__ import annotations

import re
from pathlib import Path

_CHANGELOG = Path(__file__).resolve().parents[3] / "CHANGELOG.md"
_HEADING = re.compile(r"^(#{1,6})\s+(.+?)\s*$")
_RELEASE = re.compile(
r"cuml\s+(?:v?\d+(?:\.\d+)+(?:[^\s]*)?|unreleased)\b", re.I
)
_TITLE = re.compile(r"release notes", re.I)


def render_release_notes(
changelog: str, policy_url: str = "deprecation_policy.html"
) -> str:
"""Add the page introduction and normalize historic changelog headings."""
lines = [
"# Release notes",
"",
(
"See the [compatibility and deprecation policy]"
f"({policy_url}) for cuML's API stability guarantees."
),
"",
]
found_release = False

for line in changelog.splitlines():
match = _HEADING.match(line)
if not match:
lines.append(line)
continue

level = len(match.group(1))
heading = match.group(2)
if _TITLE.fullmatch(heading.strip()):
# The integration supplies one page title for both the canonical
# changelog and old branches whose changelog lacks a document title.
continue
if _RELEASE.match(heading):
found_release = True
lines.append(f"## {heading}")
elif found_release and level <= 3:
# Historic generated notes use both H2 and H3 for categories.
# Keep the prose untouched while presenting a consistent tree.
lines.append(f"### {heading}")
elif not found_release and level <= 2:
# Reserve H1 for the page title even on older or hand-edited
# changelogs with introductory sections.
lines.append(f"## {heading}")
else:
lines.append(line)

return "\n".join(lines).rstrip() + "\n"


def _read_release_notes(app, docname: str, source: list[str]) -> None:
if docname != "release_notes":
return
app.env.note_dependency(str(_CHANGELOG))
try:
changelog = _CHANGELOG.read_text(encoding="utf-8")
except OSError as error:
raise RuntimeError(
f"Unable to read the canonical cuML changelog at {_CHANGELOG}"
) from error

policy_url = app.builder.get_relative_uri(docname, "deprecation_policy")
source[0] = render_release_notes(changelog, policy_url)


def setup(app):
app.connect("source-read", _read_release_notes)
return {
"version": "1",
"parallel_read_safe": True,
"parallel_write_safe": True,
}
127 changes: 127 additions & 0 deletions docs/source/sphinxext/tests/test_release_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

import importlib.util
from pathlib import Path

import pytest

_EXTENSION = Path(__file__).parents[1] / "release_notes.py"
_DOCS_SOURCE = Path(__file__).parents[2]
_SPEC = importlib.util.spec_from_file_location("release_notes", _EXTENSION)
assert _SPEC is not None and _SPEC.loader is not None
release_notes = importlib.util.module_from_spec(_SPEC)
_SPEC.loader.exec_module(release_notes)


def test_render_release_notes_normalizes_legacy_heading_levels():
# rapids-pre-commit-hooks: disable-next-line[verify-hardcoded-version]
changelog = """# cuML 26.08.00 (5 Aug 2026)

## New Features

- Added a feature.

# cuML 26.06.00 (3 Jun 2026)

### Fixed

#### Details
"""

rendered = release_notes.render_release_notes(
changelog, "../deprecation_policy/"
)

assert rendered.count("# Release notes\n") == 1
# rapids-pre-commit-hooks: disable-next-line[verify-hardcoded-version]
assert "## cuML 26.08.00 (5 Aug 2026)" in rendered
assert "### New Features" in rendered
assert "## cuML 26.06.00 (3 Jun 2026)" in rendered
assert "### Fixed" in rendered
assert "#### Details" in rendered
assert "](../deprecation_policy/)" in rendered


def test_render_release_notes_replaces_existing_title():
changelog = """# Release notes

## Before the releases

## cuML unreleased

### Added
"""

rendered = release_notes.render_release_notes(changelog)

assert rendered.count("# Release notes\n") == 1
assert "## Before the releases\n" in rendered
assert rendered.count("## cuML unreleased\n") == 1
assert "### Added\n" in rendered


class _Environment:
def __init__(self):
self.dependencies = []

def note_dependency(self, dependency):
self.dependencies.append(dependency)


class _Builder:
def get_relative_uri(self, from_docname, to_docname):
assert from_docname == "release_notes"
assert to_docname == "deprecation_policy"
return "../deprecation_policy/"


class _Application:
def __init__(self):
self.env = _Environment()
self.builder = _Builder()


def test_read_release_notes_registers_dependency(monkeypatch, tmp_path):
changelog = tmp_path / "CHANGELOG.md"
# rapids-pre-commit-hooks: disable-next-line[verify-hardcoded-version]
changelog.write_text("# cuML 26.10.00 (unreleased)\n", encoding="utf-8")
monkeypatch.setattr(release_notes, "_CHANGELOG", changelog)
app = _Application()
source = ["placeholder"]

release_notes._read_release_notes(app, "release_notes", source)

assert app.env.dependencies == [str(changelog)]
assert source[0].startswith("# Release notes\n")
assert "](../deprecation_policy/)" in source[0]


def test_read_release_notes_ignores_other_documents(monkeypatch, tmp_path):
missing = tmp_path / "CHANGELOG.md"
monkeypatch.setattr(release_notes, "_CHANGELOG", missing)
app = _Application()
source = ["unchanged"]

release_notes._read_release_notes(app, "index", source)

assert source == ["unchanged"]
assert app.env.dependencies == []


def test_read_release_notes_reports_missing_changelog(monkeypatch, tmp_path):
missing = tmp_path / "CHANGELOG.md"
monkeypatch.setattr(release_notes, "_CHANGELOG", missing)
app = _Application()

with pytest.raises(RuntimeError, match=str(Path(missing))):
release_notes._read_release_notes(app, "release_notes", [""])

assert app.env.dependencies == [str(missing)]


def test_deprecation_policy_uses_resolvable_developer_policy_link():
policy = (_DOCS_SOURCE / "deprecation_policy.md").read_text(encoding="utf-8")

assert "(developer_guide/python/development.md)" in policy
assert "development.md#" not in policy