docs: update useMaterial api docs#1389
Conversation
WalkthroughThe documentation for the material plugin's Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant useMaterial API
participant MaterialState
User->>useMaterial API: initMaterial({ isInit, appData })
useMaterial API->>MaterialState: Initialize state
User->>useMaterial API: fetchMaterial()
useMaterial API->>MaterialState: Fetch and update materials
User->>useMaterial API: getComponentsByGroup(components, groupName)
useMaterial API->>MaterialState: Retrieve grouped components
User->>useMaterial API: refreshMaterial()
useMaterial API->>MaterialState: Refresh material data
User->>useMaterial API: getBlockByName(name)
useMaterial API->>MaterialState: Retrieve block details
User->>useMaterial API: addBlockResources(id, resource)
useMaterial API->>MaterialState: Add block resource
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (7)
docs/extension-capabilities-overview/registry.md (4)
124-139: Enhance discoverability by linking to frontend API docs
The engine.config 配置项详解 section is comprehensive but users may not realize how it ties into the material-plugin API. Consider adding a cross-reference or hyperlink to the useMaterial API documentation (docs/api/frontend-api/material-api.md) so readers can quickly navigate from config settings to actionable API methods.
143-161: Clarify howmaterialarray maps to runtime state
The material 配置 subsection explains accepted formats well. It would be helpful to explicitly mention that each entry in this array feeds intouseMaterial().materialState.packages(or.componentsDepsMap) at runtime. A one-sentence note linking config → state can bridge the gap between static setup and dynamic API usage.
162-173: Cross-linkthemeconfig to registry themes definition
You’ve described how to settheme: 'light'/'dark', but it’s easy for users to miss that this value must match atypein the themes array defined earlier (lines 31–38). Adding an inline link or a “参见上文 themes 定义” callout will help users connect the two sections without scrolling back and forth.
175-204: Split theme definitions into focused snippets
The combined snippet for both light and dark themes is detailed but lengthy. For readability, consider separating it into two smaller code blocks—one illustrating the light theme and another for the dark theme—each under its own subheading. This will help users digest each example independently.docs/api/frontend-api/material-api.md (3)
65-73: Verify consistency of newmaterialStatefields
The addedcomponentsDepsMap(withscripts:[]andstyles:Set) andpackages:[]accurately replace the oldthirdPartyDeps. To avoid confusion, consider standardizing collection types (e.g., useArrayfor both) or briefly explain why aSetis preferred for styles.
76-79: Correct inline code formatting in usage example
The 使用示例 uses triple backticks for inline code:
useMaterial().materialState
For proper markdown, switch this to single backticks:- ```useMaterial().materialState``` + `useMaterial().materialState`🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
76-76: Emphasis used instead of a heading
null(MD036, no-emphasis-as-heading)
120-137: Align examples with documented API surface
The second 使用示例 block invokesregisterBlockandrefreshMaterial, but readers may expect to see both in the API list above. Either remove or replace methods in the example so they match the documented API, or update the API list to include any additional methods you intend to support.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
120-120: Emphasis used instead of a heading
null(MD036, no-emphasis-as-heading)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
docs/api/frontend-api/material-api.md(1 hunks)docs/extension-capabilities-overview/registry.md(1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
docs/api/frontend-api/material-api.md
76-76: Emphasis used instead of a heading
null
(MD036, no-emphasis-as-heading)
120-120: Emphasis used instead of a heading
null
(MD036, no-emphasis-as-heading)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: push-check
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit