Skip to content

Commit 2f7c7df

Browse files
authored
增加内部public变量、方法检测脚本,修正处理文档链接的逻辑
1 parent b7582e1 commit 2f7c7df

File tree

14 files changed

+103
-12
lines changed

14 files changed

+103
-12
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ before_script:
3131
- # ./build/scripts/sauce_connect_setup.sh
3232

3333
script:
34+
- node build/scripts/check-demo-import.js
35+
- node build/scripts/check-public-variables.js
3436
- gulp ensure-url-matches-path
3537
- gulp generate-demo-info
3638
- gulp build:jigsaw
37-
- node build/scripts/check-demo-import.js
3839
- ng test jigsaw --code-coverage false --watch false
3940
- # cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
4041
- sh build/scripts/doc-generator/generate.sh ./temp/doc/
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
let hasError = false;
5+
checkAll();
6+
if (hasError) {
7+
process.exit(1);
8+
} else {
9+
console.error(`Everything's fine!`);
10+
}
11+
12+
// checkPublicVariables('D:\\Codes\\jigsaw\\src\\jigsaw\\mobile-components\\alert\\alert.ts');
13+
14+
function checkAll(folder) {
15+
const cmpHome = path.resolve(`${__dirname}/../../src/jigsaw`);
16+
const cmpFolders = fs.readdirSync(cmpHome);
17+
cmpFolders.forEach(cmpFolder => {
18+
const pathname = path.join(cmpHome, cmpFolder);
19+
const stat = fs.lstatSync(pathname);
20+
if (stat.isDirectory()) {
21+
checkSourceFiles(pathname);
22+
}
23+
});
24+
}
25+
26+
function checkSourceFiles(sourceFolder) {
27+
const files = fs.readdirSync(sourceFolder);
28+
files.forEach(file => {
29+
const pathname = path.join(sourceFolder, file);
30+
const stat = fs.lstatSync(pathname);
31+
if (stat.isDirectory()) {
32+
checkSourceFiles(pathname)
33+
} else {
34+
checkPublicVariables(pathname);
35+
}
36+
});
37+
}
38+
39+
function checkPublicVariables(srcPath) {
40+
if (!srcPath.match(/.+\.ts$/i)) {
41+
return;
42+
}
43+
44+
console.log(`Checking ${srcPath} ...`);
45+
const source = fs.readFileSync(srcPath).toString();
46+
47+
const vars = source.match(/\spublic\s+(static\s+)?_\$?\w+/g);
48+
if (!vars) {
49+
return;
50+
}
51+
52+
vars.forEach(variable => {
53+
const fixed = variable.replace(/\$/g, '\\$');
54+
const reg = new RegExp(`[\\s\\S]*\\/\\*\\*([\\s\\S]*?)\\*\\/\\s*(@\\w+.*\\s*)?${fixed}\\b`);
55+
const match = source.match(reg);
56+
if (!match || match[1].indexOf('@internal') === -1) {
57+
const name = variable.replace(/public\s*(static\s+)?/, '').trim();
58+
error(`Error: variable "${name}" has no @internal flag!`);
59+
}
60+
});
61+
}
62+
63+
function error(msg) {
64+
console.error(msg);
65+
hasError = true;
66+
}
67+
68+

src/app/demo/pc/dialog/absolute-position/demo.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@ export class DialogAbsolutePositionDemoComponent {
6767
// ignore the following lines, they are not important to this demo
6868
// ====================================================================
6969
summary: string = '这个demo介绍了弹出对话框四个方位弹出的绝对位置:靠上、靠左、靠右、考下';
70-
description: string = '[这里详细介绍了`PopupService`,请仔细阅读](/#/pc/popup/introduce)。';
70+
description: string = '这里[详细介绍](#/pc/popup/introduce)了`PopupService`,请仔细阅读。';
7171
}

src/app/markdown/markdown.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ export class JigsawMarkdown extends AbstractJigsawComponent implements OnInit {
5858
markdown = marked(markdown.trim());
5959

6060
// redirect internal doc link to the ued site
61-
markdown = markdown.replace(/<a href="\/(components\/api\/\w+?\/.*?)">/g,
62-
`<a href="${InternalUtils.uedSiteHost}/$1" target="_blank">`);
63-
markdown = markdown.replace(/\$uedHost/g, InternalUtils.uedSiteHost);
61+
markdown = markdown.replace(/<a\s+href="(\/components\/api\/.*?)"/g,
62+
`<a href="javascript:top.location.hash='$1'" target="_self"`);
6463

6564
// add class to raise the css priority
6665
markdown = markdown.replace(/<(\w+)(\s|>)/g, (found, tag, border) => {

src/jigsaw/common/core/data/graph-data.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ export abstract class AbstractGraphData extends TableDataBase {
123123
return this._fromObject(data);
124124
}
125125

126+
/**
127+
* @internal
128+
*/
126129
public _fromObject(data: any): AbstractGraphData {
127130
if (!AbstractGraphData.isGraphData(data)) {
128131
throw new Error('invalid graph data, need at least a "data" property which type is Array!');

src/jigsaw/common/core/utils/internal-utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ import {TranslateHelper} from "./translate-helper";
77
*/
88
// @dynamic
99
export class InternalUtils {
10-
public static uedSiteHost = 'http://rdk.zte.com.cn';
11-
12-
public static _uniqueIdIndex = 0;
13-
public static _defaultPrefix = '__unique_id__';
10+
private static _uniqueIdIndex = 0;
11+
private static _defaultPrefix = '__unique_id__';
1412

1513
/*
1614
* 初始化对象标识,转化为数组

src/jigsaw/common/service/popup.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export enum PopupEffect {
3131
* 用于控制弹出视图的各种参数,包括是否模态、弹出位置、视图尺寸、弹出动画等等,`PopupService`能够覆盖所有弹出场景,
3232
* 很大程度上得益于这个参数的强大扩展性,熟悉这个参数的各个属性对是否能够用好`PopupService`有着决定性的影响。
3333
*
34-
* [这个demo](/components/dialog/demo#popup-option)详细的说明了如何使用这个对象。
34+
* [这个demo]($demo=dialog/popup-option)详细的说明了如何使用这个对象。
3535
*/
3636
export class PopupOptions {
3737
/**

src/jigsaw/mobile-components/icon/icon.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import {CommonUtils} from "../../common/core/utils/common-utils";
1919
}
2020
})
2121
export class JigsawMobileIcon extends AbstractJigsawComponent {
22+
/**
23+
* @internal
24+
*/
2225
public _$secureUrl;
2326
private _href: string = 'javascript:void(0);';
2427

src/jigsaw/mobile-components/tabs/tab.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ export class JigsawMobileTab extends AbstractJigsawComponent implements AfterVie
120120
@Input()
121121
public editable: boolean;
122122

123+
/**
124+
* @internal
125+
*/
123126
public _$headless: boolean = false;
124127

125128
/**

src/jigsaw/mobile-components/tag/tag.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ export class JigsawMobileTag extends AbstractJigsawComponent implements OnInit {
5151
public _state: string;
5252

5353
constructor(private _renderer: Renderer2,
54+
/**
55+
* @internal
56+
*/
5457
public _elementRef: ElementRef) {
5558
super();
5659
}

0 commit comments

Comments
 (0)