Skip to content

Commit

Permalink
chore(module:*): allow debug demos under development (#7408)
Browse files Browse the repository at this point in the history
fix: fix implementation

chore: remove Chinese comment
  • Loading branch information
hullis committed Sep 26, 2022
1 parent dda0e6d commit d14f20d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
15 changes: 15 additions & 0 deletions components/progress/demo/dashboard-layout.md
@@ -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
@@ -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
Expand Up @@ -7,7 +7,7 @@
"node": "^14.15.5 || ^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
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
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

0 comments on commit d14f20d

Please sign in to comment.