-
Notifications
You must be signed in to change notification settings - Fork 134
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
Handling/documenting merged declarations #137
Comments
I'm curious in general about how documentation systems represent merged declarations, which seem to be a TypeScript-specific requirement. Consider a definition like ApiReleaseTagMixin:
Currently DocFX groups API items under headings by type (e.g. "Classes", "Interfaces", "Enums", and "Functions" in this example). Today Using the TSDoc tags @natalieethell proposed above, we could maybe improve that: /**
* The mixin base class for declarations that have an associated release tag.
*
* @remarks
* The interface describes the non-static members of the mixin class.
* The namespace contains the static members.
*
* {@documentAs mixin}
*/
interface ApiReleaseTagMixin {
}
/** {@partOf (ApiReleaseTagMixin:interface)} */
namespace ApiReleaseTagMixin {
}
/**
* Constructs a mixin base class conforming to the {@link (ApiReleaseTagMixin:interface)}
* interface.
* @param baseClass - The base class to extend
* @returns a base class that implements `ApiReleaseTagMixin` and extends `baseClass`
*/
function ApiReleaseTagMixin<TBaseClass extends IApiItemConstructor>(baseClass: TBaseClass):
TBaseClass & (new (...args: any[]) => ApiReleaseTagMixin) {
} The
Whereas the function would get its own documentation entry under the "Functions" section as usual:
|
We already established in #9 that function overloads should be documented separately. But Office Addin-ins encountered a bunch of function overloads that exist purely for technical reasons (due to two different enum representations in this case). For example: /**
*
* Deletes the cells associated with the range.
*
* [Api set: ExcelApi 1.1]
*
* @param shift - Specifies which way to shift the cells. See Excel.DeleteShiftDirection for details.
*/
delete(shift: Excel.DeleteShiftDirection): void;
/**
*
* Deletes the cells associated with the range.
*
* [Api set: ExcelApi 1.1]
*
* @param shift - Specifies which way to shift the cells. See Excel.DeleteShiftDirection for details.
*/
delete(shift: "Up" | "Left"): void; The /**
*
* Deletes the cells associated with the range.
*
* [Api set: ExcelApi 1.1]
*
* @param shift - Specifies which way to shift the cells. See Excel.DeleteShiftDirection for details.
*/
delete(shift: Excel.DeleteShiftDirection): void;
/** {@partOf (delete:1)} */
delete(shift: "Up" | "Left"): void; |
How would this affect overloads with differently documented parameters? Here's a common example from our d.ts:
|
The documentation would refer to the "main" declaration (i.e. the one that doesn't have an |
Am I correct in thinking |
It depends. If |
Just to be clear, individual parameters on overloads would not be explicitly documented with Please let us know when this is functionality is supported in the web-build-tools suite. |
Update: PR microsoft/rushstack#1646 adds most of the machinery needed to implement a |
Would this work for merging interface docs into class docs? Using the example from microsoft/rushstack#1921: /**
* @public
*/
export class MyWidget extends EventEmitter {
// class implementation goes here
}
/**
* {@partOf (MyWidget:class)}
*/
export interface MyWidget {
// `on()` and `once()` declarations for MyWidget events
} |
When designing
What does the table of contents show? Should the items be mixed together like:
A different strategy would be to keep them as separate items, but with hyperlinks that makes it easy to switch between them:
Something like this:
|
Pete and I were discussing ways that TSDoc can handle merged declarations, and wanted to summarize a couple ideas here.
Say you have a scenario where you want to export the same API with a different name. You could have something like
where Y is an enum. For certain reasons, we are considering splitting it up into something like the following instead:
We likely still want both X's to be documented together. We have two tags in mind to solve this:
@documentAs
and@partOf
.@documentAs
would be used to tell the documentation system how to present this API, for example grouping it under the "Enums" section even though it isn't technically an enum.@partOf
would be used to group the second definition with the first.Using the example above, we might have something like the following:
I'm curious to see if anyone else has thought about this much and/or has any other ideas or suggestions.
The text was updated successfully, but these errors were encountered: