MCPcopy
hub / github.com/github/docs / renderPatchNotes

Function renderPatchNotes

lib/release-notes-utils.js:45–84  ·  view source on GitHub ↗
(patches, ctx)

Source from the content-addressed store, hash-verified

43 * Returns [{version, patchVersion, intro, date, sections: { features: [], bugs: []...}}]
44 */
45export async function renderPatchNotes(patches, ctx) {
46 return await Promise.all(
47 patches.map(async (patch) => {
48 // Clone the patch object but drop 'sections' so we can render them below without mutations
49 const { sections, ...renderedPatch } = patch
50 renderedPatch.intro = await renderContent(patch.intro, ctx)
51
52 // Now render the sections...
53 // E.g., sections: { features: [], bugs: []...}}
54 const renderedSections = Object.fromEntries(
55 await Promise.all(
56 Object.entries(patch.sections).map(async ([sectionType, sectionArray]) => {
57 // sectionType is things like 'features', 'bugs', etc.
58 // sectionArray is things like [ { heading, notes: [] } ]
59 const renderedSectionArray = await Promise.all(
60 sectionArray.map(async (note) => {
61 // where `note` may be a string or an object like { heading, notes: []}
62 if (typeof note === 'string') {
63 return renderContent(note, ctx)
64 } else {
65 const renderedNoteObj = {}
66 renderedNoteObj.heading = note.heading
67 renderedNoteObj.notes = await Promise.all(
68 note.notes.map(async (noteStr) => renderContent(noteStr, ctx))
69 )
70
71 return renderedNoteObj
72 }
73 })
74 )
75 return [sectionType, renderedSectionArray]
76 })
77 )
78 )
79
80 renderedPatch.sections = renderedSections
81 return renderedPatch
82 })
83 )
84}
85
86export default {
87 formatReleases,

Callers 2

ghesReleaseNotesContextFunction · 0.90
ghaeReleaseNotesContextFunction · 0.90

Calls 1

renderContentFunction · 0.85

Tested by

no test coverage detected