Is this a feature or a bug?
Please describe the actual behavior.
I'm looking for a way to generate documentation for a Typescript library/package which does not have a single input file.
Instead, the package contains of a set of modules where each module exports some classes, interfaces, ... . It is very similar to what Angular has, e.g. if you npm install @angular/router you receive 3 modules in the same npm package:
- The
@angular/router module
- The
@angular/router/upgrade module
- The
@angular/router/testing module
Judging by the documentation, this should be possible using api-extractor:
One significant limitation for .d.ts rollups is the assumption that your package has a single entry point. (If that’s not the case, you probably won’t be able to use this feature of API Extractor, although you can still use the API report and documentation generation features.)
I tried this, but could not get it to work. I have setup a test repository which you can use to reproduce my problem:
git clone https://github.com/PissedCapslock/tsdocexperiment.git
cd tsdocexperiment/
npm install
npm run-script apiextractor
npx api-documenter --input-folder temp --output-folder docs
which results in
Reading firstmodule.api.json
Reading secondmodule.api.json
Error: Another member has already been added with the same name and containerKey
What I do in this repository is the following:
- The
src folder contains a mix of .d.ts files and .ts files. This is probably irrelevant, but mainly done to mimic our current situation where we are migrating a .js codebase Typescript, and have manually created definition files for unported JS code
- The
tsc compiler compiles the src folder, and stores the output in the lib folder.
- I copy the
d.ts files from the src folder into the lib folder as well. That way, the lib folder contains all d.ts files
- I run the API extractor on all the
d.ts files in the lib folder by generating an api-extractor.json file where the entrypoint points to that specific d.ts file, and store that output into the temp folder
This approach results in .api.json files where the module information is gone. I only see the package name. So of course, running api-documenter on it does not work.
Is multiple entry points simply not supported (despite what is mentioned in the documentation), or am I doing something wrong ?
Looking at the documentation of the APIPackage class which has a ReadonlyArray<ApiEntryPoint> property, it certainly looks like multiple entry points are supported.
On the other hand, WorkingPackage.entryPointSourceFile contains the following comment:
/**
* The entry point being processed during this invocation of API Extractor.
*
* @remarks
* The working package may have multiple entry points; however, today API Extractor
* only processes a single entry point during an invocation. This will be improved
* in the future.
*/
which sounds less promising.
If supported, I would appreciate it if somebody could point me in the right direction. In return, I would gladly open a PR for the api extractor site with some extra documentation.
Is this a feature or a bug?
Please describe the actual behavior.
I'm looking for a way to generate documentation for a Typescript library/package which does not have a single input file.
Instead, the package contains of a set of modules where each module exports some classes, interfaces, ... . It is very similar to what Angular has, e.g. if you
npm install @angular/routeryou receive 3 modules in the samenpmpackage:@angular/routermodule@angular/router/upgrademodule@angular/router/testingmoduleJudging by the documentation, this should be possible using
api-extractor:I tried this, but could not get it to work. I have setup a test repository which you can use to reproduce my problem:
which results in
What I do in this repository is the following:
srcfolder contains a mix of.d.tsfiles and.tsfiles. This is probably irrelevant, but mainly done to mimic our current situation where we are migrating a.jscodebase Typescript, and have manually created definition files for unported JS codetsccompiler compiles thesrcfolder, and stores the output in thelibfolder.d.tsfiles from thesrcfolder into thelibfolder as well. That way, thelibfolder contains alld.tsfilesd.tsfiles in the lib folder by generating anapi-extractor.jsonfile where the entrypoint points to that specificd.tsfile, and store that output into thetempfolderThis approach results in
.api.jsonfiles where the module information is gone. I only see the package name. So of course, runningapi-documenteron it does not work.Is multiple entry points simply not supported (despite what is mentioned in the documentation), or am I doing something wrong ?
Looking at the documentation of the APIPackage class which has a
ReadonlyArray<ApiEntryPoint>property, it certainly looks like multiple entry points are supported.On the other hand,
WorkingPackage.entryPointSourceFilecontains the following comment:which sounds less promising.
If supported, I would appreciate it if somebody could point me in the right direction. In return, I would gladly open a PR for the api extractor site with some extra documentation.