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

refactor(api-markdown-documenter): Add and use a ValidApiItemKind type alias which excludes the None value #23384

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Josmithr
Copy link
Contributor

No valid ApiItem will have kind "None". There are a number of places where we are forced to assert that an item's kind is not "None" to make checks exhaustive, and there are other places where we probably should have been.

This PR adds a helper type alias and a helper function to encapsulate the validity checking.

@Josmithr Josmithr requested review from alexvy86, a team and Copilot December 20, 2024 01:33
@github-actions github-actions bot added the base: main PRs targeted against main branch label Dec 20, 2024

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 9 changed files in this pull request and generated no comments.

Files not reviewed (4)
  • tools/api-markdown-documenter/src/api-item-transforms/ApiItemTransformUtilities.ts: Evaluated as low risk
  • tools/api-markdown-documenter/src/api-item-transforms/TransformApiItem.ts: Evaluated as low risk
  • tools/api-markdown-documenter/src/api-item-transforms/configuration/DocumentationSuiteOptions.ts: Evaluated as low risk
  • tools/api-markdown-documenter/src/api-item-transforms/default-implementations/TransformApiClass.ts: Evaluated as low risk
Comments suppressed due to low confidence (1)

tools/api-markdown-documenter/src/utilities/ApiItemUtilities.ts:58

  • The error message should include more context about where the error occurred. Consider updating it to: Encountered an API item with kind "None" in getApiItemKind function: "${apiItem.displayName}".
throw new Error(`Encountered an API item with kind "None": "${apiItem.displayName}".`);
@github-actions github-actions bot added the public api change Changes to a public API label Dec 20, 2024
@@ -112,7 +112,7 @@ declare namespace ApiItemUtilities {
export { ApiItemUtilities }

// @public
export type ApiMemberKind = Omit<ApiItemKind, ApiItemKind.EntryPoint | ApiItemKind.Model | ApiItemKind.None | ApiItemKind.Package>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug. Should have been Exclude and not Omit.

hierarchyBoundaries: HierarchyBoundaries,
): boolean {
if (kind === ApiItemKind.Model) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handling was not exhaustive, revealed by fixing ApiMemberKind

@Josmithr Josmithr enabled auto-merge (squash) December 20, 2024 01:45
Copy link
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> fluid-framework-docs-site@0.0.0 ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> fluid-framework-docs-site@0.0.0 serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> fluid-framework-docs-site@0.0.0 check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  170138 links
    1596 destination URLs
    1825 URLs ignored
       0 warnings
       0 errors


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
base: main PRs targeted against main branch public api change Changes to a public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant