Skip to content

docs: add more JSDoc categories#714

Merged
tbouffard merged 3 commits intomainfrom
docs/jsdoc_add_more_categories
Mar 12, 2025
Merged

docs: add more JSDoc categories#714
tbouffard merged 3 commits intomainfrom
docs/jsdoc_add_more_categories

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented Mar 12, 2025

Apply existing categories to more elements.
Add categories:

  • Editor
  • GUI
  • Style
    JSDoc HTML documentation: include categories in the navigation to ease the organization

Also improve JSDoc in some classes and functions.

Summary by CodeRabbit

  • Documentation
    • Enhanced overall documentation across various product components with streamlined descriptions, modernized examples, and improved categorization for easier navigation.
    • Added new category annotations to various classes and functions to improve organization and discoverability.
  • New Features
    • Introduced an experimental reset capability for translation settings.
  • Type & Styling Improvements
    • Added new type definitions to support advanced styling options and extend plugin functionality.

Apply existing categories to more elements.
Add categories:
  - Editor
  - GUI
  - Style
JSDoc HTML documentation: include categories in the navigation to ease the organization

Also improve JSDoc in some classes and functions.
@tbouffard tbouffard added the documentation Improvements or additions to documentation label Mar 12, 2025
@coderabbitai
Copy link

coderabbitai bot commented Mar 12, 2025

Walkthrough

This pull request makes extensive updates to documentation comments and JSDoc annotations across many modules in the codebase. The changes reformat descriptions, update example code to modern JavaScript conventions (using const), and add new category tags (e.g., Editor, GUI, I18n, Serialization with Codecs, Style, EdgeStyle). A new experimental function is added to reset translation configurations, and the TypeDoc options in the tsconfig have been revised. No functional or control-flow changes have been introduced.

Changes

File(s) Change Summary
packages/core/src/editor/{Editor, EditorKeyHandler, EditorPopupMenu, EditorToolbar}.ts Updated documentation comments and examples (using const) with streamlined descriptions and added/updated @category Editor annotations; no functional changes.
packages/core/src/gui/{MaxForm, MaxLog, MaxLogAsLogger, MaxPopupMenu, MaxToolbar, MaxWindow}.ts Revised JSDoc comments by replacing legacy tags with @category GUI, reformatting examples, and adding logging-relevant category annotations; documentation-only updates.
packages/core/src/i18n/{Translations.ts, config.ts} Added @category I18n annotations and updated documentation comments; introduced a new experimental function resetTranslationsConfig to reset translation configuration values.
packages/core/src/serialization/{register-model-codecs, register-other-codecs}.ts Added @category Serialization with Codecs annotations to the documentation of codec registration functions.
packages/core/src/types.ts Introduced several new type definitions related to styling and plugin interfaces and updated existing types with annotations such as @category Style and @category EdgeStyle.
packages/core/src/util/MaxXmlRequest.ts Improved documentation by correcting typographical errors and updating links and formatting in code examples without affecting functionality.
packages/core/src/view/{cell/register-shapes.ts, geometry/edge/MarkerShape.ts, style/(EdgeStyle.ts, StyleRegistry.ts, Stylesheet.ts, config.ts, register.ts)} Enhanced documentation across shape registration and styling modules by adding @since and appropriate @category annotations; comments were restructured for clarity.
packages/core/tsconfig.json Revised TypeDoc options: added "excludeInternal": true, updated the categoryOrder array with new categories (EdgeStyle, Editor, GUI, I18n, Style), and enabled category navigation by switching "includeCategories" to true.

Possibly related PRs

  • docs: migrate the mxGraph tutorial #618: The changes in the main PR, which focus on updating documentation comments for the Editor class, are related to the retrieved PR that also emphasizes information regarding the Editor class in the context of migrating the mxGraph tutorial.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f979ead and c4f49a4.

📒 Files selected for processing (3)
  • packages/core/src/view/cell/register-shapes.ts (1 hunks)
  • packages/core/src/view/geometry/edge/MarkerShape.ts (1 hunks)
  • packages/core/src/view/style/register.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/core/src/view/cell/register-shapes.ts
  • packages/core/src/view/geometry/edge/MarkerShape.ts
  • packages/core/src/view/style/register.ts

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tbouffard tbouffard marked this pull request as ready for review March 12, 2025 09:17
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
packages/core/src/gui/MaxLogAsLogger.ts (1)

27-29: JSDoc Category Addition: GUI and Logging
The addition of @category GUI and @category Logging clarifies the categorization of the MaxLogAsLogger class. Please verify that the use of multiple categories here is intentional and that the generated documentation will display them as expected.

packages/core/src/view/cell/register-shapes.ts (1)

42-45: JSDoc Update: Added Versioning and Dual Categories
The inclusion of @since 0.8.0 along with both @category Configuration and @category Style helps clarify the function’s version history and its dual role in configuration and styling. Please confirm that dual categorization meets your documentation standards.

packages/core/src/view/style/StyleRegistry.ts (1)

20-22: Suggestion: Verify Terminology in Description
The phrase “used to perimeters and edge styles” appears ambiguous. Consider revising it for clarity (e.g., “used for handling perimeters and edge styles”) if that better reflects the intended functionality.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b22b074 and 54f6c79.

📒 Files selected for processing (24)
  • packages/core/src/editor/Editor.ts (1 hunks)
  • packages/core/src/editor/EditorKeyHandler.ts (1 hunks)
  • packages/core/src/editor/EditorPopupMenu.ts (1 hunks)
  • packages/core/src/editor/EditorToolbar.ts (2 hunks)
  • packages/core/src/gui/MaxForm.ts (1 hunks)
  • packages/core/src/gui/MaxLog.ts (1 hunks)
  • packages/core/src/gui/MaxLogAsLogger.ts (1 hunks)
  • packages/core/src/gui/MaxPopupMenu.ts (1 hunks)
  • packages/core/src/gui/MaxToolbar.ts (1 hunks)
  • packages/core/src/gui/MaxWindow.ts (1 hunks)
  • packages/core/src/i18n/Translations.ts (1 hunks)
  • packages/core/src/i18n/config.ts (1 hunks)
  • packages/core/src/serialization/register-model-codecs.ts (1 hunks)
  • packages/core/src/serialization/register-other-codecs.ts (3 hunks)
  • packages/core/src/types.ts (10 hunks)
  • packages/core/src/util/MaxXmlRequest.ts (3 hunks)
  • packages/core/src/view/cell/register-shapes.ts (1 hunks)
  • packages/core/src/view/geometry/edge/MarkerShape.ts (1 hunks)
  • packages/core/src/view/style/EdgeStyle.ts (1 hunks)
  • packages/core/src/view/style/StyleRegistry.ts (1 hunks)
  • packages/core/src/view/style/Stylesheet.ts (1 hunks)
  • packages/core/src/view/style/config.ts (6 hunks)
  • packages/core/src/view/style/register.ts (1 hunks)
  • packages/core/tsconfig.json (1 hunks)
🔇 Additional comments (53)
packages/core/src/util/MaxXmlRequest.ts (3)

222-225: Improved Documentation for getStatus Method
The updated JSDoc for getStatus now correctly uses "e.g." instead of "eg." and clearly explains the expected numeric status codes. This change enhances both grammatical correctness and clarity.


242-249: Clarified JSDoc for send Method
The revised documentation for the send method now explicitly notes that the onerror parameter is ignored (due to technical limitations) and that it is intended for override. This additional clarification improves the reader’s understanding of the method’s behavior.


519-524: Enhanced JSDoc for post Function
The updated JSDoc for the post function now cleanly explains that the parameters will be posted asynchronously and emphasizes the need to use encodeURIComponent for parameter values. This clear description will help maintain consistency across documentation and assists developers in correct usage.

