Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update dts-buddy and doc generate #181

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@changesets/cli": "^2.27.5",
"@eslint/js": "^9.4.0",
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
"dts-buddy": "^0.4.7",
"dts-buddy": "^0.5.1",
"esbuild": "^0.21.5",
"eslint": "^9.4.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/tsconfck/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ declare module 'tsconfck' {
*/
result: any;
}

export {};
}

//# sourceMappingURL=index.d.ts.map
3 changes: 2 additions & 1 deletion packages/tsconfck/types/index.d.ts.map
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
null,
null
],
"mappings": ";;;;;;;;iBAUsBA,IAAIA;;;;;;;;iBCYJC,OAAOA;;;;;;;iBCTbC,MAAMA;;;;;;;;;;iBCDAC,UAAUA;cCXnBC,aAAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBC2BJC,KAAKA;cA6VdC,kBAAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBC7VTC,WAAWA;cAkOpBC,wBAAwBA;;;;;;;;;;;;;;;;;;;;;;;;;WC5PpBC,mBAAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAkCnBC,oBAAoBA;;;;WAIpBC,sBAAsBA;;;;;;;;;;;;;;;WAetBC,mBAAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA6BnBC,0BAA0BA;;;;;;;;;;;;WAY1BC,yBAAyBA"
"mappings": ";;;;;;;;iBAUsBA,IAAIA;;;;;;;;iBCYJC,OAAOA;;;;;;;iBCTbC,MAAMA;;;;;;;;;;iBCDAC,UAAUA;cCXnBC,aAAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBC2BJC,KAAKA;cA6VdC,kBAAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBC7VTC,WAAWA;cAkOpBC,wBAAwBA;;;;;;;;;;;;;;;;;;;;;;;;;WC5PpBC,mBAAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAkCnBC,oBAAoBA;;;;WAIpBC,sBAAsBA;;;;;;;;;;;;;;;WAetBC,mBAAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA6BnBC,0BAA0BA;;;;;;;;;;;;WAY1BC,yBAAyBA",
"ignoreList": []
}
59 changes: 41 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions scripts/generate-api-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,21 @@ import fs from 'fs';
const header = '<!-- generated, do not modify -->\n## API \n\n';

function parseBlock(block) {
const m = block.match(/(function|class|interface|type) ([a-zA-Z]+)/);
if (!m) {
return {
kind: 'ignored',
md: ''
};
}
// eslint-disable-next-line no-unused-vars
const [_, kind, title] = block.match(/(function|class|interface|type) ([a-zA-Z]+)/);
const [_, kind, title] = m;
if (title === 'TSDiagnosticError') {
return {
kind: 'ignored',
md: ''
};
}
const heading = '#'.repeat(blockHeadings[title] || 3);
return {
kind,
Expand All @@ -25,8 +38,10 @@ const blockSeparator = '\n-- cut here --\n';
let dts = fs
.readFileSync(typesFile, 'utf-8')
.replace("declare module 'tsconfck' {\n", '')
.replace(/export \{[^}]+}/, '')
.replace('}\n\n//# sourceMappingURL=index.d.ts.map', '')
.replace(/^\s+export function [a-zA-Z]+\(.*$/gm, `$&${blockSeparator}`)
.replace(/^\s*(?:export )?function [a-zA-Z]+\(.*$/gm, `$&${blockSeparator}`)
.replace(/^\s*(?:export )?interface [a-zA-Z]+\s*\{.*$/gm, `${blockSeparator}$&`)
.replace(/^\s*}\s*$/gm, `$&${blockSeparator}`)
.replace(/^\t/gm, '');

Expand Down Expand Up @@ -70,6 +85,7 @@ const md =
header +
blocks
.map((block) => parseBlock(block))
.filter((b) => b.md.length > 0)
.sort(sortBlocks)
.map((b) => b.md)
.join('\n\n') +
Expand Down