Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 | 1 |
import * as fs from 'fs' |
2 | 1 |
import * as path from 'path' |
3 | 1 |
import parseVue from './parseVue' |
4 |
|
|
5 | 1 |
const readSeparateScriptFile = (fileName: string) => { |
6 |
return fs.readFileSync(fileName, { encoding: 'utf-8' }) |
|
7 |
}
|
|
8 |
|
|
9 | 1 |
export default function getComponentVueDoc(source: string, file: string): string | false { |
10 |
const parts = parseVue(source, file) |
|
11 |
|
|
12 |
if (parts.customBlocks) { |
|
13 |
const docBlocks = parts.customBlocks.filter(block => block.type === 'docs')[0] |
|
14 |
if (docBlocks && docBlocks.src) { |
|
15 |
const jsFilePath = path.join(path.dirname(file), docBlocks.src) |
|
16 |
return readSeparateScriptFile(jsFilePath) |
|
17 |
} else if (docBlocks && docBlocks.content) { |
|
18 |
return docBlocks.content |
|
19 |
}
|
|
20 |
}
|
|
21 |
return false |
|
22 |
}
|
Read our documentation on viewing source code .