-
Notifications
You must be signed in to change notification settings - Fork 699
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
Generate documentation also for indirect exported Types. #1657
Comments
Just adding a +1 here that this has been one of my biggest pain-points when using I agree that the expected behaviour from typedoc is that it would start at the // resources/users.ts
export class UserResource {
/*
* Gets a user by id
*/
async getUser(id: string) {
return await fetch('/users/' + id);
}
} // index.ts
import UserResource from './resources/users';
export class Client {
users: UserResource;
constructor() {
this.users = new UserResource();
}
} Here I would like to have the |
I've spent a lot of time thinking about this, and still come down on the side of it not being a good idea. This is not a feature that TypeDoc proper is going to include. By not exporting types which a user can access, you are making your library unnecessarily harder to use. Taking @tenbits example, if I want to use this library, and want to declare a variable of the type I need to pass to
The case presented by @dabrowne suffers from the same issue. If I have a function which doesn't need all of Thanks to the suggestion in #1653, TypeDoc 0.22 will check for types that you forgot to export and warn you about them. I believe that in almost all cases, these warnings should be fixed. However, I recognize I am not going to be able to convince everyone of this. The changes which made #1653 possible also made it relatively straightforward to detect non-exported types and document them. This is available as a plugin typedoc-plugin-missing-exports which supports version 0.22 (currently |
Thanks Gerrit, I've checked the Though, I think, such behavior should be by default, it seems you're confusing documentation with distribution. You take only packages into the consideration. My example is only the source, not the target build, therefor, as for me, the doc builder should create documentation for the source. Your case is absolutely valid, but again, only from the distribution point - when a lib consumer has no direct access to the And there are at least two other cases from my own practice.
In both cases documentation for the source code - that is the couple. A doc builder just generates easy to read (without all those implementations and internals), zero-time maintainable overview of an entry point, or even many different (case dependent) entry points. But anyway, thanks a lot for the plugin. Best |
I'd like to add, that sometimes exporting everything is not desirable/feasible. It works well in case of small, well-defined packages. However, if you write a bigger library it does not work. For example, I'm currently working on the testing tool: https://siesta.works Thanks a lot for the plugin you provided, I believe it should be available in typedoc out of the box. |
Keeping this as a separate plugin creates confusion for beginners. In addition, it allows space for incompatibility with upstream build tools like Docusaurus. I'm finding that it generates invalid markdown: Gerrit0/typedoc-plugin-missing-exports#13 It leads me to believe that this feature should be the default. Doing so would allow tool builders to ensure compatibility when making plugins and building tools on top. Like the folks above, I vote that this should be the default behavior in typedoc. |
This seems unrelated. The plugin doesn't do anything special to break other plugins that couldn't happen without it. The bug you link to could be easily reproduced without the plugin with a export class Builders {
static "<h1>"(text: string) {
return `<h1>${escape(text)}</h1>`
}
}
Could the warning be improved somehow? Your description of the issue in dawsbot/essential-eth#121 indicates you were able to quickly determine what the issue was, and how it should be fixed. |
Thanks for the understanding in the other issues @Gerrit0 I see why this is not related and this is a bug in docusaurus 🙏 |
I am using the I agree with the arguments made, but I don't think they would apply to the case where an exported type is a type alias for an internal type, or where an external interface extends an internal interface. If the internal type/interface does not make sense on its own, and is only meaningful to consumers within one of the exported types/interfaces that includes or extends its (e.g. an internal type could regroup some common properties from a few exported types), then it does not make sense to export it. Since the internal type is included in the exported type, consumers of the module will be able to view any type information and tsdoc for the internal types via the exported type. However, with this package, the documentation for the exported type alias/interface will not include any of the type information or tsdoc for the included interal type/interface. This seems like a shortcoming compared to the native TS behaviour, and is hard to justify as not conforming to best practices. |
I agree with @loucadufault. I'm working on a ts library where I usually abstract some common properties into one base interface and export public interfaces that extend the internal base interface. Currently, I have to also export the internal base interface for the consumers to view the property definitions of the public interfaces. The same applies to |
Dear Typedoc Team,
sorry for rising this topic up again, but I'm rather sure the lack of this feature makes the documentation generator uncomplete.
Consider this valid case:
Foo.ts
IFoo.ts
Bar.ts
Now let's say, we want to generate the documentation for the
Foo
class. When we specify"entryPoints": ["Foo.ts"]
we will lose half of the required documentation - about what areIFoo
andBar
.As I see, there are 2 possible workarounds:
entryPoints
, or using theplugin-not-exported
- but in both cases we have manually to track all required Types for the documentation. And usually due to the nested refs this is not quit easy to do.entryPoints
to generate the docs for all files - but this blows the documentation with unneeded types.So those workarounds are almost not usable.
What is the expected behavior?
Documentation generator should track all Types accessible by the reference (in
property
,argument
,return type
) and include those in output. It should track also deeply nested refs like in exampleFoo
➝IFoo
➝Bar
Or is there another way to output and link all Types direct or indirect accessible by
Foo
consumer?The text was updated successfully, but these errors were encountered: