-
Notifications
You must be signed in to change notification settings - Fork 668
Description
Is this a feature or a bug?
- Feature
- 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/routermodule - The
@angular/router/upgrademodule - The
@angular/router/testingmodule
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
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 code - The
tsccompiler compiles thesrcfolder, and stores the output in thelibfolder. - I copy the
d.tsfiles from thesrcfolder into thelibfolder as well. That way, thelibfolder contains alld.tsfiles - I run the API extractor on all the
d.tsfiles in the lib folder by generating anapi-extractor.jsonfile where the entrypoint points to that specificd.tsfile, and store that output into thetempfolder
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.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status