Repository navigation
feat(content-reuse): wire ::include snippet pre-fetch + dependency manifest (content-reuse Task 6/8) - #3035
Merged
Conversation
…h, disk cache, SNIPPETS_ENABLED_REPOS gate
… snippetKey→slug map
…sk 3) Adds rewriteSnippetImages() to include.ts which rewrites relative image paths inside snippet markdown to absolute GitHub raw URLs pointing to the snippet's own repo/branch, not the including tutorial's. - shared/<name> snippets → tutorial-snippets/main - <repo>/_snippets/<name> snippets → <repo>/main - Absolute URLs and parent-relative (../) paths are left untouched - snippetRepoMap in ExpandDirectivesContext allows explicit override
…pipeline - Imports fetchSnippets from github.ts in fetch-tutorials.ts - Adds snippet pre-fetch block after help-titles (gated by SNIPPETS_ENABLED_REPOS) - Passes real snippetMap to every composeTutorial() call (replaces new Map() stub) - buildSnippetDeps now receives real snippetMap + disk-cached rawMd per slug - Removes TODO comments for Task 6/8; all fetch-tutorials.ts stubs are now wired - Adds backward-compat integration test (empty snippetMap = byte-identical runs)
…th include source context When expandDirectives() throws inside a snippet's content, the error message is now augmented with: "<original message> (included from <tutorialSlug>:<line> via <snippetKey>)" Avoids double-wrapping when the message already contains "included from". Also adds gate regression tests confirming: - empty snippetMap → directive/include-not-found (behavior unchanged for non-opted-in repos) - tutorials with no ::include are unaffected (no error, identical output)
… undefined local var The token variable in main() scope was undefined at runtime (it's only defined inside fetchMarkdown()). fetchSnippets() uses the token for GitHub auth headers, so passing undefined would skip auth and fail on private repos' _snippets/ dirs. Use process.env.GITHUB_TOKEN ?? process.env.TUTORIALS_GITHUB_TOKEN directly at the call site (stored as snippetToken) to avoid the scope issue.
…ude regex Three bugs found in code review: 1. CRITICAL: fetchSnippets() stored shared snippets as 'shared/cf-cli.md' but resolveSnippetKey() normalizes ::include[shared:cf-cli] to 'shared/cf-cli' (no extension). Every shared snippet include threw directive/include-not-found. Fix: strip .md from the key when building shared/ keys. Per-repo keys keep .md since ::include[step.md] labels include the extension and suffix-match works. 2. MEDIUM: Same mismatch caused buildSnippetDeps to emit 'shared/cf-cli' keys while the rebuild workflow would compare against 'tutorial-snippets/...cf-cli.md' paths — shared-snippet changes never triggered targeted rebuilds. Fix: same as above (key consistency). 3. LOW: INCLUDE_RE in buildSnippetDeps used /:?:include/ matching one-colon :include[x] (not valid directive syntax) and producing false-positive dep entries. Fix: /::include/ (require two colons, matching actual leaf directive syntax). Also updates tests: - github-snippets.test.ts: assert 'shared/cf-cli' (not 'shared/cf-cli.md') - github-snippet-deps.test.ts: add comment clarifying key convention; add test confirming :include (single colon) is not matched - include-images.test.ts: shared snippet test uses 'shared/setup' key + label (no .md extension), matching the actual fetchSnippets output convention
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What / Why
Finishes the `::include[snippet]` pre-fetch pipeline that was merged as a stub in the content-reuse feature branch. The directive grammar, expand hook, and directive context were already shipped; this PR wires the actual GitHub fetch, disk cache, and dep-manifest steps.
Before this PR: `snippetMap: new Map()` was always passed to `composeTutorial`, so `::include` directives in tutorial source always threw `directive/include-not-found`. The snippet-deps manifest (`GET /content/manifest/snippet-deps`) always returned `{}`.
After this PR:
5-Part Status
How Tested
Deploy Scope
Backend only (fetch pipeline / build scripts). No CAP service changes, no HANA schema changes, no MTA changes, no approuter changes.
Activates previously-stubbed `::include` and unblocks the `meta-tutorials` directive-content-reuse sample tutorial.
To activate snippet fetching in a build: set `SNIPPETS_ENABLED_REPOS=` in the build environment (CI or local `.env`). Default is empty (off). The shared `tutorial-snippets` repo is always included when any repos are opted in.