From e895d64c9e6c1ae163194c443f00e1665ae5439d Mon Sep 17 00:00:00 2001 From: Giorgi Cheishvili Date: Sun, 26 Nov 2023 18:03:43 +0400 Subject: [PATCH] feat: get-doc now uses prettier for writing files in ng-api-docs --- apps/ngx-bootstrap-docs/src/ng-api-doc.ts | 10 +++++----- scripts/docs/get-doc.js | 24 +++++++++++++++++------ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/apps/ngx-bootstrap-docs/src/ng-api-doc.ts b/apps/ngx-bootstrap-docs/src/ng-api-doc.ts index 9ab266537c..507066b4ad 100644 --- a/apps/ngx-bootstrap-docs/src/ng-api-doc.ts +++ b/apps/ngx-bootstrap-docs/src/ng-api-doc.ts @@ -2197,7 +2197,7 @@ export const ngdoc: any = { }, { name: 'matches', - type: 'TypeaheadMatch[]', + type: 'TypeaheadMatch[]', description: '

All matches

\n' }, { @@ -2226,7 +2226,7 @@ export const ngdoc: any = { }, { name: 'match', - type: 'TypeaheadMatch', + type: 'TypeaheadMatch', description: '

Typeahead match

\n' }, { @@ -2247,7 +2247,7 @@ export const ngdoc: any = { args: [ { name: 'value', - type: 'TypeaheadMatch' + type: 'TypeaheadMatch' }, { name: 'e', @@ -2262,7 +2262,7 @@ export const ngdoc: any = { args: [ { name: 'value', - type: 'TypeaheadMatch' + type: 'TypeaheadMatch' } ], returnType: 'void' @@ -2273,7 +2273,7 @@ export const ngdoc: any = { args: [ { name: 'value', - type: 'TypeaheadMatch' + type: 'TypeaheadMatch' } ], returnType: 'boolean' diff --git a/scripts/docs/get-doc.js b/scripts/docs/get-doc.js index 191b271c11..060c86028e 100644 --- a/scripts/docs/get-doc.js +++ b/scripts/docs/get-doc.js @@ -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', { @@ -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();