Skip to content

Relax docs warning failures to opt in#1556

Draft
shi-eric wants to merge 1 commit into
NVIDIA:mainfrom
shi-eric:ershi/docs-opt-in-strict-build
Draft

Relax docs warning failures to opt in#1556
shi-eric wants to merge 1 commit into
NVIDIA:mainfrom
shi-eric:ershi/docs-opt-in-strict-build

Conversation

@shi-eric

@shi-eric shi-eric commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Description

Make docs warning failures opt-in for local build_docs.py runs while preserving strict warning checks in repository CI. This keeps contributor docs builds usable by default without weakening GitHub or GitLab documentation validation.

Changes

  • Add opt-in warning-as-error handling for docs builds.
  • Keep GitHub Actions and GitLab docs jobs running with strict warning checks.
  • Document the strict docs build mode and add a changelog entry.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.
  • CHANGELOG.md is updated for any user-facing changes under the Unreleased section.

Validation summary

Built the documentation locally with an isolated Warp cache path. The build generated API stubs, ran Sphinx, and completed successfully.

Command:

WARP_CACHE_PATH=/tmp/warp-cache-warp-ershi-docs-opt-in-strict-build \
WARP_CACHE_ROOT=/tmp/warp-cache-warp-ershi-docs-opt-in-strict-build \
uv run --extra docs build_docs.py

Summary by CodeRabbit

  • New Features

    • Added an offline documentation mode to skip external cross-reference lookups (WARP_DOCS_OFFLINE=1).
    • Added a configurable warnings-as-errors option for documentation/doctest builds, with CI running in strict mode.
  • Bug Fixes

    • Local documentation builds are more resilient when external inventory hosts are unreachable.
    • CI documentation checks now fail the build on Sphinx warnings that previously could pass.
  • Documentation

    • Updated the contribution guide and changelog to clarify offline behavior and warning strictness.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Enterprise

Run ID: acebe3a5-941a-4bce-a12f-daa3cf6fbd3a

📥 Commits

Reviewing files that changed from the base of the PR and between 5d82ae5 and 1cbdc81.

📒 Files selected for processing (7)
  • .github/workflows/ci.yml
  • .github/workflows/sphinx.yml
  • .gitlab-ci.yml
  • CHANGELOG.md
  • build_docs.py
  • docs/conf.py
  • docs/user_guide/contribution_guide.rst
✅ Files skipped from review due to trivial changes (1)
  • docs/user_guide/contribution_guide.rst
🚧 Files skipped from review as they are similar to previous changes (3)
  • CHANGELOG.md
  • .gitlab-ci.yml
  • build_docs.py

📝 Walkthrough

Walkthrough

build_docs.py gains a --warnings-as-errors flag that passes -W to Sphinx. CI workflows now pass that flag everywhere docs are built. docs/conf.py now skips intersphinx when inventories are unreachable or WARP_DOCS_OFFLINE=1 is set, while the docs guide and changelog describe the new behavior.

Changes

Docs build hardening

Layer / File(s) Summary
Warnings-as-errors flow in build_docs.py
build_docs.py
Adds --warnings-as-errors, extends build_sphinx_docs, conditionally inserts -W, and threads the setting through HTML and doctest builds with environment-variable handling.
CI wiring for strict docs builds
.github/workflows/ci.yml, .github/workflows/sphinx.yml, .gitlab-ci.yml
Passes --warnings-as-errors to all docs build commands in GitHub Actions and GitLab CI.
Conditional intersphinx mapping in docs/conf.py
docs/conf.py
Replaces the unconditional intersphinx map with a private inventory mapping and a reachability check that disables intersphinx for offline or unreachable inventories.
Docs updates for warning handling
CHANGELOG.md, docs/user_guide/contribution_guide.rst
Describes default warning behavior, CI strictness, and offline documentation builds in the changelog and contribution guide.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: documentation warning failures are now opt-in rather than mandatory, which is the core intent of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown

