MCPcopy Index your code
hub / github.com/pingcap/docs-cn / expectedSetForTarget

Function expectedSetForTarget

scripts/verify-internal-links-in-toc.js:122–152  ·  view source on GitHub ↗
(targetRel, tocToPages, anyTocPages, cloudTocPages)

Source from the content-addressed store, hash-verified

120}
121
122function expectedSetForTarget(targetRel, tocToPages, anyTocPages, cloudTocPages) {
123 if (
124 targetRel === "_index.md" ||
125 targetRel.endsWith("/_index.md") ||
126 targetRel === "_docHome.md" ||
127 targetRel.endsWith("/_docHome.md")
128 ) {
129 return { ok: true };
130 }
131
132 if (
133 targetRel.startsWith("tidb-cloud/") &&
134 !targetRel.startsWith("tidb-cloud/releases/")
135 ) {
136 return {
137 ok: cloudTocPages.has(targetRel),
138 expectedLabel: "any TiDB Cloud TOC",
139 };
140 }
141
142 const matchedPrefix = PREFIX_TO_TOC.find(({ prefix }) =>
143 targetRel.startsWith(prefix)
144 );
145 if (matchedPrefix) {
146 const set = tocToPages.get(matchedPrefix.toc) || new Set();
147 return { ok: set.has(targetRel), expectedLabel: matchedPrefix.toc };
148 }
149
150 // Default: the target appears in any TOC*.md
151 return { ok: anyTocPages.has(targetRel), expectedLabel: "any TOC*.md" };
152}
153
154function main() {
155 process.chdir(ROOT);

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected