-
Notifications
You must be signed in to change notification settings - Fork 536
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
refactor(api-markdown-documenter): Update structure of ApiTransformationConfiguration
and ApiItemTransformations
#23381
refactor(api-markdown-documenter): Update structure of ApiTransformationConfiguration
and ApiItemTransformations
#23381
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 17 changed files in this pull request and generated no comments.
Files not reviewed (12)
- tools/api-markdown-documenter/src/api-item-transforms/default-implementations/TransformApiInterface.ts: Evaluated as low risk
- tools/api-markdown-documenter/src/api-item-transforms/configuration/Transformations.ts: Evaluated as low risk
- tools/api-markdown-documenter/src/api-item-transforms/default-implementations/CreateSectionForApiItem.ts: Evaluated as low risk
- tools/api-markdown-documenter/src/api-item-transforms/default-implementations/TransformApiClass.ts: Evaluated as low risk
- tools/api-markdown-documenter/src/api-item-transforms/TransformApiModel.ts: Evaluated as low risk
- tools/api-markdown-documenter/src/api-item-transforms/configuration/Configuration.ts: Evaluated as low risk
- tools/api-markdown-documenter/src/api-item-transforms/default-implementations/TransformApiEnum.ts: Evaluated as low risk
- tools/api-markdown-documenter/src/api-item-transforms/default-implementations/TransformApiFunctionLike.ts: Evaluated as low risk
- tools/api-markdown-documenter/src/api-item-transforms/default-implementations/index.ts: Evaluated as low risk
- tools/api-markdown-documenter/src/api-item-transforms/default-implementations/TransformApiItemWithoutChildren.ts: Evaluated as low risk
- tools/api-markdown-documenter/src/api-item-transforms/test/Transformation.test.ts: Evaluated as low risk
- tools/api-markdown-documenter/src/api-item-transforms/default-implementations/TransformApiModuleLike.ts: Evaluated as low risk
* | ||
* @returns The list of {@link SectionNode}s that comprise the top-level section body for the API item. | ||
*/ | ||
readonly defaultSectionLayout: ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted from ApiItemTransformations
, since it really isn't a "transformation"; it's a utility used by transformations. It will also make it easier to convert ApiItemTransformations
to a mapped type (over ApiItemKind
) in the future.
/** | ||
* {@inheritDoc ApiItemTransformationConfiguration.defaultSectionLayout} | ||
*/ | ||
readonly defaultSectionLayout?: ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to deduplicate this with the duplicate signature above in a future change. For now, this is simpler given the mix of properties that are required in both "configuration" and "options", and the properties that are optional in "options".
|
||
logger.verbose(`Rendering section for ${apiItem.displayName}...`); | ||
logger.verbose(`Generating documentation section for ${apiItem.displayName}...`); | ||
|
||
let sections: SectionNode[]; | ||
switch (apiItem.kind) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: the exhaustive switch statement is still required since each transformation is strongly typed over its ApiItem
implementation. Hoping to simplify this in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple small things, otherwise lgtm!
tools/api-markdown-documenter/src/api-item-transforms/configuration/Transformations.ts
Outdated
Show resolved
Hide resolved
/** | ||
* Transformation to generate a {@link SectionNode} for a `Call Signature`. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep all the existing docs? I see only a few were kept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept the couple that had special notes on them. For the others, they seemed redundant. Cases like this always give me pause - I generally prefer docs even in cases like this, but the amount of spatial clutter they create in the file is a bit annoying :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm going to leave this alone for now. Once this becomes a mapped type, and some of the special cases have been normalized, this all becomes a lot cleaner.
🔗 No broken links found! ✅ Your attention to detail is admirable. linkcheck output
|
Updated the structure of
ApiTransformationConfiguration
to contain atransformations
property of typeApiItemTransformations
, rather than implementing that interface directly.Also updates
ApiItemTransformations
methods to be keyed off ofApiItemKind
, rather than being individually named.E.g. A call like
config.transformApiMethod(...)
would becomeconfig.transformations["Method"](...)
.This better aligns with similar transformational API surfaces in this library, like the renderers. It also makes it easier to ensure we capture all possible ApiItem kinds.
The
createDefaultLayout
property ofApiItemTransformations
now lives directly inApiTransformationConfiguration
, but has been renamed todefaultSectionLayout
.