MCPcopy
hub / github.com/freshframework/fresh / assertHasSnippets

Function assertHasSnippets

tools/check_docs_lib.ts:131–153  ·  view source on GitHub ↗
(
  doc: string,
  document: { jsDoc: JsDoc; location: Location },
)

Source from the content-addressed store, hash-verified

129}
130
131function assertHasSnippets(
132 doc: string,
133 document: { jsDoc: JsDoc; location: Location },
134) {
135 const snippets = doc.match(TS_SNIPPET_REGEXP);
136 assert(
137 snippets !== null,
138 "@example tag must have a TypeScript code snippet",
139 document,
140 );
141 if (snippets === null) return;
142 for (let snippet of snippets) {
143 const delim = snippet.split(NEWLINE)[0];
144 snippet = snippet.split(NEWLINE).slice(1, -1).join(NEWLINE);
145 if (!(delim?.includes("no-assert") || delim?.includes("ignore"))) {
146 assert(
147 snippet.match(ASSERTION_IMPORT_REGEXP) !== null,
148 "Snippet must contain assertion from `@std/assert`, `@std/expect` or `@std/testing`",
149 document,
150 );
151 }
152 }
153}
154
155function assertHasExampleTag(
156 document: { jsDoc: JsDoc; location: Location },

Callers 2

assertHasExampleTagFunction · 0.85
assertModuleDocFunction · 0.85

Calls 2

assertFunction · 0.85
matchMethod · 0.65

Tested by

no test coverage detected