Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Internal/External code distinction #927

Closed
3 tasks
aciccarello opened this issue Dec 24, 2018 · 7 comments
Closed
3 tasks

Improve Internal/External code distinction #927

aciccarello opened this issue Dec 24, 2018 · 7 comments
Labels
help wanted Contributions are especially encouraged

Comments

@aciccarello
Copy link
Collaborator

There is a lot of confusion on the Internal/External code distinction. Ideally, internal code would include the types in the project while external code would be libraries. TypeDoc currently uses the input files as the distinction between these two which is insufficient in cases where users want to use an entry file as their input.

  • Change default to mark files in a node_modules or libs directory as external rather than input files
  • Document how to use --externalPattern for more granular control
  • Rename "Externals" to "Libs"

Related issues: #124, #673

@aciccarello aciccarello added help wanted Contributions are especially encouraged epic labels Dec 24, 2018
@diosney
Copy link

diosney commented Jan 18, 2019

Besides renaming "Externals" to "Libs" it could be awesome if there was a way to differentiate code to be consumed internally from the public exported API, something like typedoc-plugin-internal-external tries to do at the Aliases section, but that is so counterintuitive (besides misusing the External/Libs feature for that).

Maybe after "Libs" gets added, "Externals" can be repurposed to differentiate between Internal APIs from the External exported public surface?

Hope you understand what I mean.

@aciccarello
Copy link
Collaborator Author

@diosney That's a good point. So you are thinking there should be a Libs, Public, and Internal distinction?

@diosney
Copy link

diosney commented Jan 19, 2019

@aciccarello Yes, that was what I meant! Do you think that is possible? It could be really awesome :D

@aciccarello
Copy link
Collaborator Author

@diosney Great, splitting internal into public and internal should be something we can look at when implementing #639

@DanielSchaffer
Copy link

If we're talking internal, this is probably worth at least keeping an eye on: microsoft/TypeScript#5228

@tobiasschweizer
Copy link

tobiasschweizer commented Nov 26, 2020

I am experiencing the issue that most of my code gets flagged as isExternal: true when I look at the JSON representation (using --json option).

I think this is because of the way this method is implemented:

/**
* Checks if the given file is external.
*
* @param fileName
* @internal
*/
isExternalFile(fileName: string) {
let isExternal = !this.fileNames.includes(fileName);
if (!isExternal && this.externalPattern) {
isExternal = this.externalPattern.some((mm) => mm.match(fileName));
}
return isExternal;
}

If I am not mistaken, this.fileNames contains the files that are set up in tsconfig.json:

/**
* A list of all files that have been passed to the TypeScript compiler.
*/
fileNames: string[];

So my tsconfig.json looks something like this:

  "files": [
    "index.ts",
  ],
  "include": [
    "src/**/*.ts"
  ]

Does this mean that the whole directory src is flagged as external because only files is used to check if something is external?

Could there be something like an internalPattern?

Edit: I have just noticed that it was probably my fault: I used typedoc src/*.ts which just included the files that were directly in src. Changing it to src works.

Then I get all the files in fileNames:

convert(fileNames: string[]): ConverterResult {

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 26, 2020

The external distinction has changed significantly in 0.20.... along with a ton of other stuff. Symbols (not files) are now marked external based solely on externalPattern, and TypeDoc defaults to marking symbols as external iff they come from node_modules. I'd recommend taking a look at typedoc@beta, which probably gives output closer to what you want by default. typedoc src/index.ts should be all that's necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributions are especially encouraged
Projects
None yet
Development

No branches or pull requests

5 participants