Partial documentation inheritance #3008
-
Is there a way to do partial inheritance of documentation from a class? For example: /**
* This is the Foo class
*
* @typeParam A foo type
*/
class Foo<A> {
constructor(public foo: A) {}
}
/*
* This is the Bar class
*
* {@inheritDoc Foo}
*/
class Bar<A> extends Foo<A> {} shows a warning that the summary of the bar class will be overwritten, and it produces "This is the Foo class" as the summary for the Bar class, is there a way to show "this is the Bar class" for the Bar class summary and only inherit typeParams? It would also be nice to do something like this: /**
* This is the Foo class
*
* @typeParam A foo type
*/
class Foo<A> {
constructor(public foo: A) {}
}
/*
* This is the Bar class
*
* {@inheritDoc Foo}
* @typeParam B bar type
*/
class Bar<A, B> extends Foo<A> {
constructor(public bar: B) {}
} and be able to merge and override typeParams Alternatively a documentation variable could also solve the problem sufficiently. For example something along the lines of /**
* @variabledef AType foo type
*/
/**
* This is the Foo class
*
* @typeParam A {@variable AType}
*/
class Foo<A> {
constructor(public foo: A) {}
}
/*
* This is the Bar class
*
* @typeParam A {@variable AType}
* @typeParam B bar type
*/
class Bar<A, B> extends Foo<A> {
constructor(public bar: B) {}
} Kind of like a macro where it just copies and pastes text in place Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
There isn't a way to do this today built in, you could use typedoc-plugin-replace-text to do a variables-like idea. I've considered a |
Beta Was this translation helpful? Give feedback.
There isn't a way to do this today built in, you could use typedoc-plugin-replace-text to do a variables-like idea.
I've considered a
@copyDoc
tag before which behaves similarly to this, but haven't built it because it would only be recognized by TypeDoc, and I really don't want to encourage people to write docs in a way which results in a degraded experience for people referencing the library's declaration file, which in my experience is the primary (beating out any level of curated docs site) way that people will interact with documentation for a library. The@copyDoc
tag could be implemented by a plugin (likely starting with the replace text plugin as it mostly does everything necessar…