MCPcopy Create free account
hub / github.com/denoland/std / assertHasSnippets

Function assertHasSnippets

_tools/check_docs.ts:141–164  ·  view source on GitHub ↗
(
  doc: string,
  document: { jsDoc: JsDoc; location: Location },
)

Source from the content-addressed store, hash-verified

139}
140
141function assertHasSnippets(
142 doc: string,
143 document: { jsDoc: JsDoc; location: Location },
144) {
145 const snippets = doc.match(TS_SNIPPET_REGEXP);
146 assert(
147 snippets !== null,
148 "@example tag must have a TypeScript code snippet",
149 document,
150 );
151 if (snippets === null) return;
152 for (let snippet of snippets) {
153 const delim = snippet.split(NEWLINE)[0];
154 // Trim the code block delimiters
155 snippet = snippet.split(NEWLINE).slice(1, -1).join(NEWLINE);
156 if (!(delim?.includes("no-assert") || delim?.includes("ignore"))) {
157 assert(
158 snippet.match(ASSERTION_IMPORT_REGEXP) !== null,
159 "Snippet must contain assertion from `@std/assert`, `@std/expect` or `@std/testing`",
160 document,
161 );
162 }
163 }
164}
165
166function assertHasExampleTag(
167 document: { jsDoc: JsDoc; location: Location },

Callers 2

assertHasExampleTagFunction · 0.85
assertModuleDocFunction · 0.85

Calls 4

matchMethod · 0.80
includesMethod · 0.80
assertFunction · 0.70
sliceMethod · 0.45

Tested by

no test coverage detected