Exemplo n.º 1
0
						},function(err,demoCodeHtml){
							if(err){
								console.log('error occur:' + str);
							}else{
								compiledDemosNum++;
								tagMapDemoHtml.push({
									str : str,
									demoCodeHtml : demoCodeHtml
								});
								if(compiledDemosNum === includingFiles.length){
									for(var j = 0; j < tagMapDemoHtml.length; j++){
										var obj = tagMapDemoHtml[j];
										fileHtml = fileHtml.replace(obj.str,obj.demoCodeHtml);
									}
									xtpl.__express(mainXtplPath,{
										mainContent : fileHtml,
										sidebarContent : sideBarHtml,
										apilink : apilink,
										version : version,
										title : title,
										settings : {
											'view encoding' : 'utf-8'
										}
									},function(err,desFile){
										var desFileName = path.normalize(fileName.replace('src','build').replace('md','html'));
										!fs.existsSync(path.dirname(desFileName)) && fs.mkdirSync(path.dirname(desFileName));
										fs.writeFileSync(desFileName, desFile);
									});
								}
							}
						});
Exemplo n.º 2
0
function buildGuideIndex(guidesModuleLists){
	var productGuideIndexPath = path.resolve(projectPath, './build/guides/index.html'),
		guidesIndexXtplPath = path.resolve(projectPath, './themes/guides/layouts/guides-index.xtpl');
	xtpl.__express(guidesIndexXtplPath,{
		version : version,
		settings : {
			'view encoding' : 'utf-8'
		},
		guidesModuleLists : guidesModuleLists
	},function(err,content){
		if(err){
			console.log('error occuring when render guides-index.xtpl');
		}else{
			fs.writeFileSync(productGuideIndexPath,content);
		}
	});
}
Exemplo n.º 3
0
			fs.readdirSync(fileName).forEach(function(file){
				var srcFileName = path.resolve(fileName,file);
				var mdContent = fs.readFileSync(srcFileName).toString(),
					desPath = path.normalize(srcFileName.replace('src','build').replace('md','html')),
					fileHtml = marked(mdContent),
					title = getTitle(fileHtml);
				xtpl.__express(mainXtplPath,{
					mainContent : fileHtml,
					version : version,
					title : title,
					settings : {
						'view encoding' : 'utf-8'
					}
				},function(err,desFile){
					fs.writeFileSync(desPath,desFile);
				});
			});
Exemplo n.º 4
0
function buildDemoIndex(demoLists){
	var productDemoIndexPath = path.resolve(projectPath, './build/demos/index.html'),
		demosIndexXtplPath = path.resolve(projectPath, './themes/demos/layouts/demos-index.xtpl');

	xtpl.__express(demosIndexXtplPath,{
		version : version,
		settings : {
			'view encoding' : 'utf-8'
		},
		demoLists : demoLists
	},function(err,content){
		if(err){
			console.log('error occuring when render demos-index.xtpl');
		}else{
			fs.writeFileSync(productDemoIndexPath,content);
		}
	});
}
Exemplo n.º 5
0
	fs.readdirSync(srcDirPath).forEach(function(file){
		if(file === 'api' || file === 'demos' || file === 'guides' || file === 'assets'){
			return;  //这个三个目录在其他地方处理,如buildGuides/buildDemos等
		}
		var fileName = path.resolve(srcDirPath,file);
		if(!fs.statSync(fileName).isDirectory()){
			var mdContent = fs.readFileSync(fileName).toString(),
				desPath = path.normalize(fileName.replace('src','build').replace('md','html')),
				fileHtml = marked(mdContent),
				title = getTitle(fileHtml);
			xtpl.__express(mainXtplPath,{
				mainContent : fileHtml,
				version : version,
				title : title,
				settings : {
					'view encoding' : 'utf-8'
				}
			},function(err,desFile){
				fs.writeFileSync(desPath,desFile);
			});
		}else{
			var desDirName = path.normalize(fileName.replace('src','build'));
			!fs.existsSync(desDirName) && fs.mkdirSync(desDirName);
			fs.readdirSync(fileName).forEach(function(file){
				var srcFileName = path.resolve(fileName,file);
				var mdContent = fs.readFileSync(srcFileName).toString(),
					desPath = path.normalize(srcFileName.replace('src','build').replace('md','html')),
					fileHtml = marked(mdContent),
					title = getTitle(fileHtml);
				xtpl.__express(mainXtplPath,{
					mainContent : fileHtml,
					version : version,
					title : title,
					settings : {
						'view encoding' : 'utf-8'
					}
				},function(err,desFile){
					fs.writeFileSync(desPath,desFile);
				});
			});
		}
	});
Exemplo n.º 6
0
			fs.readdirSync(dirName).forEach(function(file){
				var fileName = path.resolve(dirName,file),
					fileMD = fs.readFileSync(fileName).toString(),
					fileHtml = unescapeHtml(marked(fileMD)),
					title = getTitle(fileHtml),
					apiLinkReg = /\(\(\(apilink\s*(.+)\)\)\)/,
					apiLinkRegResult = apiLinkReg.exec(fileHtml),
					apilink = '../../api';

				if(apiLinkRegResult){
					apilink = apiLinkRegResult[1];
					var name = /['"](.+)['"]/.exec(apilink)[1];
					apilink = apilink.indexOf('class') > -1 ? ('../../api/classes/' + name + '.html') : ('../../api/modules/' + name + '.html');
					fileHtml = fileHtml.replace(apiLinkRegResult[0],'');
				}

				var mainXtplPath = path.resolve(srcDirPath,'../themes/guides/layouts/main.xtpl'),
					desFile = xtpl.__express(mainXtplPath,{
						mainContent : fileHtml,
						sidebarContent : sideBarHtml,
						apilink : apilink,
						version : version,
						title : title,
						settings : {
							'view encoding' : 'utf-8'
						}
					},function(err,desFile){
						if(err){
							console.log('render error!');
						}else{
							var desFileName = path.normalize(fileName.replace('src','build').replace('md','html'));
							!fs.existsSync(path.dirname(desFileName)) && fs.mkdirSync(path.dirname(desFileName));
							fs.writeFileSync(desFileName, desFile);
						}
					});
			});