Greptile Summary

This PR relaxes Sphinx warning-as-error behavior for local build_docs.py runs while preserving strict checks in all CI paths (GitHub Actions, GitLab, and the merge-request docs job). A reachability probe for intersphinx inventories is added so offline local builds degrade gracefully instead of aborting.

  • build_docs.py: adds --warnings-as-errors flag (off by default); sets/restores WARP_DOCS_WARNINGS_AS_ERRORS env var around each build_main call so conf.py knows whether to bypass the probe.
  • docs/conf.py: adds _inventories_reachable() (2 s per-host timeout, fails fast on first error); when WARP_DOCS_WARNINGS_AS_ERRORS=1 the probe is skipped and the full intersphinx mapping is used directly, keeping CI strict.
  • CI files (.github/workflows/ci.yml, .github/workflows/sphinx.yml, .gitlab-ci.yml): all docs and doctest jobs now pass --warnings-as-errors; the shared .build-docs-common template covers both the merge request docs and pages GitLab jobs.

Confidence Score: 5/5

Safe to merge — this is a purely additive opt-in flag with no risk to existing behavior; all CI jobs are correctly updated to pass --warnings-as-errors.

The change is well-scoped: local builds become more resilient without any weakening of CI strictness. The env var is correctly set and restored around each sphinx call, the probe has a short timeout with fail-fast semantics, and every CI docs/doctest job (GitHub Actions and GitLab, including the shared .build-docs-common template) was updated. No logic paths were found that could silently swallow errors or produce incorrect output.

No files require special attention.

Important Files Changed

Filename Overview
build_docs.py Adds --warnings-as-errors flag and correctly sets/restores WARP_DOCS_WARNINGS_AS_ERRORS env var around each sphinx build_main call using try/finally.
docs/conf.py Adds intersphinx reachability probe with 2 s timeout and fail-fast semantics; WARP_DOCS_OFFLINE and WARP_DOCS_WARNINGS_AS_ERRORS env vars bypass the probe cleanly.
.gitlab-ci.yml All four docs-building invocations updated with --warnings-as-errors; merge request docs and pages jobs inherit the flag via the .build-docs-common template.
.github/workflows/ci.yml Both build-docs and doctest jobs updated with --warnings-as-errors.
.github/workflows/sphinx.yml Sphinx publish job updated with --warnings-as-errors.
CHANGELOG.md Changelog entry added under Unreleased > Documentation describing both the new flag and offline probe behavior.
docs/user_guide/contribution_guide.rst Contribution guide updated with examples for --warnings-as-errors and WARP_DOCS_OFFLINE.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["build_docs.py called"] --> B{"--warnings-as-errors\nflag passed?"}
    B -- Yes --> C["Set WARP_DOCS_WARNINGS_AS_ERRORS=1\nAdd -W to sphinx args"]
    B -- No --> D["Remove WARP_DOCS_WARNINGS_AS_ERRORS\nNo -W flag"]
    C --> E["sphinx build_main runs\nconf.py is loaded"]
    D --> E
    E --> F{"WARP_DOCS_OFFLINE=1?"}
    F -- Yes --> G["intersphinx_mapping = {}"]
    F -- No --> H{"WARP_DOCS_WARNINGS_AS_ERRORS=1?"}
    H -- Yes --> I["intersphinx_mapping = full mapping\n(probe bypassed)"]
    H -- No --> J["_inventories_reachable probe\n(2s timeout per host, fail-fast)"]
    J -- All reachable --> K["intersphinx_mapping = full mapping"]
    J -- Any unreachable --> L["intersphinx_mapping = {}\n(log info message)"]
    G --> M["Sphinx build"]
    I --> M
    K --> M
    L --> M
    M --> N["Restore previous\nWARP_DOCS_WARNINGS_AS_ERRORS\n(finally block)"]
