Skip to content
Merged
Changes from all commits
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
20 changes: 19 additions & 1 deletion plugins/sphinx_adopters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

"""Sphinx extension to render and validate the ROS 2 adopters YAML file. """

import logging
import os

import yaml
Expand All @@ -23,6 +24,17 @@

from adopters_schema import validate_adopters, validate_adopter_urls

# Use the stdlib logger (not sphinx.util.logging) so URL reachability
# warnings are not promoted to errors when Sphinx is invoked with ``-W``
# (warnings-as-errors). External URL availability is inherently flaky
# and must not fail the CI workflow on transient outages.
logger = logging.getLogger(__name__)
if not logger.handlers:
_handler = logging.StreamHandler()
_handler.setFormatter(logging.Formatter('%(levelname)s: %(name)s: %(message)s'))
logger.addHandler(_handler)
logger.setLevel(logging.WARNING)


def _escape(text):
"""Escape HTML special characters."""
Expand Down Expand Up @@ -74,12 +86,18 @@ def run(self):

adopters = data.get('adopters', [])
errors = validate_adopters(adopters)
errors.extend(validate_adopter_urls(adopters))
if errors:
raise ExtensionError(
'Adopters YAML validation failed:\n' + '\n'.join(f' - {e}' for e in errors)
)

# URL reachability is best-effort: external sites can be transiently
# unavailable, so surface failures as warnings rather than failing the
# build (and the CI workflow) on flaky network conditions.
url_warnings = validate_adopter_urls(adopters)
for w in url_warnings:
logger.warning('Adopters YAML URL check: %s', w)

# Sort by organization name (A-Z), then date_added descending (newest first).
adopters.sort(key=lambda a: a.get('date_added', ''), reverse=True)
adopters.sort(key=lambda a: a.get('organization', '').lower())
Expand Down
Loading