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

0.7.0 #936

Merged
merged 1 commit into from
Jan 22, 2018
Merged

0.7.0 #936

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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

运行 `ng serve` 可以直接修改 `./components` 会立即更新。

> (待开发)若修改DEMO代码,需要额外运行一次 `node scripts/generate-site button` 表示重新生成 button 所有DEMO代码。
> 若修改DEMO代码,需要额外运行一次 `node scripts/generate-site button` 表示重新生成 button 所有DEMO代码。

## 测试代码

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"codelyzer": "~4.0.1",
"core-js": "^2.4.1",
"coveralls": "^2.13.1",
"highlight.js": "^9.12.0",
"intl": "^1.2.5",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
import * as Prism from 'prismjs';
import 'prismjs/components/prism-typescript';

@Component({
selector: 'nz-highlight',
Expand All @@ -18,7 +19,7 @@ export class NzHighlightComponent implements OnInit {
}

set nzCode(value: string) {
this._code = (Prism as any).highlight(value, (Prism.languages as any).javascript);
this._code = (Prism as any).highlight(value, (Prism.languages as any).typescript);
}

constructor() {
Expand Down
39 changes: 0 additions & 39 deletions scripts/_site/src/app/share/nz-markdown/nz-markdown.component.ts

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/_site/src/app/share/nz-markdown/nz-markdown.module.ts

This file was deleted.

32 changes: 16 additions & 16 deletions scripts/_site/src/style/highlight.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
font-family: "Lucida Console", Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
}

code[class*="language-"],
pre[class*="language-"] {
code[class*="lang-"],
pre[class*="lang-"] {
color: black;
background: none;
font-family: "Lucida Console", Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
Expand All @@ -41,43 +41,43 @@
hyphens: none;
}

pre[class*="language-"]::-moz-selection,
pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection,
code[class*="language-"] ::-moz-selection {
pre[class*="lang-"]::-moz-selection,
pre[class*="lang-"] ::-moz-selection,
code[class*="lang-"]::-moz-selection,
code[class*="lang-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}

pre[class*="language-"]::selection,
pre[class*="language-"] ::selection,
code[class*="language-"]::selection,
code[class*="language-"] ::selection {
pre[class*="lang-"]::selection,
pre[class*="lang-"] ::selection,
code[class*="lang-"]::selection,
code[class*="lang-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}

@media print {
code[class*="language-"],
pre[class*="language-"] {
code[class*="lang-"],
pre[class*="lang-"] {
text-shadow: none;
}
}

/* Code blocks */
pre[class*="language-"] {
pre[class*="lang-"] {
padding: 12px 20px;
margin: 16px 0;
overflow: auto;
}

:not(pre) > code[class*="language-"],
pre[class*="language-"] {
:not(pre) > code[class*="lang-"],
pre[class*="lang-"] {
background: #f2f4f5;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
:not(pre) > code[class*="lang-"] {
padding: .1em;
border-radius: .3em;
white-space: normal;
Expand Down
59 changes: 33 additions & 26 deletions scripts/generate-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,31 @@ const generateDemo = require('./utils/generate-demo');
const generateDocs = require('./utils/generate-docs');
const generateRoutes = require('./utils/generate-routes');
const getMeta = require('./utils/get-meta');
const status = process.argv[2] || 'sync';

const target = process.argv[2];
const isSyncSpecific = target && (target !== 'init');
// 创建site文件夹
const showCasePath = path.resolve(__dirname, '../site');

if (status === 'init') {
if (!target) {
wrench.rmdirSyncRecursive(`${showCasePath}/src`, true);
wrench.copyDirSyncRecursive(path.resolve(__dirname, '_site/src'), `${showCasePath}/src`);
} else if (target === 'init') {
wrench.rmdirSyncRecursive(`${showCasePath}`, true);
wrench.copyDirSyncRecursive(path.resolve(__dirname, '_site'), `${showCasePath}`);
} else {
wrench.rmdirSyncRecursive(`${showCasePath}/src`, true);
wrench.copyDirSyncRecursive(path.resolve(__dirname, '_site/src'), `${showCasePath}/src`);
// wrench.rmdirSyncRecursive(`${showCasePath}/node_modules/ng-zorro-antd`, true);
// wrench.copyDirSyncRecursive(path.resolve(__dirname, '../components'), `${showCasePath}/node_modules/ng-zorro-antd`);
wrench.rmdirSyncRecursive(`${showCasePath}/src/app/${target}`, true);
}

const showCaseTargetPath = `${showCasePath}/src/app/`;
// 读取components文件夹
const rootPath = path.resolve(__dirname, '../components');
const rootDir = fs.readdirSync(rootPath);
const componentsMap = {};
rootDir.forEach(componentName => {
if (isSyncSpecific) {
if (componentName !== target) {
return;
}
}
const componentDirPath = path.join(rootPath, componentName);
if (componentName === 'style' || componentName === 'core' || componentName === 'locale') {
return;
Expand Down Expand Up @@ -73,23 +77,26 @@ rootDir.forEach(componentName => {
}
});

// 读取docs文件夹
const docsPath = path.resolve(__dirname, '../docs');
const docsDir = fs.readdirSync(docsPath);
let docsMap = {};
let docsMeta = {};
docsDir.forEach(doc => {
const name = nameWithoutSuffixUtil(doc);
docsMap[name] = {
zh: fs.readFileSync(path.join(docsPath, `${name}.zh-CN.md`)),
en: fs.readFileSync(path.join(docsPath, `${name}.en-US.md`))
};
docsMeta[name] = {
zh: getMeta(docsMap[name].zh),
en: getMeta(docsMap[name].en)
}
});
if (!isSyncSpecific) {
// 读取docs文件夹
const docsPath = path.resolve(__dirname, '../docs');
const docsDir = fs.readdirSync(docsPath);
let docsMap = {};
let docsMeta = {};
docsDir.forEach(doc => {
const name = nameWithoutSuffixUtil(doc);
docsMap[name] = {
zh: fs.readFileSync(path.join(docsPath, `${name}.zh-CN.md`)),
en: fs.readFileSync(path.join(docsPath, `${name}.en-US.md`))
};
docsMeta[name] = {
zh: getMeta(docsMap[name].zh),
en: getMeta(docsMap[name].en)
}
});

generateDocs(showCaseTargetPath, docsMap);
generateRoutes(showCaseTargetPath, componentsMap, docsMeta);
}

generateDocs(showCaseTargetPath, docsMap);

generateRoutes(showCaseTargetPath, componentsMap, docsMeta);