docs: support cross-repo README substitution for aweXpect Migration page#29
Merged
Conversation
Add ExtraReadmes config on DocsSource so a slice can pull a foreign repo's README and substitute it into a named target file. New StripReadmeFront helper handles READMEs without ## headings (drops H1, consecutive badge lines, and surrounding blanks). The aweXpect slice now pulls aweXpect.Migration's README and inlines it into 09-migration.md, giving the rendered Migration page a single source of truth.
There was a problem hiding this comment.
Pull request overview
This PR extends the docs aggregation pipeline so a docs slice can substitute README content from a different repository into one of its generated pages. In practice, it uses that new mechanism to make the aweXpect Migration page pull its body from the aweXpect.Migration repository, keeping that content as the single source of truth.
Changes:
- Adds
ExtraReadmes/ReadmeSubstitutionsupport toDocsSourcefor cross-repo README injection. - Implements
FetchReadmeBodyandStripReadmeFrontto fetch a foreignREADME.mdand remove its leading title/badge section. - Configures the aweXpect slice to inline
aweXpect.Migration's README into09-migration.md.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+128
to
+150
| Func<string, string, string>? transformer = (source.InlineReadme || extraReadmes.Count > 0) | ||
| ? (name, content) => | ||
| { | ||
| if (name.StartsWith("00-", StringComparison.Ordinal) && | ||
| if (source.InlineReadme && | ||
| name.StartsWith("00-", StringComparison.Ordinal) && | ||
| content.Contains("{README}", StringComparison.Ordinal)) | ||
| { | ||
| string substitution = readmeContent.Replace("Docs/pages/", "./", StringComparison.Ordinal); | ||
| content = content.Replace("{README}", substitution, StringComparison.Ordinal); | ||
| readmeContent = string.Empty; // substitute into the first match only | ||
| Log.Information($" Inlined README.md into {name}"); | ||
| } | ||
| for (int i = 0; i < extraReadmes.Count; i++) | ||
| { | ||
| (ReadmeSubstitution cfg, string body) = extraReadmes[i]; | ||
| if (string.IsNullOrEmpty(body)) | ||
| { | ||
| continue; | ||
| } | ||
| if (string.Equals(name, cfg.TargetFileName, StringComparison.Ordinal) && | ||
| content.Contains(cfg.Placeholder, StringComparison.Ordinal)) | ||
| { | ||
| content = content.Replace(cfg.Placeholder, body, StringComparison.Ordinal); |
Comment on lines
+143
to
+146
| if (string.IsNullOrEmpty(body)) | ||
| { | ||
| continue; | ||
| } |
Comment on lines
+52
to
+56
| record ReadmeSubstitution( | ||
| string Organization, | ||
| string Repository, | ||
| string TargetFileName, | ||
| string Placeholder = "{README}"); |
Comment on lines
+118
to
+125
| List<(ReadmeSubstitution Config, string Body)> extraReadmes = new(); | ||
| if (source.ExtraReadmes != null) | ||
| { | ||
| foreach (ReadmeSubstitution sub in source.ExtraReadmes) | ||
| { | ||
| string body = await FetchReadmeBody(client, sub.Organization, sub.Repository); | ||
| extraReadmes.Add((sub, body)); | ||
| } |
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.
Add ExtraReadmes config on DocsSource so a slice can pull a foreign repo's README and substitute it into a named target file. New StripReadmeFront helper handles READMEs without ## headings (drops H1, consecutive badge lines, and surrounding blanks).
The aweXpect slice now pulls aweXpect.Migration's README and inlines it into 09-migration.md, giving the rendered Migration page a single source of truth.