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

Feat: api parser with propFilter #807

Merged
merged 4 commits into from
Aug 5, 2021

Conversation

sdhr27
Copy link
Contributor

@sdhr27 sdhr27 commented Aug 4, 2021

🤔 这个变动的性质是?/ What is the nature of this change?

  • 新特性提交 / New feature
  • bug 修复 / Fix bug
  • 样式优化 / Style optimization
  • 代码风格优化 / Code style optimization
  • 性能优化 / Performance optimization
  • 构建优化 / Build optimization
  • 网站、文档、Demo 改进 / Website, documentation, demo improvements
  • 重构代码或样式 / Refactor code or style
  • 测试相关 / Test related
  • 其他 / Other

🔗 相关 Issue / Related Issue

#513

💡 需求背景和解决方案 / Background or solution

解决问题:api自动生成无法进行propFilter问题。

📝 更新日志 / Changelog

1、添加了apiParser配置项,包含配置ignoreNodeModules、skipPropsWithoutDoc、excludes、propFilter,比如:

export default {
  apiParser: {
    ignoreNodeModules: true,
    skipPropsWithoutDoc: true,
    excludes: ['realtime'],
  },
};

2、过滤HTML标签,且标签优先级高于全局配置,但低于全局配置的propFilter,用法:

<API excludes='["realtime", "addFolder"]' skipPropsWithoutDoc></API>
Language Changelog
🇺🇸 English
🇨🇳 Chinese

@github-actions
Copy link

github-actions bot commented Aug 4, 2021

⚡️ Deploying PR Preview...

@github-actions
Copy link

github-actions bot commented Aug 4, 2021

⚡️ Deploying PR Mobile Preview...

@codecov
Copy link

codecov bot commented Aug 4, 2021

Codecov Report

Merging #807 (1b86e7d) into master (daebdeb) will increase coverage by 0.06%.
The diff coverage is 94.59%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #807      +/-   ##
==========================================
+ Coverage   94.14%   94.21%   +0.06%     
==========================================
  Files         112      112              
  Lines        2493     2522      +29     
  Branches      811      824      +13     
==========================================
+ Hits         2347     2376      +29     
  Misses        142      142              
  Partials        4        4              
Impacted Files Coverage Δ
packages/preset-dumi/src/context.ts 100.00% <ø> (ø)
...ackages/preset-dumi/src/plugins/features/config.ts 100.00% <ø> (ø)
...ckages/preset-dumi/src/transformer/remark/utils.ts 100.00% <ø> (ø)
packages/preset-dumi/src/transformer/remark/api.ts 92.30% <75.00%> (+0.15%) ⬆️
packages/preset-dumi/src/api-parser/index.ts 100.00% <100.00%> (ø)
packages/preset-dumi/src/plugins/features/api.ts 94.44% <100.00%> (+2.77%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update daebdeb...1b86e7d. Read the comment docs.

@PeachScript PeachScript merged commit 6656cac into umijs:master Aug 5, 2021
@PeachScript
Copy link
Member

@sdhr27 同步下对 propFilter 相关代码做的调整:

  1. componentNamefilterOptions 合并成 parseOpts,和最初的版本一致,在 parser 里再做剥离
  2. ignoreNodeModules 改成 skipNodeModules,和其他命名保持一致
  3. excludes 去掉,改用默认的 skipPropsWithName,拿字符串 new RegExp 默认是模糊匹配,可能更常见的用法还是全等过滤
  4. skipNodeModules 合并到 propFilter,相当于 dumi 只对 react-docgen-typescriptpropFilter 做了一层属性扩展,最大限度和上游配置保持一致,给未来 apiParser 扩展其他配置留出空间

所有变更见:9531213

@Gyyi
Copy link

Gyyi commented Sep 23, 2021

请问这样是正确用法吗?

<API src="../../src/charts/baseBar/index.tsx" skipPropsWithName='["option"]'></API>

升级到1.1.29版本,无效

@PeachScript
Copy link
Member

@Gyyi 目前 skipPropsWithName 只支持配置到 config 里,下个版本加上标签级的

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