fix(ci): docs drift handles repeated placeholders, scopes its warning filter

Review follow-ups: `providers.<id>.models.<model>.timeout_seconds` now
matches (a second <...> segment no longer ends the pattern), the YAML
warning filter is scoped with catch_warnings, and the slash-command list
drops a `hidden` filter CommandDef never had.
This commit is contained in:
Teknium
2026-10-11 04:43:00 -07:00
parent 4e8fe569e4
commit 7bc05085f0
2 changed files with 11 additions and 8 deletions

View File

@@ -27,7 +27,7 @@ SLASH_PAGE = DOCS / "reference" / "slash-commands.md"
BASELINE = Path(__file__).with_name("docs_drift_baseline.json")
_FENCE = re.compile(r"```ya?ml[^\n]*\n(.*?)```", re.DOTALL)
_DOTTED = re.compile(r"(?<![\w.])[A-Za-z_][\w-]*(?:\.[A-Za-z_][\w-]*)+")
_PLACEHOLDER = re.compile(r"(?<![\w.])((?:[a-z_][\w-]*\.)+(?:<[\w-]+>|\*)(?:\.(?:[a-z_][\w-]*|\*))*)")
_PLACEHOLDER = re.compile(r"(?<![\w.])((?:[a-z_][\w-]*\.)+(?:<[\w-]+>|\*)(?:\.(?:[a-z_][\w-]*|<[\w-]+>|\*))*)")
# Globs only count inside inline code (`auxiliary.*.provider`): bare `*` in prose is emphasis.
_CODE_SPAN = re.compile(r"`([^`\n]+)`")
@@ -62,7 +62,7 @@ def slash_commands() -> list[str]:
sys.path.insert(0, str(ROOT))
from hermes_cli.commands import COMMAND_REGISTRY
return sorted(c.name for c in COMMAND_REGISTRY if not getattr(c, "hidden", False))
return sorted(c.name for c in COMMAND_REGISTRY)
def _yaml_paths(text: str) -> set[str]:
@@ -71,7 +71,6 @@ def _yaml_paths(text: str) -> set[str]:
from hermes_yaml import safe_load
from ruamel.yaml.error import YAMLError
warnings.simplefilter("ignore") # ruamel's YAML 1.1 float notes on doc snippets are noise here
paths: set[str] = set()
def flat(d: dict, pre: tuple[str, ...]) -> None:
@@ -82,10 +81,12 @@ def _yaml_paths(text: str) -> set[str]:
flat(v, p)
for m in _FENCE.finditer(text):
try:
doc = safe_load(m.group(1))
except YAMLError: # a partial or templated snippet documents nothing reliably
continue
with warnings.catch_warnings():
warnings.simplefilter("ignore") # ruamel's YAML 1.1 float notes on doc snippets
try:
doc = safe_load(m.group(1))
except YAMLError: # a partial or templated snippet documents nothing reliably
continue
if isinstance(doc, dict):
flat(doc, ())
return paths

View File

@@ -40,12 +40,14 @@ def test_detects_each_documentation_form(drift, monkeypatch):
docs = (
"Set `agent.max_turns` to cap a run.\n"
"Every `auxiliary.<task>.timeout` is in seconds; `display.pet.*` tunes the pet.\n"
"Per model: `providers.<id>.models.<model>.timeout_seconds`.\n"
"```yaml\ncompression:\n threshold: 0.5\n```\n"
"This sentence has emphasis on *agent.* things.\n"
)
monkeypatch.setattr(drift, "_docs_text", lambda: docs)
monkeypatch.setattr(drift, "config_leaves", lambda: [
"agent.max_turns", "auxiliary.vision.timeout", "display.pet.size",
"compression.threshold", "agent.secret_knob", "auxiliary.vision.api_key"])
"compression.threshold", "agent.secret_knob", "auxiliary.vision.api_key",
"providers.nous.models.hermes.timeout_seconds"])
monkeypatch.setattr(drift, "slash_commands", list)
assert drift.find_gaps()["config"] == ["agent.secret_knob", "auxiliary.vision.api_key"]