Skip to content

Commit ebb6a91

Browse files
committed
【feat】产品页模块说明g6结构自动化; review by luox
1 parent 1678640 commit ebb6a91

File tree

144 files changed

+10816
-10575
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+10816
-10575
lines changed

build/jsdocs/classic/docs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"src/common/lang/locales"
6161
]
6262
},
63-
"plugins": ["plugins/markdown"],
63+
"plugins": ["plugins/markdown", "../plugins/moduleCategories"],
6464
"templates": {
6565
"cleverLinks": false,
6666
"monospaceLinks": false,

build/jsdocs/leaflet/docs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"src/leaflet/core/CommontypesConversion"
7878
]
7979
},
80-
"plugins": ["plugins/markdown","../plugins/usage"],
80+
"plugins": ["plugins/markdown","../plugins/usage", "../plugins/moduleCategories"],
8181
"markdown": {
8282
"tags": ["usage"]
8383
},

build/jsdocs/mapboxgl/docs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"src/mapboxgl/core/Util"
6868
]
6969
},
70-
"plugins": ["plugins/markdown","../plugins/usage"],
70+
"plugins": ["plugins/markdown","../plugins/usage", "../plugins/moduleCategories"],
7171
"markdown": {
7272
"tags": ["usage"]
7373
},

build/jsdocs/maplibregl/docs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"src/mapboxgl/core/Util"
6666
]
6767
},
68-
"plugins": ["plugins/markdown", "../plugins/usage"],
68+
"plugins": ["plugins/markdown", "../plugins/usage", "../plugins/moduleCategories"],
6969
"markdown": {
7070
"tags": ["usage"]
7171
},

build/jsdocs/openlayers/docs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"src/openlayers/core/Util"
6868
]
6969
},
70-
"plugins": ["plugins/markdown","../plugins/usage"],
70+
"plugins": ["plugins/markdown","../plugins/usage", "../plugins/moduleCategories"],
7171
"markdown": {
7272
"tags": ["usage"]
7373
},
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const env = require('jsdoc/lib/jsdoc/env');
2+
3+
const globalParams = env.conf.templates;
4+
exports.defineTags = function (dictionary) {
5+
dictionary.defineTag('modulecategory', {
6+
mustHaveValue: true,
7+
mustNotHaveDescription: false,
8+
canHaveType: false,
9+
canHaveName: false,
10+
onTagged: function (doclet, tag) {
11+
doclet.modulecategory = {
12+
globalParams,
13+
category: tag.value,
14+
name: doclet.name,
15+
des_en: doclet.name
16+
};
17+
}
18+
});
19+
};
20+
21+
exports.handlers = {
22+
newDoclet: function (e) {
23+
const modulecategory = e.doclet.modulecategory;
24+
if (modulecategory) {
25+
e.doclet.modulecategory.className = modulecategory.name;
26+
if (!modulecategory.name.startsWith('SuperMap')) {
27+
const matchTag = e.doclet.tags.find(tag => tag.title === 'browsernamespace') || {};
28+
const prefix = matchTag.value || globalParams.namespace;
29+
e.doclet.modulecategory.name = `${prefix}.${modulecategory.name}`;
30+
}
31+
e.doclet.modulecategory.des = (e.doclet.classdesc || '').split('。')[0].replace('<p>', '').replace('类', '');
32+
}
33+
}
34+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"moduleRoots": {
3+
"ol": "SuperMap iClient for OpenLayers",
4+
"L": "SuperMap iClient for Leaflet",
5+
"SuperMap": "SuperMap iClient Classic",
6+
"mapboxgl": "SuperMap iClient for MapboxGL",
7+
"maplibregl": "SuperMap iClient for MapLibreGL"
8+
},
9+
"moduleCategories": {
10+
"Mapping": {
11+
"des": "基础地图模块",
12+
"des_en": "Basic map module"
13+
},
14+
"Services": {
15+
"des": "服务模块",
16+
"des_en": "Service module"
17+
},
18+
"Overlay": {
19+
"des": "可视化与计算模块",
20+
"des_en": "Visualization and calculation module"
21+
},
22+
"Control": {
23+
"des": "功能控件模块",
24+
"des_en": "Control module"
25+
},
26+
"Components": {
27+
"des": "组件模块",
28+
"des_en": "Component module"
29+
}
30+
}
31+
}

