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

docs: fix docs-link and add EllipsisText docs #5158

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

mynetfan
Copy link
Collaborator

@mynetfan mynetfan commented Dec 17, 2024

Description

修复演示页面中的文档链接可能会404的问题;
添加EllipsisText组件文档
fix #5155

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • New Features

    • Added a new sidebar item for "EllipsisText 省略文本" in the documentation.
    • Introduced new documentation for the Vben EllipsisText component, detailing its usage and properties.
    • Added a new API section to the Vben ApiComponent documentation.
    • Created demo components for the EllipsisText component showcasing expandable text, line truncation, and tooltip functionality.
  • Bug Fixes

    • Enhanced URL construction logic in the DocButton component to prevent 404 errors.
  • Style

    • Updated the DocButton component in the form example to include a margin-bottom styling.
  • Chores

    • Maintained existing structure and functionality across various documentation files and components.

@mynetfan mynetfan requested review from anncwb, vince292007 and a team as code owners December 17, 2024 06:26
Copy link

changeset-bot bot commented Dec 17, 2024

⚠️ No Changeset found

Latest commit: d9ef96a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Dec 17, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

playground/src/views/examples/ellipsis/index.vue

Oops! Something went wrong! :(

ESLint: 9.16.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/node_modules/@vben/eslint-config/dist/index.mjs' imported from /eslint.config.mjs
at finalizeResolution (node:internal/modules/esm/resolve:257:11)
at moduleResolve (node:internal/modules/esm/resolve:914:10)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

Walkthrough

This pull request introduces documentation for the new EllipsisText component in the Vben Admin project. The changes include adding a sidebar entry in the Chinese configuration, creating a new documentation file for the component, and providing multiple demonstration examples of its usage. Additionally, a minor modification was made to the doc-button.vue file to improve URL handling when linking to documentation pages.

Changes

File Change Summary
docs/.vitepress/config/zh.mts Added new sidebar item for "EllipsisText 省略文本"
docs/src/components/common-ui/vben-api-component.md Updated with new API section and detailed props table
docs/src/components/common-ui/vben-ellipsis-text.md New documentation file for EllipsisText component
docs/src/demos/vben-ellipsis-text/* Added demo components showcasing different EllipsisText usage
playground/src/views/examples/doc-button.vue Modified URL construction logic to append .html extension
playground/src/views/examples/ellipsis/index.vue Added DocButton to link to EllipsisText documentation
playground/src/views/examples/form/basic.vue Minor styling adjustment to DocButton

Assessment against linked issues

Objective Addressed Explanation
Ensure navigation links do not return 404 errors when accessed directly (#[5155])
Update documentation to include new components and their usage (#[5155])

Possibly related PRs

Suggested labels

chore

Suggested reviewers

  • vince292007
  • anncwb

Poem

🐰 A rabbit's tale of text so neat,
Ellipsis dancing, making content sweet
Lines truncated with elegant grace
Expanding stories in a compact space
Documentation blooms, clear and bright! 📜✨


📜 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 d0696db and d9ef96a.

📒 Files selected for processing (1)
  • playground/src/views/examples/ellipsis/index.vue (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • playground/src/views/examples/ellipsis/index.vue

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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. (Beta)
  • @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.

Copy link
Contributor

@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 (9)
docs/src/demos/vben-ellipsis-text/tooltip/index.vue (1)

5-13: Consider adding English translations for better documentation accessibility

While the Chinese text effectively demonstrates the component, consider adding English translations or examples to make the documentation more accessible to a global audience.

 <EllipsisText :max-width="240">
-  住在我心里孤独的 孤独的海怪 痛苦之王 开始厌倦 深海的光 停滞的海浪
+  <!-- Chinese text -->
+  住在我心里孤独的 孤独的海怪 痛苦之王 开始厌倦 深海的光 停滞的海浪
+  <!-- English example -->
+  The lonely sea monster living in my heart, the king of pain, begins to tire of the deep sea light and stagnant waves
   <template #tooltip>
     <div style="text-align: center">
-      《秦皇岛》<br />住在我心里孤独的<br />孤独的海怪 痛苦之王<br />开始厌倦
-      深海的光 停滞的海浪
+      <!-- Chinese text -->
+      《秦皇岛》<br />住在我心里孤独的<br />孤独的海怪 痛苦之王<br />开始厌倦
+      深海的光 停滞的海浪
+      <!-- English translation -->
+      "Qinhuangdao"<br />The lonely sea monster<br />living in my heart, the king of pain<br />begins to tire
+      of the deep sea light and stagnant waves
     </div>
playground/src/views/examples/doc-button.vue (1)

10-16: Consider enhancing URL handling and documentation

The URL handling logic is good, but could be more robust and better documented.

-  // 如果没有.html,打开页面时可能会出现404
-  const path =
-    VBEN_DOC_URL +
-    (props.path.toLowerCase().endsWith('.html')
-      ? props.path
-      : `${props.path}.html`);
-  openWindow(path);
+  // Prevent 404 errors by ensuring .html extension
+  // 如果没有.html,打开页面时可能会出现404
+  const normalizedPath = props.path.trim().toLowerCase();
+  const documentPath = normalizedPath.endsWith('.html') 
+    ? props.path
+    : `${props.path}.html`;
+  openWindow(`${VBEN_DOC_URL}${documentPath}`);
docs/src/demos/vben-ellipsis-text/line/index.vue (2)

4-6: Consider improving text content organization and documentation

The demo effectively shows the component functionality, but the text content could be better organized and documented.

-const text = `
-Vben Admin 是一个基于 Vue3.0、Vite、 TypeScript 的后台解决方案,目标是为开发中大型项目提供开箱即用的解决方案。包括二次封装组件、utils、hooks、动态菜单、权限校验、多主题配置、按钮级别权限控制等功能。项目会使用前端较新的技术栈,可以作为项目的启动模版,以帮助你快速搭建企业级中后台产品原型。也可以作为一个示例,用于学习 vue3、vite、ts 等主流技术。该项目会持续跟进最新技术,并将其应用在项目中。Vben Admin 是一个基于 Vue3.0、Vite、 TypeScript 的后台解决方案,目标是为开发中大型项目提供开箱即用的解决方案。包括二次封装组件、utils、hooks、动态菜单、权限校验、多主题配置、按钮级别权限控制等功能。项目会使用前端较新的技术栈,可以作为项目的启动模版,以帮助你快速搭建企业级中后台产品原型。也可以作为一个示例,用于学习 vue3、vite、ts 等主流技术。该项目会持续跟进最新技术,并将其应用在项目中。Vben Admin 是一个基于 Vue3.0、Vite、 TypeScript 的后台解决方案,目标是为开发中大型项目提供开箱即用的解决方案。包括二次封装组件、utils、hooks、动态菜单、权限校验、多主题配置、按钮级别权限控制等功能。项目会使用前端较新的技术栈,可以作为项目的启动模版,以帮助你快速搭建企业级中后台产品原型。也可以作为一个示例,用于学习 vue3、vite、ts 等主流技术。该项目会持续跟进最新技术,并将其应用在项目中。Vben Admin 是一个基于 Vue3.0、Vite、 TypeScript 的后台解决方案,目标是为开发中大型项目提供开箱即用的解决方案。包括二次封装组件、utils、hooks、动态菜单、权限校验、多主题配置、按钮级别权限控制等功能。项目会使用前端较新的技术栈,可以作为项目的启动模版,以帮助你快速搭建企业级中后台产品原型。也可以作为一个示例,用于学习 vue3、vite、ts 等主流技术。该项目会持续跟进最新技术,并将其应用在项目中。
-`;
+// Sample text demonstrating EllipsisText behavior with long content
+const text = {
+  zh: `Vben Admin 是一个基于 Vue3.0、Vite、 TypeScript 的后台解决方案...`, // Keep original text
+  en: `Vben Admin is a Vue 3.0, Vite, and TypeScript-based backend solution...` // Add English version
+};

Also consider adding a comment explaining the purpose of the 500px max-width in the template:

-  <EllipsisText :max-width="500">{{ text }}</EllipsisText>
+  <!-- Set max-width to 500px to demonstrate text truncation behavior -->
+  <EllipsisText :max-width="500">{{ text.zh }}</EllipsisText>

9-10: Consider adding responsive max-width handling

The fixed max-width might not work well across different screen sizes.

-  <EllipsisText :max-width="500">{{ text }}</EllipsisText>
+  <div class="demo-container">
+    <EllipsisText :max-width="maxWidth">{{ text }}</EllipsisText>
+  </div>

+<style scoped>
+.demo-container {
+  width: 100%;
+  max-width: 500px;
+}
+</style>
docs/src/components/common-ui/vben-ellipsis-text.md (2)

33-45: Props documentation needs enhancement

Consider the following improvements to the Props table:

  • Add type information for tooltipOverlayStyle (currently shows CSSProperties)
  • Clarify the format for maxWidth when using string values (e.g., specify valid CSS units)
  • Add examples for color values in tooltipBackgroundColor and tooltipColor

48-50: Events table could be more descriptive

Consider enhancing the expandChange event description to include:

  • When exactly this event is triggered
  • The meaning of the isExpand parameter
  • Example usage
docs/src/demos/vben-ellipsis-text/expand/index.vue (2)

4-6: Consider simplifying the demo text

The current text is very long and contains repeated content. Consider using a shorter, more focused example that still demonstrates the component's functionality effectively.

-const text = `
-Vben Admin 是一个基于 Vue3.0、Vite、 TypeScript 的后台解决方案,目标是为开发中大型项目提供开箱即用的解决方案。包括二次封装组件、utils、hooks、动态菜单、权限校验、多主题配置、按钮级别权限控制等功能。项目会使用前端较新的技术栈,可以作为项目的启动模版,以帮助你快速搭建企业级中后台产品原型。也可以作为一个示例,用于学习 vue3、vite、ts 等主流技术。该项目会持续跟进最新技术,并将其应用在项目中。[repeated content...]
-`;
+const text = `
+Vben Admin 是一个基于 Vue3.0、Vite、 TypeScript 的后台解决方案,目标是为开发中大型项目提供开箱即用的解决方案。包括二次封装组件、utils、hooks、动态菜单、权限校验、多主题配置、按钮级别权限控制等功能。项目会使用前端较新的技术栈,可以作为项目的启动模版,以帮助你快速搭建企业级中后台产品原型。也可以作为一个示例,用于学习 vue3、vite、ts 等主流技术。该项目会持续跟进最新技术,并将其应用在项目中。
+`;

9-9: Consider adding more props for demonstration

The current example only demonstrates the line and expand props. Consider showcasing more props like tooltipMaxWidth or placement to make the demo more comprehensive.

docs/src/components/common-ui/vben-api-component.md (1)

Line range hint 126-146: LGTM! Well-structured API documentation.

The API documentation is comprehensive and well-organized. A few minor suggestions to enhance readability:

  1. Consider grouping related props together (e.g., field mapping props, event-related props)
  2. Add examples for complex prop types like beforeFetch and afterFetch

Consider adding the following sections to enhance the documentation:

 ## API
 
 ### Props
+
+#### Field Mapping Props
 | 属性名 | 描述 | 类型 | 默认值 |
 | --- | --- | --- | --- |
-| component | 欲包装的组件 | `Component` | - |
-| numberToString | 是否将value从数字转为string | `boolean` | `false` |
-| api | 获取数据的函数 | `(arg?: any) => Promise<OptionsItem[] \| Record<string, any>>` | - |
-| params | 传递给api的参数 | `Record<string, any>` | - |
 | resultField | 从api返回的结果中提取options数组的字段名 | `string` | - |
 | labelField | label字段名 | `string` | `label` |
 | childrenField | 子级数据字段名,需要层级数据的组件可用 | `string` | `` |
 | valueField | value字段名 | `string` | `value` |
+
+#### Component Configuration Props
+| 属性名 | 描述 | 类型 | 默认值 |
+| --- | --- | --- | --- |
+| component | 欲包装的组件 | `Component` | - |
 | optionsPropName | 组件接收options数据的属性名称 | `string` | `options` |
 | modelPropName | 组件的双向绑定属性名,默认为modelValue。部分组件可能为value | `string` | `modelValue` |
+
+#### Data Fetching Props
+| 属性名 | 描述 | 类型 | 默认值 |
+| --- | --- | --- | --- |
+| api | 获取数据的函数 | `(arg?: any) => Promise<OptionsItem[] \| Record<string, any>>` | - |
+| params | 传递给api的参数 | `Record<string, any>` | - |
 | immediate | 是否立即调用api | `boolean` | `true` |
 | alwaysLoad | 每次`visibleEvent`事件发生时都重新请求数据 | `boolean` | `false` |
 | beforeFetch | 在api请求之前的回调函数 | `AnyPromiseFunction<any, any>` | - |
 | afterFetch | 在api请求之后的回调函数 | `AnyPromiseFunction<any, any>` | - |
+
+### Examples
+
+#### Using beforeFetch and afterFetch
+
+```ts
+const beforeFetch = async (params: any) => {
+  // Modify params before API call
+  return params;
+};
+
+const afterFetch = async (data: any) => {
+  // Process data after API call
+  return data;
+};
+```
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 593916d and d0696db.

📒 Files selected for processing (9)
  • docs/.vitepress/config/zh.mts (1 hunks)
  • docs/src/components/common-ui/vben-api-component.md (1 hunks)
  • docs/src/components/common-ui/vben-ellipsis-text.md (1 hunks)
  • docs/src/demos/vben-ellipsis-text/expand/index.vue (1 hunks)
  • docs/src/demos/vben-ellipsis-text/line/index.vue (1 hunks)
  • docs/src/demos/vben-ellipsis-text/tooltip/index.vue (1 hunks)
  • playground/src/views/examples/doc-button.vue (1 hunks)
  • playground/src/views/examples/ellipsis/index.vue (1 hunks)
  • playground/src/views/examples/form/basic.vue (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • playground/src/views/examples/form/basic.vue
🔇 Additional comments (2)
playground/src/views/examples/ellipsis/index.vue (1)

18-20: LGTM! Good addition of documentation link

The DocButton is well-placed in the extra slot of the Page component, providing easy access to the component documentation.

docs/.vitepress/config/zh.mts (1)

189-192: LGTM! Properly structured sidebar entry.

The new EllipsisText component entry follows the existing sidebar patterns and conventions.

@mynetfan mynetfan merged commit 4fe4461 into vbenjs:main Dec 17, 2024
14 checks passed
@mynetfan mynetfan deleted the docs/fix-docs-link branch December 17, 2024 06:41
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.

Bug: 通过项目中的link访问具体某个组件doc会报错404
1 participant