packages/core/src/view/geometry/edge/MarkerShape.ts (1)

256-258: Documentation improvement: Added style category

Good addition of @since 0.11.0 and @category Style tags to properly categorize the registerDefaultEdgeMarkers function. This enhancement improves documentation organization and aligns with the PR objectives.

packages/core/src/view/style/register.ts (1)

27-29: Documentation improvement: Added style category and version information

The addition of @since 0.8.0 and @category Style tags to the registerDefaultStyleElements function enhances the documentation by providing version information and proper categorization, which aligns perfectly with the PR objectives.

packages/core/src/serialization/register-model-codecs.ts (1)

43-43: Documentation improvement: Added serialization category

Good addition of the @category Serialization with Codecs tag to properly categorize the registerModelCodecs function. This enhancement improves the organization of documentation and helps users better understand the purpose of this function.

packages/core/src/view/style/config.ts (6)

27-27: Documentation improvement: Added EdgeStyle category

Good addition of the @category EdgeStyle tag to enhance the categorization of the EntityRelationConnectorConfig configuration object.


44-44: Documentation improvement: Added EdgeStyle category

Good addition of the @category EdgeStyle tag to enhance the categorization of the resetEntityRelationConnectorConfig function.


57-57: Documentation improvement: Added EdgeStyle category

Good addition of the @category EdgeStyle tag to enhance the categorization of the OrthogonalConnectorConfig configuration object.


84-84: Documentation improvement: Added EdgeStyle category

Good addition of the @category EdgeStyle tag to enhance the categorization of the resetOrthogonalConnectorConfig function.


126-126: Documentation improvement: Added EdgeStyle category

Good addition of the @category EdgeStyle tag to enhance the categorization of the ManhattanConnectorConfig configuration object.


144-144: Documentation improvement: Added EdgeStyle category

Good addition of the @category EdgeStyle tag to enhance the categorization of the resetManhattanConnectorConfig function.

packages/core/src/view/style/EdgeStyle.ts (1)

81-83: JSDoc Category Added for EdgeStyle
The documentation now includes the @category EdgeStyle tag, which improves the organization and discoverability of this class in the generated docs. This change is straightforward and aligns well with the new documentation standards.

packages/core/src/gui/MaxPopupMenu.ts (1)

50-52: JSDoc Enhancement for GUI Components
The inclusion of the @category GUI tag in the JSDoc comment clarifies that MaxPopupMenu is part of the GUI layer. This helps in better categorizing documentation without affecting functionality.

packages/core/src/gui/MaxLog.ts (1)

31-33: Enhanced JSDoc with Multiple Categories
The addition of both @category GUI and @category Logging tags to the MaxLog class refines its classification. This dual categorization neatly indicates that the class plays a role in both GUI-related operations and logging functionality.

packages/core/src/view/style/Stylesheet.ts (1)

46-48: Added JSDoc Category for Styling
The new @category Style tag in the documentation for the Stylesheet class helps in grouping style-related functionalities. This update should enhance navigation in the generated documentation and follows the documentation consistency improvements seen across the codebase.

packages/core/src/gui/MaxToolbar.ts (1)

46-47: JSDoc Categorization Update for GUI Components
Adding the @category GUI tag to the MaxToolbar class documentation is a clear improvement, making it easier for developers to locate and understand GUI-related components in the codebase.

packages/core/src/i18n/Translations.ts (1)

75-77: JSDoc Category Addition: I18n
Adding the @category I18n tag organizes the Translations class under internationalization, which aligns well with the overall documentation improvements.

packages/core/src/gui/MaxForm.ts (1)

27-27: JSDoc Update: Categorization as GUI
The updated JSDoc for the MaxForm class now includes the @category GUI annotation, which improves the clarity and navigability of the documentation for GUI-related components.

packages/core/src/view/style/StyleRegistry.ts (1)