build/jsdocs/template/publish.js

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var template = require('jsdoc/template'),
88
helper = require('jsdoc/util/templateHelper'),
99
logger = require('jsdoc/util/logger'),
1010
typeLinks = require('./typeLinkExt').typeLinks,
11+
moduleCategoriesConfig = require('./module-categories.json'),
1112
_ = require('underscore'),
1213
htmlsafe = helper.htmlsafe,
1314
linkto = helper.linkto,
@@ -20,6 +21,7 @@ var template = require('jsdoc/template'),
2021
language,
2122
outdir = env.opts.destination;
2223
var util = require('util');
24+
var chalk = require('chalk');
2325

2426
function find(spec) {
2527
return helper.find(data, spec);
@@ -259,7 +261,7 @@ function buildNav(members, view, templatePath) {
259261
}else{
260262
methods[element.fileName] = m;
261263
}
262-
264+
263265
}
264266
}
265267
var methodsPath = path.join(outdir, 'methods.json');
@@ -298,6 +300,50 @@ function buildCategories(members, templatePath) {
298300
return categories;
299301
}
300302

303+
function buildModuleCategories(data, outdir, conf) {
304+
var clientModuleName = conf.namespace.replace('.supermap', '');
305+
var moduleCategories = moduleCategoriesConfig.moduleCategories;
306+
var rootDes = moduleCategoriesConfig.moduleRoots[clientModuleName];
307+
var categories = Object.keys(moduleCategories).reduce((sum, key) => {
308+
const info = moduleCategories[key];
309+
sum[key] = {
310+
name: key,
311+
...info,
312+
children: []
313+
}
314+
return sum;
315+
}, {});
316+
317+
data().each(function (v) {
318+
var categoryInfo = v.modulecategory;
319+
if (!categoryInfo) {
320+
return;
321+
}
322+
if (!categories[categoryInfo.category]) {
323+
console.log(chalk.red(`ERROR [${clientModuleName}]: The @modulecategory(${categoryInfo.category}) is not exsist in ${v.meta.filename}\n`));
324+
return;
325+
}
326+
if (!categoryInfo.des) {
327+
console.log(chalk.red(`ERROR [${clientModuleName}]: The @classdesc cannot be empty in ${v.meta.filename}\n`));
328+
}
329+
categories[categoryInfo.category].children.push({
330+
name: categoryInfo.name,
331+
des: categoryInfo.des,
332+
des_en: categoryInfo.des_en,
333+
docName: categoryInfo.className
334+
});
335+
});
336+
const finalContent = {
337+
id: clientModuleName,
338+
name: rootDes,
339+
des: rootDes,
340+
children: Object.values(categories).filter(item => item.children.length > 0)
341+
}
342+
var outpath = path.join(outdir, 'module-categories.js');
343+
fs.writeFileSync(outpath, `var deps = ${JSON.stringify(finalContent, null, 2)}`, 'utf8');
344+
return categories;
345+
}
346+
301347
/**
302348
* Create the navigation sidebar.
303349
* @param {object} members The members that will be used to create the sidebar.
@@ -1139,7 +1185,8 @@ exports.publish = function (taffyData, opts, tutorials) {
11391185
const dir = outdir.replace('./docs/', '');
11401186
return whiteLists[dir];
11411187
}
1142-
1188+
// 生成产品介绍中模块说明的g6配置
1189+
buildModuleCategories(data, outdir, conf);
11431190
const allFiles = getFileNames();
11441191
console.error('生成的多余的文档页面: ', getMorePages(allFiles, getHtmlLinks(allFiles)));
11451192
console.error('没有链接的类型: ', getWrongLink(allFiles));

build/pack.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const { Command } = require('commander');
22
const program = new Command();
33
var shell = require("shelljs");
4-
require("./deps");
54
program.description('Customized pack iClient.');
65

76
var excludeFields = ['title', 'description', 'description_en'];
@@ -70,4 +69,4 @@ function getCommonModulePaths() {
7069
})
7170
}
7271
return modulePaths;
73-
}
72+
}

0 commit comments

Comments
 (0)