Skip to content

Commit 9cb9d5a

Browse files
committed
build: 增加 jsdoc 描述來表示這是自動生成出來的列表,防止誤編輯,並且提示原始來源
1 parent 6ce6ded commit 9cb9d5a

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

packages/@lazy-cjk/jp-table-comparison/test/script/build-cache.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { IPLUS_TABLE, ITeachKanjiComparison, IKanjiComparisonTable } from '../..
1313
import { array_unique_overwrite, array_unique } from 'array-hyper-unique';
1414
import { sortBySlugify } from '@lazy-cjk/sort';
1515
import { compareCaseInsensitive } from '@bluelovers/string-natural-compare/core';
16+
import { lineSplit } from 'crlf-normalize';
1617

1718
const data = _jpTableCmparisonBuild({
1819
PLUS_TABLE,
@@ -34,7 +35,10 @@ const data = _jpTableCmparisonBuild({
3435
sortTable(data.TABLE);
3536
sortTable(data.TABLE_SAFE);
3637

38+
lines.push(printJSDOC(`Code generated from @lazy-cjk/jp-table-comparison/lib/table/core.ts;\nDO NOT EDIT.\n@see {@link ./table/core.ts}`));
3739
lines.push(`export const TABLE: IKanjiComparisonTable = [\n${printTable(data.TABLE).join('\n')}\n];`);
40+
41+
lines.push(printJSDOC(`Code generated from @lazy-cjk/jp-table-comparison/lib/table/core.ts;\nDO NOT EDIT.\n@see {@link ./table/core.ts}`));
3842
lines.push(`export const TABLE_SAFE: IKanjiComparisonTable = [\n${printTable(data.TABLE_SAFE).join('\n')}\n];`);
3943

4044
lines.push(``);
@@ -58,7 +62,10 @@ const data = _jpTableCmparisonBuild({
5862
sortTablePlus(data.PLUS_TABLE);
5963
sortTablePlus(data.PLUS_TABLE_SAFE);
6064

65+
lines.push(printJSDOC(`Code generated from @lazy-cjk/jp-table-comparison/lib/table/core.ts;\nDO NOT EDIT.\n@see {@link ./table/core.ts}`));
6166
lines.push(`export const PLUS_TABLE: IPLUS_TABLE = [\n${printTable(data.PLUS_TABLE).join('\n')}\n];`);
67+
68+
lines.push(printJSDOC(`Code generated from @lazy-cjk/jp-table-comparison/lib/table/core.ts;\nDO NOT EDIT.\n@see {@link ./table/core.ts}`));
6269
lines.push(`export const PLUS_TABLE_SAFE: IPLUS_TABLE = [\n${printTable(data.PLUS_TABLE_SAFE).join('\n')}\n];`);
6370

6471
lines.push(``);
@@ -89,8 +96,10 @@ const data = _jpTableCmparisonBuild({
8996

9097
let re = new RegExp(`[${keys.join('')}]`, 'u');
9198

99+
lines.push(printJSDOC(`Code generated from @lazy-cjk/jp-table-comparison/lib/table/core.ts;\nDO NOT EDIT.\n@see {@link ./table/core.ts}`));
92100
lines.push(`export const _re_table_keys = ${re.toString()};`);
93101

102+
lines.push(printJSDOC(`Code generated from @lazy-cjk/jp-table-comparison/lib/table/core.ts;\nDO NOT EDIT.\n@see {@link ./table/core.ts}`));
94103
lines.push(`export default _re_table_keys`);
95104

96105
lines.push(``);
@@ -109,6 +118,7 @@ const data = _jpTableCmparisonBuild({
109118

110119
lines.push(``);
111120

121+
lines.push(printJSDOC(`Code generated from @lazy-cjk/jp-table-comparison/lib/table/core.ts;\nDO NOT EDIT.\n@see {@link ./table/core.ts}`));
112122
lines.push(`export const _table_keys = [\n${printTable(keys).join('\n')}\n];`);
113123

114124
lines.push(`export default _table_keys`);
@@ -194,3 +204,11 @@ function sortTablePlus(table: IPLUS_TABLE)
194204
return comp(s1[0], s2[0])
195205
})
196206
}
207+
208+
function printJSDOC(msg: string)
209+
{
210+
const c = '\n * ';
211+
212+
return `/**${c}${lineSplit(msg).join(c)}${c}/`
213+
.replace(/\*\s+\/$/, '*/');
214+
}

packages/@lazy-cjk/jp-table-convert/test/script/build-cache.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import assert from 'assert';
88
import emitTsFiles from 'build-ts-file';
99
import { _build_table } from '../../lib/core';
1010
import { ZHJP_TABLE, ZHJP_TABLE_SAFE } from '@lazy-cjk/jp-table-comparison';
11+
import { crlf, lineSplit } from 'crlf-normalize';
1112

1213
const data = _build_table(ZHJP_TABLE, ZHJP_TABLE_SAFE);
1314

@@ -19,9 +20,13 @@ const data = _build_table(ZHJP_TABLE, ZHJP_TABLE_SAFE);
1920

2021
lines.push(`import { ITABLE_MAIN } from './types';`);
2122

23+
lines.push(printJSDOC(`Code generated from @lazy-cjk/jp-table-comparison;\nDO NOT EDIT.\n@see {@link @lazy-cjk/jp-table-comparison}`));
2224
lines.push(`export const TABLE_KEYS = ${printTable(Object.keys(data.TABLE))} as const;`);
2325

26+
lines.push(printJSDOC(`Code generated from @lazy-cjk/jp-table-comparison;\nDO NOT EDIT.\n@see {@link @lazy-cjk/jp-table-comparison}`));
2427
lines.push(`export const TABLE: ITABLE_MAIN = ${printTable(data.TABLE)};`);
28+
29+
lines.push(printJSDOC(`Code generated from @lazy-cjk/jp-table-comparison;\nDO NOT EDIT.\n@see {@link @lazy-cjk/jp-table-comparison}`));
2530
lines.push(`export const TABLE_SAFE: ITABLE_MAIN = ${printTable(data.TABLE_SAFE)};`);
2631

2732
lines.push(``);
@@ -38,3 +43,11 @@ function printTable(table)
3843
{
3944
return JSON.stringify(table, null, `\t`);
4045
}
46+
47+
function printJSDOC(msg: string)
48+
{
49+
const c = '\n * ';
50+
51+
return `/**${c}${lineSplit(msg).join(c)}${c}/`
52+
.replace(/\*\s+\/$/, '*/');
53+
}

0 commit comments

Comments
 (0)