-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tsdocs): add integration with api-extractor/documenter
- Loading branch information
1 parent
d4116cf
commit 36f4d15
Showing
45 changed files
with
1,470 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Copyright (c) IBM Corp. 2019. All Rights Reserved. | ||
Node module: @loopback/tsdocs | ||
This project is licensed under the MIT License, full text below. | ||
|
||
-------- | ||
|
||
MIT license | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# @loopback/tsdocs | ||
|
||
This module provides [API docs](https://github.com/Microsoft/tsdoc) generation | ||
for `@loopback/*` packages. | ||
|
||
It's built on top of https://api-extractor.com/: | ||
|
||
- https://github.com/Microsoft/web-build-tools/tree/master/apps/api-extractor | ||
- https://github.com/Microsoft/web-build-tools/tree/master/apps/api-documenter | ||
|
||
## Basic Use | ||
|
||
### Build api reports and doc models | ||
|
||
```sh | ||
npm run extract-apidocs -- --report | ||
``` | ||
|
||
The command above will traverse all TypeScript packages in the monorepo and run | ||
`api-extractor` to generate api reports and doc models into | ||
`loopback-next/docs/apidocs`: | ||
|
||
- `reports`: api reports | ||
- `reports-temp`: temporary api reports | ||
- `models`: doc models | ||
|
||
### Generate api docs as markdown files | ||
|
||
```sh | ||
npm run document-apidocs | ||
``` | ||
|
||
It runs `api-documenter` to generate markdown files into | ||
`loopback-next/docs/site/apidocs`. | ||
|
||
### Update api docs for Jekyll site | ||
|
||
```sh | ||
npm run update-apidocs | ||
``` | ||
|
||
It adds Jekyll metadata to markdown files in `loopback-next/docs/site/apidocs` | ||
and generates `loopback-next/docs/site/apidocs/index.md` as the index page. | ||
|
||
To run all steps together: | ||
|
||
```sh | ||
npm run build:apidocs | ||
``` | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install --save @loopback/tsdocs | ||
``` | ||
|
||
## Contributions | ||
|
||
- [Guidelines](https://github.com/strongloop/loopback-next/blob/master/docs/CONTRIBUTING.md) | ||
- [Join the team](https://github.com/strongloop/loopback-next/issues/110) | ||
|
||
## Tests | ||
|
||
Run `npm test` from the root folder. | ||
|
||
## Contributors | ||
|
||
See | ||
[all contributors](https://github.com/strongloop/loopback-next/graphs/contributors). | ||
|
||
## License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env node | ||
// Copyright IBM Corp. 2019. All Rights Reserved. | ||
// Node module: @loopback/tsdocs | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
/** | ||
* Run api-extractor against the monorepo | ||
*/ | ||
const runExtractorForMonorepo = require('..').runExtractorForMonorepo; | ||
|
||
const silent = process.argv.includes('--silent'); | ||
const dryRun = process.argv.includes('--dry-run'); | ||
|
||
/** | ||
* The option to control if reports are generated by api-extractor | ||
*/ | ||
const apiReportEnabled = process.argv.includes('--report'); | ||
|
||
async function main() { | ||
await runExtractorForMonorepo({silent, dryRun, apiReportEnabled}); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env node | ||
// Copyright IBM Corp. 2019. All Rights Reserved. | ||
// Node module: @loopback/tsdocs | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
/** | ||
* Update generated api md files with Jekyll macros and create index page | ||
*/ | ||
const updateApiDocs = require('..').updateApiDocs; | ||
const silent = process.argv.includes('--silent'); | ||
const dryRun = process.argv.includes('--dry-run'); | ||
|
||
async function main() { | ||
await updateApiDocs({silent, dryRun}); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# fixtures/monorepo | ||
|
||
This `monorepo` directory contains a simplified monorepo managed by lerna. It's | ||
used to mimic `loopback-next` to test `@loopback/tsdocs`. | ||
|
||
# Rebuild | ||
|
||
If you have to change the source code for the fixture, run the following command | ||
to rebuild. | ||
|
||
```sh | ||
npm run build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"lerna": "3.3.0", | ||
"packages": [ | ||
"packages/*", | ||
"docs" | ||
], | ||
"version": "independent", | ||
"command": { | ||
"run": { | ||
"prefix": false, | ||
"loglevel": "silent", | ||
"stream": true, | ||
"concurrency": 8, | ||
"sort": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "root", | ||
"version": "1.0.0", | ||
"description": "Root", | ||
"scripts": { | ||
"clean": "../../../../node_modules/.bin/lerna run clean", | ||
"bootstrap": "../../../../node_modules/.bin/lerna bootstrap", | ||
"build": "npm -s run bootstrap && npm -s run clean && ../../../../node_modules/.bin/lerna run build" | ||
}, | ||
"author": "", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@loopback/build": "file:../../../build" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/tsdocs/fixtures/monorepo/packages/pkg1/dist/index.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Base class for pets | ||
*/ | ||
export declare class Pet { | ||
readonly name: string; | ||
readonly kind: string; | ||
/** | ||
* Create a pet | ||
* @param name - Name of the pet | ||
* @param kind - Kind of the pet | ||
*/ | ||
constructor(name: string, kind: string); | ||
/** | ||
* Greet the pet | ||
* @param msg - Message for the greeting | ||
* @returns The description | ||
*/ | ||
greet(msg: string): string; | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/tsdocs/fixtures/monorepo/packages/pkg1/dist/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
packages/tsdocs/fixtures/monorepo/packages/pkg1/dist/index.js.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
packages/tsdocs/fixtures/monorepo/packages/pkg1/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "pkg1", | ||
"version": "1.0.0", | ||
"description": "Test package 1", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "lb-tsc es2017 --outDir dist", | ||
"clean": "lb-clean dist" | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/tsdocs/fixtures/monorepo/packages/pkg1/src/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright IBM Corp. 2019. All Rights Reserved. | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
/** | ||
* Base class for pets | ||
*/ | ||
export class Pet { | ||
/** | ||
* Create a pet | ||
* @param name - Name of the pet | ||
* @param kind - Kind of the pet | ||
*/ | ||
constructor(public readonly name: string, public readonly kind: string) {} | ||
|
||
/** | ||
* Greet the pet | ||
* @param msg - Message for the greeting | ||
* @returns The description | ||
*/ | ||
greet(msg: string) { | ||
return `[${msg}] ${this.name}:${this.kind}`; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/tsdocs/fixtures/monorepo/packages/pkg1/tsconfig.build.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/tsconfig", | ||
"extends": "@loopback/build/config/tsconfig.common.json", | ||
"compilerOptions": { | ||
"rootDir": "src" | ||
}, | ||
"include": ["src"] | ||
} |
Oops, something went wrong.