(
doc: string,
document: { jsDoc: JsDoc; location: Location },
)
| 139 | } |
| 140 | |
| 141 | function 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 | |
| 166 | function assertHasExampleTag( |
| 167 | document: { jsDoc: JsDoc; location: Location }, |
no test coverage detected