Skip to content

feat(capture): rank selector candidates without changing capture YAML - #515

Open
gildesmarais wants to merge 5 commits into
masterfrom
feat/suggest-selector-candidates
Open

gildesmarais wants to merge 5 commits into
masterfrom
feat/suggest-selector-candidates

Conversation

@gildesmarais

Copy link
Copy Markdown
Member

What changed

  • SelectorCandidates ranks items, title, link, and published selector evidence best-first and allows any bucket to be empty.
  • Field selectors use the identifying class, CSS-escaped, instead of the lexicographically smallest class token.
  • Capture still writes one items selector into YAML. The default a[href] fallback is not listed as discovered evidence.
  • CaptureResult#candidates carries the four buckets. This branch is rebased onto master, so it includes the Falcon HTTPX retry fix.

Why

Studio refine needs more than the single winning items selector Capture emits for YAML. Empty evidence must stay a success, and utility-class pages must not publish a broad class token.

Risk

  • Field candidates are derived from the winning items roots only. A lower-ranked items selector plus a field selector can describe two different card shapes.
  • A non-empty items_selector hint skips discovery and returns empty buckets.

Review map

  1. spec/lib/html2rss/selector_candidates_spec.rb — empty buckets, best-first order, identifying class, escaped class tokens.
  2. lib/html2rss/selector_candidates.rb — ranking, dedupe, field CSS.
  3. lib/html2rss/capture.rb — YAML stays one items selector; candidates are separate.
  4. spec/lib/html2rss/capture_spec.rb — existing capture contracts plus candidate exposure.

Validation

  • make ready exited 0 on the pre-rebase candidate commits.
  • Rebase onto 98e9725b applied cleanly. make ready was not re-run after the rebase.

Expose best-first items/title/link/published evidence on CaptureResult while keeping emitted YAML single-selector and excluding the default a[href] fallback from discovered candidates.
Title matches were published as the lexicographically smallest class
token, so a utility class replaced title or font-semibold, and raw
tokens containing ] or , could widen the CSS selector.
The test result keeps an in-process copy of the fetched HTML so replay
can read it without putting the page on the public test hash.
The fetched-body check on a short item count is its own example so the
existing min_items example stays within RSpec/ExampleLength.
Ranked items and field candidates now carry visible_text so the studio
can label choices with a headline instead of CSS.

This branch has not been deployed

No deployments
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