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(module:*): debug demos #7408

Merged
merged 1 commit into from
Sep 26, 2022
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
15 changes: 15 additions & 0 deletions components/progress/demo/dashboard-layout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
order: 8
debug: true
title:
zh-CN: 仪表盘样式
en-US: Dashboard Layout
---

## zh-CN

仪表盘展示样式

## en-US

Dashboard layout
10 changes: 10 additions & 0 deletions components/progress/demo/dashboard-layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'nz-demo-progress-dashboard-layout',
template: `<nz-progress [nzPercent]="1" nzType="dashboard" [nzGapDegree]="90"></nz-progress>
<nz-progress [nzPercent]="75" nzType="dashboard" [nzGapDegree]="180"></nz-progress>
<nz-progress [nzPercent]="75" nzType="dashboard" [nzGapDegree]="295"></nz-progress>
<nz-progress [nzPercent]="1" nzType="dashboard" [nzGapDegree]="340"></nz-progress>`
})
export class NzDemoProgressDashboardLayoutComponent {}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"node": "^12.20.0 || ^14.15.0 || >=16.10.0"
},
"scripts": {
"start": "gulp start:dev",
"start": "NODE_ENV=development gulp start:dev",
"test": "ng test --no-watch --no-progress --browsers=ChromeHeadlessCI --code-coverage",
"test:watch": "gulp test:watch --tags",
"test:schematics": "gulp build:schematics && gulp test:schematics",
Expand Down
17 changes: 16 additions & 1 deletion scripts/site/generate-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,22 @@ function generate(target) {
// handle components->${component}->demo folder
const demoDirPath = path.join(componentDirPath, 'demo');
const demoMap = {};
const debugDemos = new Set();

if (fs.existsSync(demoDirPath)) {
const demoDir = fs.readdirSync(demoDirPath);
demoDir.forEach(demo => {
if (/.md$/.test(demo)) {
const nameKey = nameWithoutSuffixUtil(demo);
const demoMarkDownFile = fs.readFileSync(path.join(demoDirPath, demo));
demoMap[nameKey] = parseDemoMdUtil(demoMarkDownFile);
const demoMeta = parseDemoMdUtil(demoMarkDownFile);

if (demoMeta.meta.debug && process.env.NODE_ENV !== 'development') {
debugDemos.add(nameKey);
return;
}

demoMap[nameKey] = demoMeta;
demoMap[nameKey]['name'] = `NzDemo${camelCase(capitalizeFirstLetter(componentName))}${camelCase(
capitalizeFirstLetter(nameKey)
)}Component`;
Expand All @@ -80,12 +89,18 @@ function generate(target) {
demoMap[nameKey].meta.iframe
);
}

if (/.ts$/.test(demo)) {
const nameKey = nameWithoutSuffixUtil(demo);
if (debugDemos.has(nameKey)) {
return;
}

demoMap[nameKey].ts = String(fs.readFileSync(path.join(demoDirPath, demo)));
// copy ts file to site->${component} folder
fs.writeFileSync(path.join(showCaseComponentPath, demo), demoMap[nameKey].ts);
}

if (demo === 'module') {
const data = String(fs.readFileSync(path.join(demoDirPath, demo)));
fs.writeFileSync(path.join(showCaseComponentPath, 'module.ts'), data);
Expand Down
2 changes: 1 addition & 1 deletion scripts/site/utils/get-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = function getMeta(file) {
.reduce((a, b) => [...a, ...b], []);
let description = '';
if (meta.subtitle) {
description = `Angular ${meta.subtitle}组件,`;
description = `Angular ${meta.subtitle} 组件,`;
} else if (meta.title) {
description = `Angular ${meta.title} Component, `;
}
Expand Down