Skip to content

Commit

Permalink
chore: update dts-buddy and doc generate (#181)
Browse files Browse the repository at this point in the history
* chore: update dts-buddy and doc generate

* chore: update dts-buddy again

* chore: regenerate docs
  • Loading branch information
dominikg authored Jul 11, 2024
1 parent e3a4df8 commit 87e69fa
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 22 deletions.
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

0 comments on commit 87e69fa

Please sign in to comment.