(
doc: string,
document: { jsDoc: JsDoc; location: Location },
)
| 129 | } |
| 130 | |
| 131 | function 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 | |
| 155 | function assertHasExampleTag( |
| 156 | document: { jsDoc: JsDoc; location: Location }, |
no test coverage detected