-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocument.mjs
49 lines (46 loc) · 1.23 KB
/
document.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import * as fs from "fs";
import { sep, resolve } from "path";
import {
parseExportedFunctionsAsync,
renderFunctionDataToMarkdown
} from "generate-ts-docs";
import { exec } from "child_process";
const __dirname = resolve();
// function generateMarkdown(filters, apiName) {
// const markdown = jsdocToMd(`${__dirname}/../lib`, {
// filter: (filename) => {
// console.log('FILTER', filename)
// if (lodash.some(filters, (suffix) => filename.endsWith(suffix))) {
// console.log(`File "${filename}" parsing...`) // eslint-disable-line no-console
// return true
// }
// return false
// },
// })
//
// fs.writeFileSync(`${__dirname}/../docs/api/${apiName}.md`, `${markdown}`)
// }
async function generateMarkdown(files, apiName) {
files = files.map(
item => {
return `${__dirname}/src${item}`;
}
);
await exec(
`rm -ls ${__dirname}/docs/api/*.md | grep -v ${__dirname}/docs/api/README.txt`);
await
fs.writeFileSync(`${__dirname}/docs/api/${apiName}.md`, `${markdown}`);
}
const APIs = [
{
name: "Index",
files: [`${sep}index.ts`]
},
{
name: "Provider",
files: [`${sep}provider.ts`]
}
];
for (const API of APIs) {
generateMarkdown(API.files, API.name);
}