@giupaprusso/json
v0.3.3
Published
Parse exported declarations from typescript files into json object, for documentation.
Maintainers
Readme
@giupaprusso/json
Parse exported declarations from typescript files into json object, for documentation.
Installation
As dependency:
npm install @giupaprusso/jsonAs devDependency:
npm install @giupaprusso/json --save-devUsage
const { giupaprusso } = require('@giupaprusso/json');
const doc = giupaprusso(['path/to/file.ts']);API
giupaprusso(filesPath: string[], options?: ts.CompilerOptions): Declaration[]options is optional, and will be passed to typescript compiler. See typescript docs for more details.
Examples
// Movie.ts
/**
* Interface description
*/
export interface Movie {
/**
* Property description
*/
title: string;
year: number;
actors: string[];
}Will be parsed into:
{
Movie: {
name: 'Movie',
kind: 'interface',
description: 'Interface description',
props: [
{
name: 'title',
kind: 'prop',
type: 'string',
description: 'Property description'
},
{
name: 'year',
kind: 'prop',
type: 'number',
description: ''
},
{
name: 'actors',
kind: 'prop',
type: 'string[]',
description: ''
}
]
}
};More examples can be found in examples.
Supported declarations
| Declaration | Supported |
| ----------- | --------- |
| variable | ✅ |
| interface | ✅ |
| function | ❌ |
| type | ❌ |
| enum | ❌ |
| class | ❌ |
| namespace | ❌ |
License
Distributed under the MIT License. See LICENSE file for more information.
