MCPcopy Index your code
hub / github.com/modelcontextprotocol/modelcontextprotocol / renderTemplate

Function renderTemplate

typedoc.plugin.mjs:98–126  ·  view source on GitHub ↗

* * @param {string} template * @param {typedoc.PageEvent[]} pageEvents * @param {typedoc.DefaultTheme} theme * @returns {string}

(template, pageEvents, theme)

Source from the content-addressed store, hash-verified

96 * @returns {string}
97 */
98function renderTemplate(template, pageEvents, theme) {
99 const reflectionEvents = pageEvents.filter(isDeclarationReflectionEvent);
100
101 /** @type {Set<string>} */
102 const renderedCategories = new Set();
103
104 const rendered = template.replaceAll(
105 /^\{\/\* @category (.+) \*\/\}$/mg,
106 (match, category) => {
107 renderedCategories.add(category);
108 return renderCategory(category, reflectionEvents, theme);
109 }
110 );
111
112 const missingCategories = reflectionEvents.
113 map((event) => getReflectionCategory(event.model)).
114 filter((category) => category && !renderedCategories.has(category)).
115 filter((category, i, array) => array.indexOf(category) === i). // Remove duplicates.
116 sort();
117
118 if (missingCategories.length > 0) {
119 throw new Error(
120 "The following categories are missing from the schema page template:\n\n" +
121 missingCategories.map((category) => `- ${category}\n`).join("")
122 );
123 }
124
125 return rendered;
126}
127
128/**
129 * @param {typedoc.PageEvent} event

Callers 1

loadFunction · 0.85

Calls 2

renderCategoryFunction · 0.85
getReflectionCategoryFunction · 0.85

Tested by

no test coverage detected