(dir: string, ref: string, section: string)
| 62 | } |
| 63 | |
| 64 | async function resolveComment(dir: string, ref: string, section: string): Promise<string[]> { |
| 65 | const fileReadme = join(dir, ref); |
| 66 | const lines = await readFileSection(fileReadme, section); |
| 67 | let row = 0; |
| 68 | let output: string[] = []; |
| 69 | const dirReadme = dirname(fileReadme); |
| 70 | while (row < lines.length) { |
| 71 | let line = lines[row++]; |
| 72 | const match = /<docs code="\.\/(.*)#(.*)"\/>/.exec(line); |
| 73 | if (match) { |
| 74 | output.push('```tsx'); |
| 75 | (await resolveCodeExample(join(dirReadme, match[1]), match[2])).forEach((l) => |
| 76 | output.push(l) |
| 77 | ); |
| 78 | output.push('```'); |
| 79 | } else { |
| 80 | output.push(line); |
| 81 | } |
| 82 | } |
| 83 | return output; |
| 84 | } |
| 85 | |
| 86 | async function readFileSection(file: string, section: string) { |
| 87 | const lines = await readLines(file); |
no test coverage detected
searching dependent graphs…