The first line of a docstring right after line `after`, as it is written (one or two lines).
(lines: readonly string[], after: number, indent: string)
| 55 | |
| 56 | /** The first line of a docstring right after line `after`, as it is written (one or two lines). */ |
| 57 | function docstring(lines: readonly string[], after: number, indent: string): string[] { |
| 58 | const at = lines.findIndex((line, index) => index > after && line.trim()); |
| 59 | const first = at >= 0 ? lines[at].trim() : ''; |
| 60 | if (!/^[rubRUB]{0,2}("""|''')/.test(first)) return []; |
| 61 | const bare = /^[rubRUB]{0,2}("""|''')$/.test(first); |
| 62 | const next = bare ? lines.slice(at + 1).find(line => line.trim())?.trim() : undefined; |
| 63 | return bare && next ? [`${indent}${first}`, `${indent}${bounded(next)}`] : [`${indent}${bounded(first)}`]; |
| 64 | } |
| 65 | |
| 66 | /** Where a docstring after line `after` ends, or `after` without one. */ |
| 67 | function docstringEnd(lines: readonly string[], after: number): number { |
no test coverage detected