Skip to content

Further changes - #5

Merged
lars20070 merged 15 commits into
masterfrom
lars20070/furtherchanges
Aug 1, 2026
Merged

Further changes#5
lars20070 merged 15 commits into
masterfrom
lars20070/furtherchanges

Conversation

@lars20070

@lars20070 lars20070 commented Jul 31, 2026

Copy link
Copy Markdown
Owner

The PR adds a md/GoogleStyleGuide.md test input file. It was generated with the web2md script.

Added

  • web2md, a deterministic website-to-Markdown scraper (web2md/src/web2md.py).
    It walks a documentation site and writes one Markdown document into md/,
    as an upstream source step alongside the existing pdf2md/. No model is
    involved. Target site and output filename are two constants at the top of the
    module (SOURCE_URL, OUTPUT_FILE); everything else URL-shaped is derived
    from SOURCE_URL.
  • CLI flags for the scraper: --refresh (re-fetch instead of reusing the
    cache), --cache-dir, and --output. Fetched HTML is cached under
    web2md/cache/ (gitignored) with bounded retries, so re-runs are cheap.
  • md/GoogleStyleGuide.md: a scraped snapshot of the
    Google developer documentation style guide
    (16,514 lines), now tracked as wiki input.
  • Offline pytest suite for the scraper in web2md/tests/ (11 test modules plus
    conftest.py). HTTP is served through httpx.MockTransport, so no test opens
    a socket and writes stay in tmp_path. Coverage spans the pure helpers
    (slugs, anchors, link rewriting, Markdown conversion, assembly), every
    validate_output error branch, fetch retry and caching, and one end-to-end
    run() over a synthetic 72-page site.
  • make test (runs pytest via the overridable PYTEST variable) and
    make scrape (runs the scraper by path) targets.
  • CI test job that reuses make test, installing only the test and web2md
    dependency groups with --only-group so it never pulls marker-pdf or torch.
    It checks out with persist-credentials: false.
  • Dependency groups test (pytest) and web2md (httpx, beautifulsoup4, lxml,
    markdownify), keeping each CI job's install narrow; uv.lock updated.
  • Ruff lint configuration: rule selection (E, W, F, I, UP, B, SIM,
    C4, RET, PT, D), Google docstring convention, line-length = 100, and
    a per-file ignore so tests need no module/function docstrings. Pytest is
    configured in pyproject.toml with pythonpath = ["web2md/src"] in place of a
    [build-system].
  • CodeRabbit review instructions for **/*.py and **/tests/**/*.py, covering
    mutable default arguments, blocking calls in async functions, leaked secrets,
    missing context managers and timeouts, unsanitized shell/LLM input, fixture
    isolation, and the no-real-network rule for tests.
  • Cursor editor configuration: .cursor/mcp.json (Context7 and GitHub MCP
    servers) and .cursor/settings.json.
  • Documentation: web2md/README.md, a "Starting from a website" section in
    README.md, and a web2md/ section in AGENTS.md.

Changed

  • md/ is no longer gitignored, so scraped source documents are tracked.
  • .gitignore now also covers __pycache__/, .pytest_cache/, .ruff_cache/
    and web2md/cache/.
  • CI path filter and make lint extended to web2md/** and
    web2md/README.md.
  • CodeRabbit finishing_touches for docstrings and unit tests are enabled now
    that first-party code exists, and .cursor/mcp.json is excluded from review
    to silence its @latest warning.
  • README Development section rewritten: it describes the three dependency
    groups and the per-tool web2md/src + web2md/tests layout instead of the
    previous "adopt src/md2okf/ when real Python lands" placeholder.
  • .cspell.json extended with Python tooling vocabulary (httpx, conftest,
    monkeypatch, pydocstyle, and similar).

Removed

  • Superseded Claude plan documents .claude/plans/compile-wiki-skill-container.md,
    observable-wiki-compilation.md and observe-pi-agent-sandbox.md; the
    directory is kept via .gitkeep.

Summary by CodeRabbit

  • New Features

    • Added a command-line scraper that converts Google’s developer documentation style guide into a single Markdown document.
    • Supports cached downloads, retry handling, refresh mode, custom cache locations, and custom output paths.
    • Preserves navigation, links, anchors, callouts, code blocks, tables, images, and document metadata.
    • Validates generated Markdown before writing the final output.
  • Documentation

    • Added setup, usage, output, caching, testing, and linting guidance for the scraper.
  • Tests

    • Added comprehensive offline and end-to-end coverage for scraping, conversion, linking, validation, and CLI behavior.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a complete web2md scraper for the Google Developer Documentation Style Guide, with caching, retries, HTML conversion, link rewriting, validation, tests, CI integration, documentation, and execution commands.

Changes

Google style guide scraper

Layer / File(s) Summary
Scraper design and implementation plan
.cursor/plans/*
Documents the scraper architecture, conversion rules, validation checks, safeguards, and reference implementation.
Page discovery, fetching, and HTML cleanup
web2md/src/web2md.py, web2md/tests/conftest.py, web2md/tests/test_discovery.py, web2md/tests/test_fetch.py, web2md/tests/test_cleaning.py, web2md/tests/test_slugs.py
Adds page discovery, cached fetching with retries, DevSite cleanup, URL helpers, fixtures, and focused tests.
Anchor rewriting and Markdown conversion
web2md/src/web2md.py, web2md/tests/test_links.py, web2md/tests/test_converter.py, web2md/tests/test_run.py
Adds namespaced anchors, internal-link rewriting, image handling, callouts, definition lists, heading conversion, and Markdown output tests.
Document assembly, validation, and CLI workflow
web2md/src/web2md.py, web2md/tests/test_assemble.py, web2md/tests/test_validate.py, web2md/tests/test_run.py, web2md/tests/test_cli.py
Adds document assembly, table-of-contents generation, output validation, end-to-end orchestration, CLI options, and tests.
Project integration and usage
pyproject.toml, Makefile, .github/workflows/ci.yml, .gitignore, .coderabbit.yaml, AGENTS.md, README.md, web2md/README.md, .cspell.json
Adds dependency groups, test and lint configuration, Make targets, CI execution, repository guidance, usage documentation, and spelling terms.

Cursor MCP configuration

Layer / File(s) Summary
MCP server settings
.cursor/mcp.json, .cursor/settings.json
Configures Context7 and GitHub MCP servers and remote container folder behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is vague and does not use an imperative verb or identify the affected area. Replace it with an imperative, area-specific title under 72 characters, such as "Add web2md scraper tests and tooling".
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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: 4

🤖 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 @.cursor/mcp.json:
- Around line 3-9: Pin the package version in the context7 MCP configuration by
replacing `@latest` in the command arguments with an explicitly reviewed exact
`@upstash/context7-mcp` version. Keep the existing npx -y invocation and update
the pinned version deliberately when upgrading.

In @.cursor/plans/google_style_guide_scraper_plan.md:
- Around line 179-303: Remove the obsolete “Ready-to-Run Reference
Implementation Script” section from the plan, or clearly label the entire
document and script as historical and non-executable. Ensure agents are directed
to the authoritative namespaced-anchor design in
google-style-guide-to-markdown.md rather than this invalid implementation.

In @.cursor/plans/google-style-guide-to-markdown.md:
- Around line 170-175: Update the retry policy in the Fetch section to define a
finite maximum attempt count, cap exponential backoff delays, and honor valid
Retry-After response headers for 429 and 5xx responses. Ensure retries stop
after the configured limit so the style-guide command cannot run indefinitely.
- Around line 210-217: Update the “Assemble” output specification to remove the
runtime-generated generated_at frontmatter field, or require it as an explicit
stable input/source revision; ensure identical inputs produce identical Markdown
bytes and update the stated static frontmatter line count accordingly.
🪄 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.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 199f8c6d-ea12-4f70-a074-65376d478d05

📥 Commits

Reviewing files that changed from the base of the PR and between 2ca8fc1 and 5a64678.

📒 Files selected for processing (4)
  • .cursor/mcp.json
  • .cursor/plans/google-style-guide-to-markdown.md
  • .cursor/plans/google_style_guide_scraper_plan.md
  • .cursor/settings.json

Comment thread .cursor/mcp.json
Comment thread .cursor/plans/google_style_guide_scraper_plan.md Outdated
Comment thread .cursor/plans/google-style-guide-to-markdown.md Outdated
Comment thread .cursor/plans/google-style-guide-to-markdown.md 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: 2

🧹 Nitpick comments (1)
web2md/google_style_guide.py (1)

546-564: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Make the size and term-count thresholds non-fatal or tunable.

SIZE_MIN/SIZE_MAX and WORD_LIST_TERM_EXPECTED ± 30 encode a snapshot of the current upstream guide. If Google adds or removes content, the style-guide Make target fails and writes no output, even though the conversion succeeded. Structural checks (broken anchors, leftover devsite-, heading depth) deserve a hard failure; volume heuristics do not.

♻️ Suggested split
-    size = len(md.encode("utf-8"))
-    if not (SIZE_MIN <= size <= SIZE_MAX):
-        errors.append(
+    warnings_out: list[str] = []
+    size = len(md.encode("utf-8"))
+    if not (SIZE_MIN <= size <= SIZE_MAX):
+        warnings_out.append(
             f"output size {size / 1024 / 1024:.2f} MB outside "
             f"{SIZE_MIN / 1024 / 1024:.1f}–{SIZE_MAX / 1024 / 1024:.1f} MB"
         )
@@
     if not (low <= term_count <= high):
-        errors.append(
+        warnings_out.append(
             f"word-list term count {term_count} outside {low}–{high} "
             f"(expected ~{WORD_LIST_TERM_EXPECTED})"
         )
+    for warn in warnings_out:
+        print(f"VALIDATION WARNING: {warn}", file=sys.stderr)
🤖 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 `@web2md/google_style_guide.py` around lines 546 - 564, Update the validation
logic around the size and word-list term-count checks so these volume heuristics
are configurable or reported non-fatally rather than added to the fatal errors
that prevent output. Preserve hard failures for structural validation checks,
and reuse the existing configuration or warning mechanism if available;
specifically adjust the SIZE_MIN/SIZE_MAX and
WORD_LIST_TERM_EXPECTED/WORD_LIST_TERM_TOLERANCE handling without changing the
conversion output.
🤖 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 `@web2md/google_style_guide.py`:
- Around line 168-197: Update the retry loop around the 429/5xx handling to
assign an appropriate HTTP error for the response to last_error before
continuing. Ensure that when all attempts return retryable statuses, the final
SystemExit message from the fetch flow includes the HTTP failure instead of
None, while preserving the existing retry behavior.

In `@web2md/README.md`:
- Around line 14-16: Update the README installation instructions around “uv sync
--group web2md” to accurately reflect dependency installation: use the mode that
excludes the project’s marker-pdf dependencies, such as “uv sync --only-group
web2md”, or remove the claim that the setup is separate from the heavy
marker-pdf stack.

---

Nitpick comments:
In `@web2md/google_style_guide.py`:
- Around line 546-564: Update the validation logic around the size and word-list
term-count checks so these volume heuristics are configurable or reported
non-fatally rather than added to the fatal errors that prevent output. Preserve
hard failures for structural validation checks, and reuse the existing
configuration or warning mechanism if available; specifically adjust the
SIZE_MIN/SIZE_MAX and WORD_LIST_TERM_EXPECTED/WORD_LIST_TERM_TOLERANCE handling
without changing the conversion output.
🪄 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.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1cec4aad-a153-4e3a-9c07-b09d4bb60419

📥 Commits

Reviewing files that changed from the base of the PR and between 5a64678 and e6c8c95.

⛔ Files ignored due to path filters (3)
  • md/.gitkeep is excluded by !md/**
  • md/GoogleDeveloperDocumentationStyleGuide.md is excluded by !md/**
  • uv.lock is excluded by !**/*.lock, !uv.lock
📒 Files selected for processing (9)
  • .claude/plans/.gitkeep
  • .cspell.json
  • .cursor/plans/.gitkeep
  • .cursor/plans/google-style-guide-to-markdown.md
  • .gitignore
  • Makefile
  • pyproject.toml
  • web2md/README.md
  • web2md/google_style_guide.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • .cursor/plans/google-style-guide-to-markdown.md

Comment thread web2md/src/web2md.py
Comment thread web2md/README.md

@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.

♻️ Duplicate comments (1)
web2md/README.md (1)

25-34: 🚀 Performance & Scalability | 🟠 Major

Keep scraper commands separate from project dependencies.

--group web2md does not omit [project].dependencies; --only-group web2md omits the project and its dependencies. The current commands can therefore install marker-pdf and psutil, contradicting the README's isolation claim. (docs.astral.sh)

  • web2md/README.md#L25-L34: change uv sync --group web2md and both direct scraper commands to --only-group web2md, or remove the isolation claim.
  • Makefile#L71-L73: run the scraper with uv run --only-group web2md ....

As per path instructions: “flag commands, paths, options, and examples that this change has made wrong or stale.” Context7 was not available in this review; the official uv documentation was checked.

Proposed command changes
-uv sync --group web2md
+uv sync --only-group web2md

-uv run --group web2md python web2md/src/web2md.py
+uv run --only-group web2md python web2md/src/web2md.py

-uv run --group web2md python web2md/src/web2md.py --refresh
+uv run --only-group web2md python web2md/src/web2md.py --refresh

-	uv run --group web2md python web2md/src/web2md.py
+	uv run --only-group web2md python web2md/src/web2md.py
#!/usr/bin/env bash
set -euo pipefail

echo "Dependencies selected by --group web2md:"
uv tree --group web2md | grep -E 'marker-pdf|psutil' || true

echo "Dependencies selected by --only-group web2md:"
if uv tree --only-group web2md | grep -E 'marker-pdf|psutil'; then
  echo "Heavy project dependencies remain selected" >&2
  exit 1
fi
🤖 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 `@web2md/README.md` around lines 25 - 34, Update the scraper commands in
web2md/README.md lines 25-34 to use --only-group web2md instead of --group
web2md, including the sync and both direct uv run examples. Update the scraper
invocation in Makefile lines 71-73 to use --only-group web2md as well,
preserving the existing module and arguments.

Source: Path instructions

🤖 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.

Duplicate comments:
In `@web2md/README.md`:
- Around line 25-34: Update the scraper commands in web2md/README.md lines 25-34
to use --only-group web2md instead of --group web2md, including the sync and
both direct uv run examples. Update the scraper invocation in Makefile lines
71-73 to use --only-group web2md as well, preserving the existing module and
arguments.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 45a26b49-2076-4cf6-b124-a23de7889a69

📥 Commits

Reviewing files that changed from the base of the PR and between e6c8c95 and ec4032b.

⛔ Files ignored due to path filters (2)
  • md/GoogleDeveloperDocumentationStyleGuide.md is excluded by !md/**
  • uv.lock is excluded by !**/*.lock, !uv.lock
📒 Files selected for processing (22)
  • .coderabbit.yaml
  • .cspell.json
  • .cursor/plans/google-style-guide-to-markdown.md
  • .github/workflows/ci.yml
  • .gitignore
  • AGENTS.md
  • Makefile
  • README.md
  • pyproject.toml
  • web2md/README.md
  • web2md/src/web2md.py
  • web2md/tests/conftest.py
  • web2md/tests/test_assemble.py
  • web2md/tests/test_cleaning.py
  • web2md/tests/test_cli.py
  • web2md/tests/test_converter.py
  • web2md/tests/test_discovery.py
  • web2md/tests/test_fetch.py
  • web2md/tests/test_links.py
  • web2md/tests/test_run.py
  • web2md/tests/test_slugs.py
  • web2md/tests/test_validate.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • .gitignore
  • .cursor/plans/google-style-guide-to-markdown.md

@lars20070

Copy link
Copy Markdown
Owner Author

@coderabbitai summary

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
✅ Action performed

Summary regeneration triggered.

@lars20070

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 39 minutes.

@lars20070

Copy link
Copy Markdown
Owner Author

@mprokopov I will merge this PR since web2md is pretty isolated from the rest of the codebase.

@lars20070
lars20070 merged commit df36595 into master Aug 1, 2026
4 checks passed
@lars20070
lars20070 deleted the lars20070/furtherchanges branch August 1, 2026 08:40
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