Loading

Reviews (3): Last reviewed commit: "Relax build_docs.py warnings-as-errors t..." | Re-trigger Greptile

Comment thread docs/conf.py
Comment thread docs/conf.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/conf.py (1)

421-428: ⚡ Quick win

Use Google-style sections in the new function docstring.

The new _inventories_reachable() docstring is narrative-only; project Python guidelines require Google-style docstrings.

Suggested docstring format
 def _inventories_reachable(mapping, timeout=5):
-    """Return True if the network can reach the intersphinx inventory hosts.
-
-    A host that returns *any* HTTP response (even 403/404) is reachable: Sphinx
-    fetches inventories with its own user-agent and may succeed where a bare
-    probe is blocked, so only connection-level failures (DNS, refused, timeout)
-    count as "offline". This avoids wrongly disabling intersphinx in CI just
-    because a CDN rejects the probe's user-agent.
-    """
+    """Check whether configured intersphinx inventory hosts are reachable.
+
+    Args:
+        mapping: Intersphinx mapping dictionary.
+        timeout: Probe timeout in seconds.
+
+    Returns:
+        ``True`` if configured hosts are reachable.
+    """

As per coding guidelines: **/*.py: “Use Google-style docstrings.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/conf.py` around lines 421 - 428, The `_inventories_reachable()`
docstring in `docs/conf.py` needs to be converted from narrative prose to the
project’s Google-style docstring format. Update the function’s docstring to use
standard sections such as Args, Returns, and any other applicable headings,
while preserving the current behavior description about network reachability and
connection-level failures.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/conf.py`:
- Around line 420-442: The _inventories_reachable function returns True
immediately upon encountering the first reachable host (at lines 436 and 439),
without checking if all configured inventory hosts in the mapping are reachable.
This causes the function to enable intersphinx even when some inventories are
unreachable. Remove the early return True statements within the loop and instead
continue iterating through all hosts in mapping.values() to check every
configured inventory. Only return True after confirming that all hosts are
reachable with HTTP responses, and return False only if any host has a
connection-level failure (URL error, timeout, etc.).

---

Nitpick comments:
In `@docs/conf.py`:
- Around line 421-428: The `_inventories_reachable()` docstring in
`docs/conf.py` needs to be converted from narrative prose to the project’s
Google-style docstring format. Update the function’s docstring to use standard
sections such as Args, Returns, and any other applicable headings, while
preserving the current behavior description about network reachability and
connection-level failures.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Enterprise

Run ID: 6d279c32-22ab-493c-b64c-881e87e22cfd

📥 Commits

Reviewing files that changed from the base of the PR and between e0fd0ab and 7a11795.

📒 Files selected for processing (7)
  • .github/workflows/ci.yml
  • .github/workflows/sphinx.yml
  • .gitlab-ci.yml
  • CHANGELOG.md
  • build_docs.py
  • docs/conf.py
  • docs/user_guide/contribution_guide.rst

Comment thread docs/conf.py Outdated
@shi-eric shi-eric force-pushed the ershi/docs-opt-in-strict-build branch from 7a11795 to 5d82ae5 Compare June 13, 2026 22:42
Building docs hardcoded sphinx-build -W, so an unreachable intersphinx
inventory (offline machine, sandbox with no egress, flaky DNS) became a
fatal error and aborted the build with no output, even though the local
content was fine.

Make warnings-as-errors opt-in: build_docs.py is lenient by default and
takes a new --warnings-as-errors flag, which CI passes to keep strict
checks. Also skip external intersphinx resolution in conf.py when the
inventories are unreachable or WARP_DOCS_OFFLINE=1 is set, so offline
builds still produce output.

Signed-off-by: Eric Shi <ershi@nvidia.com>
@shi-eric shi-eric force-pushed the ershi/docs-opt-in-strict-build branch from 5d82ae5 to 1cbdc81 Compare June 14, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant