Skip to content

fix(docs): rewrite env README relative links in generated stubs - #1101

Open
Cunninger wants to merge 1 commit into
huggingface:mainfrom
Cunninger:fix/sync-env-docs-relative-links-1095
Open

fix(docs): rewrite env README relative links in generated stubs#1101
Cunninger wants to merge 1 commit into
huggingface:mainfrom
Cunninger:fix/sync-env-docs-relative-links-1095

Conversation

@Cunninger

@Cunninger Cunninger commented Aug 30, 2026

Copy link
Copy Markdown

Fixes #1095

scripts/sync_env_docs.py inlined each env README into docs/source/environments/<slug>.md but only rewrote HTML src="assets/" image paths. Markdown links such as [example](../../examples/foo.py) stayed relative, so they resolved from the docs stub (wrong depth) on the published site.

This extends stub generation to rewrite markdown links that escape envs/<env>/ into GitHub blob/tree URLs (the convention browsergym / pelican_svg already use by hand). Extra ../ segments that walk out of the repo (e.g. git_env's ../../../examples/...) are stripped so they still map to the intended path.

--check already treats rewritten stubs as the expected content, so leftover relative links fail CI until --fix is run. Regenerated the currently affected stubs (agent_world_model, carla, git, opencode, repl).

Tests:

PYTHONPATH=src:envs uv run pytest tests/scripts/test_sync_env_docs.py -v
uv run python scripts/sync_env_docs.py --check

9 passed; --check is clean.

RFC: not required (docs generator only, no public API / core change).


Note

Low Risk
Docs sync tooling and generated markdown only; no runtime API or environment behavior changes.

Overview
Fixes broken example and RFC links on the published docs site when env READMEs are inlined into docs/source/environments/*.md (issue #1095). Previously only HTML assets/ image paths were absolutized; markdown links like ../../examples/foo.py stayed relative and resolved from the wrong path.

scripts/sync_env_docs.py now rewrites markdown links that point outside envs/<env>/ into GitHub blob/tree URLs (and raw for images), including normalizing over-long ../ chains (e.g. git_env’s ../../../examples/...). Stub generation calls this during generate_stub, so --check in CI expects the rewritten output.

Regenerated affected stubs (agent_world_model, carla, git, opencode, repl) and added tests/scripts/test_sync_env_docs.py for path resolution, link rewriting, and integration via generate_stub.

Reviewed by Cursor Bugbot for commit 99e46a9. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

Relative links in env READMEs break in the generated docs stubs

1 participant