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(common): update design docs #1658

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions site/plugin-tdoc/md-to-vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function customRender({ source, file, md }: any) {
};

// md filename
const reg = file.match(/src\/(\w+-?\w+)\/(\w+-?\w+)\.md/);
const reg = file.match(/src\/(\S*)(?=\/\S*.md)/);
const componentName = reg && reg[1];

// split md
Expand All @@ -79,9 +79,15 @@ function customRender({ source, file, md }: any) {

if (pageData.isComponent) {
mdSegment.demoMd = md.render.call(md, `${demoMd.replace(/<!--[\s\S]+?-->/g, '')}`).html;
mdSegment.apiMd = md.render.call(md, `${pageData.toc ? '[toc]\n' : ''}${apiMd.replace(/<!--[\s\S]+?-->/g, '')}`).html;
mdSegment.apiMd = md.render.call(
md,
`${pageData.toc ? '[toc]\n' : ''}${apiMd.replace(/<!--[\s\S]+?-->/g, '')}`,
).html;
} else {
mdSegment.docMd = md.render.call(md, `${pageData.toc ? '[toc]\n' : ''}${content.replace(/<!--[\s\S]+?-->/g, '')}`).html;
mdSegment.docMd = md.render.call(
md,
`${pageData.toc ? '[toc]\n' : ''}${content.replace(/<!--[\s\S]+?-->/g, '')}`,
).html;
}

// 设计指南内容 不展示 design Tab 则不解析
Expand Down
21 changes: 11 additions & 10 deletions site/plugin-tdoc/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ import mdToVue from './md-to-vue';

let demoCodesImports: Record<string, string> = {};


export default {
before({ source, file, md }: any) {
const resouceDir = path.dirname(file);
const reg = file.match(/src\/(\w+-?\w+)\/\w+-?\w+\.md/);
const reg = file.match(/src\/(\S*)(?=\/\S*.md)/);
const name = reg && reg[1];
demoCodesImports = {};

// 增加渲染规则
md.renderer.rules.html_block = function (tokens: string, idx: number) {
const { content } = tokens[idx];
if (content.startsWith('<img') && content.indexOf('qrcode') === -1) {
return '';
return '';
}

return content;
Expand All @@ -29,10 +28,10 @@ export default {
console.log('\x1B[36m%s\x1B[0m', `${name} 组件需要实现 _example/${demoDirName} 示例!`);
return '\n<h3>DEMO (🚧建设中)...</h3>';
}
const wxml = fs.readFileSync(path.resolve(demoPath, 'index.wxml'), { encoding: 'utf-8'});
const js = fs.readFileSync(path.resolve(demoPath, 'index.js'), { encoding: 'utf-8'});
const css = fs.readFileSync(path.resolve(demoPath, 'index.wxss'), { encoding: 'utf-8'});
const json = fs.readFileSync(path.resolve(demoPath, 'index.json'), { encoding: 'utf-8'});
const wxml = fs.readFileSync(path.resolve(demoPath, 'index.wxml'), { encoding: 'utf-8' });
const js = fs.readFileSync(path.resolve(demoPath, 'index.js'), { encoding: 'utf-8' });
const css = fs.readFileSync(path.resolve(demoPath, 'index.wxss'), { encoding: 'utf-8' });
const json = fs.readFileSync(path.resolve(demoPath, 'index.json'), { encoding: 'utf-8' });

return `
<td-code-block panel="WXML">
Expand All @@ -43,13 +42,15 @@ export default {
<pre slot="CSS" lang="css">${encodeURIComponent(css)}</pre>

<pre slot="JSON" lang="javascript">${encodeURIComponent(json)}</pre>
</td-code-block>`
</td-code-block>`;
});

return source;
},
render({ source, file, md }: { source: string, file: string, md: any }) {
const demoCodesDefsStr = Object.keys(demoCodesImports).map((key) => demoCodesImports[key]).join(';\n');
render({ source, file, md }: { source: string; file: string; md: any }) {
const demoCodesDefsStr = Object.keys(demoCodesImports)
.map((key) => demoCodesImports[key])
.join(';\n');
const demoCodesInstallStr = Object.keys(demoCodesImports).join(',');

const sfc = mdToVue({
Expand Down
2 changes: 1 addition & 1 deletion src/_common
Submodule _common updated 60 files
+4 −0 .gitignore
+75 −0 docs/miniprogram/_design/ActionSheet.md
+86 −0 docs/miniprogram/_design/Button.md
+59 −0 docs/miniprogram/_design/Checkbox.md
+69 −0 docs/miniprogram/_design/Dialog.md
+55 −0 docs/miniprogram/_design/Divider.md
+61 −0 docs/miniprogram/_design/Drawer.md
+88 −0 docs/miniprogram/_design/Fab.md
+61 −0 docs/miniprogram/_design/Image.md
+45 −0 docs/miniprogram/_design/ImageViewer.md
+59 −0 docs/miniprogram/_design/PullDownRefresh.md
+64 −0 docs/miniprogram/_design/Radio.md
+62 −0 docs/miniprogram/_design/Slider.md
+83 −0 docs/miniprogram/_design/TabBar.md
+114 −0 docs/miniprogram/_design/Tabs.md
+38 −0 docs/miniprogram/_design/gen-design-docs.js
+73 −0 docs/miniprogram/design/action-sheet.md
+84 −0 docs/miniprogram/design/button.md
+57 −0 docs/miniprogram/design/checkbox.md
+67 −0 docs/miniprogram/design/dialog.md
+53 −0 docs/miniprogram/design/divider.md
+59 −0 docs/miniprogram/design/drawer.md
+86 −0 docs/miniprogram/design/fab.md
+43 −0 docs/miniprogram/design/image-viewer.md
+59 −0 docs/miniprogram/design/image.md
+57 −0 docs/miniprogram/design/pull-down-refresh.md
+62 −0 docs/miniprogram/design/radio.md
+60 −0 docs/miniprogram/design/slider.md
+81 −0 docs/miniprogram/design/tab-bar.md
+112 −0 docs/miniprogram/design/tabs.md
+420 −0 docs/miniprogram/overview.md
+80 −0 docs/mobile/_design/按钮Button.md
+2 −0 docs/mobile/design/button.md
+9 −3 docs/web/api/select.md
+5 −3 js/color-picker/gradient.ts
+3 −2 js/date-picker/format.ts
+8 −7 js/date-picker/utils.ts
+144 −143 js/global-config/locale/ar_KW.ts
+145 −144 js/global-config/locale/en_US.ts
+147 −146 js/global-config/locale/ja_JP.ts
+146 −145 js/global-config/locale/ko_KR.ts
+147 −146 js/global-config/locale/zh_CN.ts
+4 −2 js/input-number/large-number.ts
+8 −6 js/input-number/number.ts
+1 −1 js/loading/circle-adapter.ts
+4 −3 js/table/tree-store.ts
+5 −3 js/tree/tree-node-model.ts
+10 −7 js/tree/tree-node.ts
+12 −8 js/tree/tree-store.ts
+7 −5 js/upload/main.ts
+2 −1 js/upload/xhr.ts
+3 −2 js/utils/calcTextareaHeight.ts
+12 −2 js/utils/getScrollbarWidth.ts
+21 −6 js/utils/helper.ts
+1 −0 js/utils/observe.ts
+1 −1 js/watermark/generateBase64Url.ts
+3 −3 package.json
+5 −5 style/web/components/button/_index.less
+0 −1 style/web/components/dialog/_index.less
+4 −4 style/web/components/tabs/_index.less