MCPcopy
hub / github.com/pingcap/docs-cn / buildTocIndex

Function buildTocIndex

scripts/verify-internal-links-in-toc.js:94–120  ·  view source on GitHub ↗
(tocFiles)

Source from the content-addressed store, hash-verified

92}
93
94function buildTocIndex(tocFiles) {
95 const tocToPages = new Map(); // tocFile -> Set(relPathWithoutLeadingSlash)
96 const anyTocPages = new Set();
97 const pageToTocs = new Map(); // pageRel -> Set(tocFile)
98
99 tocFiles.forEach((toc) => {
100 const tocAbs = path.join(ROOT, toc);
101 const pages = new Set();
102
103 extractInternalDocTargetsFromMarkdownFile(tocAbs).forEach((rel) => {
104 pages.add(rel);
105 anyTocPages.add(rel);
106
107 const tocs = pageToTocs.get(rel) || new Set();
108 tocs.add(toc);
109 pageToTocs.set(rel, tocs);
110 });
111
112 tocToPages.set(toc, pages);
113 });
114
115 const cloudTocPages = new Set(
116 CLOUD_TOC_FILES.flatMap((toc) => [...(tocToPages.get(toc) || new Set())])
117 );
118
119 return { tocToPages, anyTocPages, pageToTocs, cloudTocPages };
120}
121
122function expectedSetForTarget(targetRel, tocToPages, anyTocPages, cloudTocPages) {
123 if (

Callers 1

mainFunction · 0.85

Tested by

no test coverage detected