Skip to content

Refactor: remove jsdoc-api from the docs app#2051

Merged
matyasf merged 1 commit intomasterfrom
remove_jsdocapi
Jul 4, 2025
Merged

Refactor: remove jsdoc-api from the docs app#2051
matyasf merged 1 commit intomasterfrom
remove_jsdocapi

Conversation

@matyasf
Copy link
Collaborator

@matyasf matyasf commented Jun 30, 2025

Changes:

  • It uses the TypeScript compiler API instead of JSDoc-api JSDoc is outdated and its meant for JavaScript projects. We use this to parse everything thats not a React component or a Markdown file. (the utilities menu in the sidebar).
  • It gets type information for functions from the TypeScript types, so it can be deleted in the jsdoc (the {Object} part in @param {Object} bla).
  • For non-function or complex utilities it gets the info from the JSDoc so we need to keep it (e.g. withStyle, contains).
  • Removed DateTime and conversions and some custom PropTypes from the doc since they were parsed in a special way and contained no useful info.
  • note that it cannot parse types if the jsdoc is at the export e.g.
    function myFunc() ...
    
    export {
    /**
    * here is the doc. The parser doesnt know the types, do not use this pattern
    */
    myFunc
    }
    

To test:

  • check all the functions in the utilities submenu, they should display equal or more information

Closes INSTUI-4574

@matyasf matyasf self-assigned this Jun 30, 2025
@github-actions
Copy link

github-actions bot commented Jun 30, 2025

PR Preview Action v1.6.2
Preview removed because the pull request was closed.
2025-07-04 08:05 UTC

@matyasf matyasf force-pushed the remove_jsdocapi branch 6 times, most recently from d4f3c51 to 432b3e0 Compare July 2, 2025 11:23

render() {
const { layout } = this.props
renderGenericRows() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

now it can display generic parameters

@matyasf matyasf requested review from HerrTopi, balzss and Copilot July 2, 2025 11:28
@matyasf matyasf changed the title [WIP] refactor: remove jsdoc-api from the docs app Refactor: remove jsdoc-api from the docs app Jul 2, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Refactors the documentation generation to drop jsdoc-api in favor of the TypeScript compiler API, updates JSDoc comments for utility modules, and enhances the docs UI to surface generic type parameters.

  • Switch parsing from jsdoc-api to TypeScript compiler API in build scripts.
  • Remove outdated module-level JSDoc blocks and add inline JSDoc for utilities.
  • Extend documentation components (Params, Returns) to support generic type parameters.

Reviewed Changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/docs/buildScripts/utils/getJSDoc.mts Replaced jsdoc-api usage with TypeScript compiler API parsing.
packages/docs/src/Params/props.ts Added genericParameters prop support but missing in allowedProps.
packages/docs/src/Params/index.tsx Extended UI to render a Generic Parameters table.
packages/ui-position/src/calculateElementPosition.ts Added JSDoc block but missing module name in @module tag.
packages/ui-dom-utils/src/findTabbable.ts Reorganized code but removed JSDoc for findTabbable.
Comments suppressed due to low confidence (4)

packages/ui-position/src/calculateElementPosition.ts:79

  • The @module tag should include the module name (e.g. @module calculateElementPosition) so the docs generator can correctly associate comments with this function.
 * @module

packages/ui-dom-utils/src/findTabbable.ts:44

  • The findTabbable function no longer has its JSDoc comment after the refactor; add a descriptive block above the function to ensure it’s documented.
function findTabbable(el?: UIElement, shouldSearchRootNode?: boolean) {

packages/docs/src/Params/index.tsx:62

  • [nitpick] The new genericParameters rendering logic isn’t covered by existing tests. Consider adding unit tests for this branch to guarantee it displays correctly.
  renderGenericRows() {

packages/docs/buildScripts/utils/getClientProps.mts:44

  • [nitpick] The previous if (doc.undocumented) return check was removed, so docs without JSDoc may now slip through. Verify this change or reintroduce filtering for undocumented entries if unintended.
    .filter((doc) => !doc.private)

<Table.Body>
<Table.Row>
<Table.Cell>
<code>{this.props.types.type}</code>
Copy link

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

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

[nitpick] Rendering this.props.types.type directly may display undefined when no return type exists. Provide a fallback or conditional rendering to handle missing types.

Suggested change
<code>{this.props.types.type}</code>
<code>{this.props.types.type ?? 'N/A'}</code>

Copilot uses AI. Check for mistakes.
@matyasf matyasf force-pushed the remove_jsdocapi branch 3 times, most recently from 461b904 to feb99c4 Compare July 3, 2025 09:52
The **source code** is parsed with [JSDoc](https://jsdoc.app/) with the exeption of react components, which are parsed by [react-docgen](https://react-docgen.dev/) and it provides `type` information for the docs.
The **source code** is parsed with the [TypeScript compiler API](https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API) with the exception of React components, which are parsed by [react-docgen](https://react-docgen.dev/). These tools parse out JSDoc comments, type information of React component props and types for functions.

## Utility functions
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Heres the high level information how it works

Copy link
Contributor

@balzss balzss left a comment

Choose a reason for hiding this comment

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

nice work. good to see another legacy dependency gone

It uses the TypeScript compiler API instead of
JSDoc-api JSDoc is outdated and its meant for
 JavaScript projects.
 We use this to parse everything thats not a
 React component or a Markdown file.
 (the utilities menu in the sidebar).

It gets type information for functions from the
TypeScript types, so it can be deleted in the
jsdoc (the {Object} part in @param {Object} bla).

For non-function or complex utilities
it gets the info from the JSDoc so we need to
keep it (e.g. withStyle, contains).

Removed DateTime and conversions and some
custom PropTypes from the doc since they were
parsed in a special way and contained no useful
info.

note that it cannot parse types if the jsdoc is
at the export statement
@matyasf matyasf force-pushed the remove_jsdocapi branch from feb99c4 to d02c61b Compare July 4, 2025 07:54
@matyasf matyasf merged commit c6b30ad into master Jul 4, 2025
11 checks passed
@matyasf matyasf deleted the remove_jsdocapi branch July 4, 2025 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants