Repository navigation
Link folders under the blueprint by the spelling Git committed, and fix render --ref's help - #333
Conversation
#301 recorded the committed spelling of each captured file whose name macOS Git stores composed, and source-note links looked their whole path up in that map. A link to a folder, such as `../sources/`, never matched, so when a folder above it was decomposed on disk the link named the on-disk spelling and 404'd. The map now holds each file's leading folder paths too, and a link takes the committed spelling of its longest mapped leading path. That also covers a folder render does not capture, such as one holding only a `.gitkeep`. The test runs on every OS with the composed ls-tree output the existing decomposed-name test uses, now a shared helper.
Since #300, code links need only the captured Lean sources in the commit, and links into the blueprint need the blueprint too. The help still said links needed every rendered input.
|
Review: changes requested, to comments and the description only. The code is right. Reviewed by four independent lenses (correctness and tests; necessity and scope; design and style; claims and contracts), a refuting verifier per lens and a completeness critic. I checked each surviving finding against the code and re-ran the tests on main 30e28b1 with this PR merged. What holds
Changes requested
Optional
None of these changes behavior. Once they are in, mark the PR ready; it can then be merged. |
The comment in _SourceBase.href said the lookup covers folders render did not capture. Render does capture such a folder, just no file inside it, and only the leading folders it shares with a captured file take their committed spelling; its own decomposed name keeps the link's spelling. The spellings docstring again says why its keys are NFC.
|
Follow-up: the requested changes are in.
CI is green on 00e30ee (Linux 3.10 and 3.13, real Lean, the skeleton suite, the REPL and Windows). With the requested changes in, this is ready: mark it ready for review and merge. |
Main brings #333 (folder links by their committed spelling) and #348 (a Lean name selects its one public declaration, or is reported as ambiguous). README.md, __main__.py, audit.py, lean.py, render.py and tests/test_lean_sources.py conflicted. The resolution keeps main's selection and its duplicates map, which replace this branch's elsewhere map and per-file declaration lines; source spans take main's keying by declaration and stay bounded by each file's own declarations. check and audit report main's ambiguous names first and keep the ledger hint for a catalog name that is not found. The alias prepass and the name filter keep scanning every file that may declare a requested name, so a filtered index selects as the unfiltered one does. Repository links take main's folder spellings and keep the quoted ref.
Two follow-ups from the post-merge review of #295, #296, #297, #300 and #301.
Folder links on macOS (bad5b1b, 00e30ee)
#301 made code, Markdown source and source-note links name the spelling macOS Git committed when a name is decomposed (NFD) on disk. Source-note links looked their whole path up in a map of committed file paths, so a link to a folder, such as
[the notes](../sources/)or a subfolder, never matched. When a folder above it was decomposed on disk, as Finder writes names, the link named the on-disk spelling and GitHub returned 404. Before #301 that layout got no links into the blueprint at all, with a warning; after it, file links were right and folder links broke._sources_basenow maps each captured file's leading folder paths as well as the file itself, and a link takes the committed spelling of its longest mapped leading path. A folder with no captured file below it, such as one holding only a.gitkeep(render skips hidden files), gets the committed spelling of the leading folders it shares with a captured file; its own name keeps the link's spelling. A link to a subfolder the commit does not hold, an empty one or one holding only untracked hidden files, 404s under any spelling, as it did before. An untracked note that render captures still drops every link into the blueprint, with a warning.render --refhelp (69a10b6)Since #300, code links need only the captured Lean sources in the commit, and links into the blueprint need the blueprint too. The help said links appear only if the commit holds "the exact rendered inputs". It now says which links need which inputs.
Tests
test_a_link_to_a_folder_names_the_spelling_git_committedputs the blueprint under a folder whose name is decomposed on disk, with a note insources/and asources/drafts/folder holding only a committed.gitkeep. The links to../sources/, the note and../sources/drafts/, and a statement's Markdown source link, must all name the committed spelling, the on-disk spelling must appear nowhere on the page, and there is no warning. It runs on every OS: liketest_decomposed_file_names_link_to_the_spelling_git_committed, it makesgit ls-treeprint the composed spelling macOS Git prints, through a helper both tests now share. Either half of the fix alone fails it (the file-only map, or an exact-only lookup), under real macOS precomposition and under Linux Git's behavior emulated withcore.precomposeUnicodefalse; with both, it passes. The other source-note and decomposed-name tests pass unchanged. They ran with a plain Python driver, without pytest or Lean, because the machine was over its load limit, so CI is the authority.ruff checkis clean.Overlaps with open PRs
_SourceBase.href: keep this branch's longest-prefix loop, thenpath = "/".join(parts)and Scale roadmap inventories and the full DAG explorer #90'squote(self.ref, safe='')return. Taking Scale roadmap inventories and the full DAG explorer #90's side fails the new test on Linux CI._sources_base(..., spellings). Whichever lands second keeps the leading-path loop, iterating that function'sspellingsargument under another local name. If the other side is taken, the new test fails on Linux CI.