(source: string, format: SourceFormat = "jsdoc")
| 81 | * @since 4.0.0 |
| 82 | */ |
| 83 | export const extract = (source: string, format: SourceFormat = "jsdoc"): ReadonlyArray<Snippet> => { |
| 84 | if (!source.includes(runnableMarker)) { |
| 85 | return [] |
| 86 | } |
| 87 | |
| 88 | const lineAt = lineNumberAt(source) |
| 89 | return format === "markdown" |
| 90 | ? snippets(source, 0, lineAt) |
| 91 | : Array.from(source.matchAll(jsdocPattern)).flatMap((match) => snippets(match[0], match.index ?? 0, lineAt, true)) |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Reads a file and extracts its marked code snippets. |
no test coverage detected