Skip to content

Commit

Permalink
feat: get-doc now uses prettier for writing files in ng-api-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
g-cheishvili committed Nov 26, 2023
1 parent 867bb20 commit e895d64
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
10 changes: 5 additions & 5 deletions apps/ngx-bootstrap-docs/src/ng-api-doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2197,7 +2197,7 @@ export const ngdoc: any = {
},
{
name: 'matches',
type: 'TypeaheadMatch[]',
type: 'TypeaheadMatch<any>[]',
description: '<p>All matches</p>\n'
},
{
Expand Down Expand Up @@ -2226,7 +2226,7 @@ export const ngdoc: any = {
},
{
name: 'match',
type: 'TypeaheadMatch',
type: 'TypeaheadMatch<any>',
description: '<p>Typeahead match</p>\n'
},
{
Expand All @@ -2247,7 +2247,7 @@ export const ngdoc: any = {
args: [
{
name: 'value',
type: 'TypeaheadMatch'
type: 'TypeaheadMatch<any>'
},
{
name: 'e',
Expand All @@ -2262,7 +2262,7 @@ export const ngdoc: any = {
args: [
{
name: 'value',
type: 'TypeaheadMatch'
type: 'TypeaheadMatch<any>'
}
],
returnType: 'void'
Expand All @@ -2273,7 +2273,7 @@ export const ngdoc: any = {
args: [
{
name: 'value',
type: 'TypeaheadMatch'
type: 'TypeaheadMatch<any>'
}
],
returnType: 'boolean'
Expand Down
24 changes: 18 additions & 6 deletions scripts/docs/get-doc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// All rights reserved by ng-bootstrap team, read licence file
// todo: add ng-bootstrap copyrights
const fs = require('fs');
const {writeFileSync} = require('fs');
const glob = require('glob');
const doc = require('./api-doc');
const {format, resolveConfig} = require('prettier');

function getFileNames() {
return glob.sync('src/**/*.ts', {
Expand All @@ -15,9 +16,20 @@ function getApiDocs() {
}

module.exports = getApiDocs;
const json = JSON.stringify(getApiDocs(), null, 2);
fs.writeFileSync('apps/ngx-bootstrap-docs/src/ng-api-doc.ts',
`/* tslint:disable */
export const ngdoc: any = ${json};
`);

async function run() {
const json = JSON.stringify(getApiDocs(), null, 2);
const outputFile = 'apps/ngx-bootstrap-docs/src/ng-api-doc.ts';
const prettierConfig = await resolveConfig(outputFile, { editorConfig: true });
writeFileSync(
outputFile,
await format(
`/* tslint:disable */
export const ngdoc: any = ${json};
`,
prettierConfig
)
);
}

run();

0 comments on commit e895d64

Please sign in to comment.