19-25: JSDoc Enhancement: Improved Formatting and Category Inclusion
The restructuring of the documentation comment—with the consolidation of the description and the insertion of the @category Style tag—greatly improves clarity and consistency.

packages/core/src/gui/MaxWindow.ts (1)

179-179: Good addition of category tag for improved documentation organization.

Adding the @category GUI tag to the MaxWindow class helps organize the documentation and makes it easier to navigate related components.

packages/core/src/serialization/register-other-codecs.ts (3)

70-70: Documentation enhancement with new category tag.

Adding the @category Serialization with Codecs tag to the registerCoreCodecs function improves documentation organization while maintaining the existing @category Configuration tag.


95-95: Documentation enhancement with new category tag.

Adding the @category Serialization with Codecs tag to the registerEditorCodecs function improves documentation organization while maintaining the existing @category Configuration tag.


117-117: Documentation enhancement with new category tag.

Adding the @category Serialization with Codecs tag to the registerAllCodecs function improves documentation organization while maintaining the existing @category Configuration tag.

packages/core/src/i18n/config.ts (2)

40-50: Good addition of a utility function to reset translations configuration.

The new resetTranslationsConfig function with proper JSDoc documentation provides a convenient way to reset translations to default values. The experimental tag is appropriate since this is related to global configuration that may change in the future.


54-58: Enhanced documentation for TranslationsConfig.

The updated JSDoc for TranslationsConfig now properly indicates its experimental status and adds the I18n category tag, providing better documentation organization.

packages/core/src/editor/EditorToolbar.ts (4)

33-37: Improved class documentation formatting and clarity.

The description has been concisely updated to "Toolbar for the editor" with proper markdown formatting using "### Example" which aligns with modern documentation standards.


44-47: Updated example code to use modern JavaScript conventions.

Good update from var to const in the example code, which follows modern JavaScript best practices.


57-57: Added category tag for better documentation organization.

The addition of @category Editor helps with documentation organization and makes related components easier to find.


122-122: Improved readability in comment.

Changed "doubleclick" to "double click" for better readability and consistency with other documentation.

packages/core/src/editor/Editor.ts (2)

394-394: Documentation improvement with category addition

The addition of the @category Editor tag enhances the code's documentation by properly categorizing this class in the generated documentation. This aligns with the PR objective of adding JSDoc categories.


397-406: Improved constructor documentation with modern JavaScript syntax

The updated constructor documentation is more concise and uses modern ES6 syntax with const instead of var. The parameter description has also been added for better clarity.

packages/core/src/editor/EditorKeyHandler.ts (1)

25-46: Improved class documentation with better structure and modern syntax

The documentation has been significantly improved with:

  1. More concise first line description
  2. Better explanation of class functionality
  3. Improved section headers using markdown syntax (### Example, ### Codec, ### Keycodes)
  4. Updated code example to use modern ES6 syntax with const
  5. Added @category Editor tag for proper categorization

These changes align with the PR objective to enhance JSDoc documentation and apply consistent categorization.

packages/core/src/editor/EditorPopupMenu.ts (1)

28-39: Enhanced documentation with improved structure and categorization

The class documentation has been restructured with:

  1. More concise first line description
  2. Better organized explanations with separate paragraphs
  3. Updated class reference from mxPopupMenu to MaxPopupMenu
  4. Improved section header format with markdown syntax (### Codec)
  5. Added @category Editor tag for proper categorization

These changes contribute to better documentation readability and organization, aligning with the PR objectives.

packages/core/tsconfig.json (3)

18-18: Added excludeInternal option for TypeDoc

Adding "excludeInternal": true will ensure that internal symbols are excluded from the generated documentation, creating cleaner and more focused API documentation for users.


25-30: Added new JSDoc categories to TypeDoc configuration

The addition of new categories ("EdgeStyle", "Editor", "GUI", "I18n", "Style") and reorganization of existing ones supports the PR objective of adding more JSDoc categories for better documentation organization.

Also applies to: 34-34


39-39: Enabled categories in TypeDoc navigation

Changing includeCategories from false to true ensures that the newly defined categories will be included in the navigation structure of the generated documentation. This improves documentation browsing and organization.

packages/core/src/types.ts (16)

38-39: LGTM! Good documentation enhancement.

Adding the @category Style tag to StyleValue type helps organize your JSDoc documentation better.


43-69: LGTM! Appropriate categorization for CellStyle.

The @category Style tag is correctly added to the CellStyle type, enhancing documentation organization.


71-875: LGTM! Good documentation organization.

Adding the @category Style tag to the extensive CellStateStyle type helps with JSDoc categorization.


877-882: LGTM! Appropriate categorization.

The @category Style tag is correctly added to the NumericCellStateStyleKeys type.


884-885: LGTM! Consistent categorization.

The @category Style tag is appropriately added to the ColorValue type.


886-889: LGTM! Enhanced documentation for SpecialStyleColorValue.

Improved JSDoc comment with the @category Style tag for better organization.


897-908: LGTM! Consistent categorization for style-related types.

The @category Style tags are appropriately added to all style value types, maintaining consistency.


911-911: LGTM! Appropriate categorization for ArrowValue.

The @category Style tag is correctly added to the arrow-related type.


927-927: LGTM! Consistent categorization.

The @category Style tag is appropriately added to the StyleArrowValue type.


933-933: LGTM! Appropriate categorization for ShapeValue.

The @category Style tag is correctly added to the shapes-related type.


955-955: LGTM! Consistent categorization.

The @category Style tag is appropriately added to the StyleShapeValue type.


1202-1204: LGTM! Added version information and categorization.

The @since 0.8.0 and @category EdgeStyle tags provide valuable metadata for the EdgeStyleFunction type.


1217-1217: LGTM! Appropriate categorization for EdgeStyleValue.

The @category EdgeStyle tag is correctly added to the edge style-related type.


1232-1232: LGTM! Consistent categorization.

The @category EdgeStyle tag is appropriately added to the StyleEdgeStyleValue type.


1242-1242: LGTM! Appropriate categorization for MarkerFactoryFunction.

The @category Style tag is correctly added to the marker-related function type.


1088-1097:

Details

✅ Verification successful

Added new onDestroy method to GraphPlugin interface.

The GraphPlugin interface has been enhanced with an onDestroy method, which will require implementations to handle plugin cleanup. Make sure all existing plugin implementations are updated to include this method.

Both interfaces are correctly categorized with @category Plugin tags.


🏁 Script executed:

#!/bin/bash
# Check for existing plugin implementations that might need updates
echo "Searching for GraphPlugin implementations that need to be updated with onDestroy method:"
rg "class .+ implements GraphPlugin" -g "*.ts"

Length of output: 1116


I'll run a further check to verify if the implementations of GraphPlugin include an onDestroy method.


🏁 Script executed:

#!/bin/bash
echo "Checking for onDestroy definitions in files implementing GraphPlugin..."
rg -n "onDestroy" packages/core/src/view/handler/*.ts

Length of output: 2343


Update Verified: GraphPlugin onDestroy Implementations

The new onDestroy method has been correctly added to the GraphPlugin interface, and our search confirms that all core classes implementing GraphPlugin (e.g., RubberBandHandler, TooltipHandler, PanningHandler, SelectionHandler, PopupMenuHandler, SelectionCellsHandler, ConnectionHandler, and CellEditorHandler) now include an implementation of onDestroy. The categorization with @category Plugin remains intact.

No further changes are needed for this update. Please ensure that any non-core or future plugin implementations also adhere to this updated cleanup contract.

@sonarqubecloud
Copy link

@tbouffard tbouffard merged commit 8385ad5 into main Mar 12, 2025
2 checks passed
@tbouffard tbouffard deleted the docs/jsdoc_add_more_categories branch March 12, 2025 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant