Remove failed-new-file TOC entries before opening sync PR - #289
Conversation
|
@mmcky Please review the files under |
…notice (QuantEcon#156) Review follow-up on the failed-new-file TOC filter: - removeTocFileEntries no longer round-trips the TOC through yaml.dump. QuantEcon TOCs use the zero-indent block style js-yaml re-indents, so a one-entry removal became a whole-file rewrite (401 changed lines on the 204-line lecture-python TOC). Entries are now spliced out of the original text — the `- file:` line plus any deeper-indented `title:`/`sections:` children — and the result is verified by parse against the filtered document before a noArrayIndent re-serialisation fallback is considered. Real-TOC check: exactly the removed lines differ, nothing else. - Recursion covers `sections:` as well as `chapters:` at any depth. - A new markdown file whose *source* fetch fails never reached the filter (it is in fetchErrors, not filesToSync). fetchAllFileContents now probes the target on that path — 404 means nothing will be delivered under the name, any other answer keeps the entry — and passes the list into processFiles so those entries leave the TOC too. - The PR-body notice says what actually happened: names the TOC(s) the entries were removed from, or states that no TOC was in the changeset and a pre-existing target entry may still dangle. The unconditional "failure issue has been filed" is reworded; result.filteredTocPaths carries the distinction. - js-yaml import moved beside the other local imports so the bundle diff is the change itself (+207/-9) rather than an esbuild module reshuffle. - Tests: byte-identity on a QuantEcon-style fixture with comments, quoting and trailing whitespace; title/sections removal; nested sections; url/glob siblings; the fallback path; unparseable input; fetch-failed inputs; no-TOC-in-changeset; both PR-body wordings. Duplicate empty-set test removed. CHANGELOG and FAQ entries added. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Thanks @kp992 — the mechanism here is right and this closes the #156 field case: the new-vs-existing distinction is derived correctly ( What the review found
Confirmed correct and left as-is: the stem mapping for flat, parts and subdirectory TOC layouts; the What changed in
|
…only target fetch (QuantEcon#254) Review follow-up on the _toc.yml caption preservation: - Matching by identical file set lost the caption of exactly the part a lecture-adding sync touches (measured on the real python/zh-cn pair: append one lecture to the first part and 基础工具 reverted to English). Parts are now paired by largest shared membership, each target part used once, ties to the nearest position. A part with no shared files keeps the source caption and is named in a warning; a matched part whose caption is already byte-identical to the source is logged as not localised. No positional guessing. - The merge no longer round-trips through yaml.dump (201 of 204 lines changed on lecture-python's TOC, comments dropped, re-dumped even when nothing was preserved). Caption values are substituted into the source text and the result is verified by parse against the intended document; noArrayIndent re-serialisation is the fallback only. - The rebase replay's `type: 'toc'` site in index.ts now fetches targetContent too, so a rebase no longer re-copies English captions. - Both target-TOC fetches swallow only a 404; any other status fails the fetch instead of silently dropping the captions on a transient error. - Code moved to src/toc-captions.ts (new module, new test file) so this PR and QuantEcon#289 — which inserts at the same point in sync-orchestrator.ts and adds the same js-yaml import — merge cleanly in either order. - Tests: byte-identity on a QuantEcon-style fixture with a comment, quoted caption and trailing whitespace; gain/lose/reorder a lecture; parts moved; new part; no-overlap part not guessed; split part; target-only parts; never-localised no-op by reference; no parts; malformed target; quoting; commented-out caption line; the block-scalar fallback; matcher unit tests. Orchestrator test asserts bytes. CHANGELOG, FAQ and architecture map updated. Merged current main. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
When a sync run fails to translate a new lecture, the
_toc.ymlwas committed with an entry for the absent file, producing a dangling reference that broke the target build and corrupted cross-references in every sibling lecture.Changes:
sync-orchestrator.ts(filtering logic + exportedremoveTocFileEntries),pr-creator.ts(PR body notice),index.ts(thread new field through). New unit tests cover flat/parts TOC layouts, the existing-file exemption, and the PR body section.Fixes #156