mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-1549] Initial files for new doc format (#2342)
This commit is contained in:
committed by
Eugenio Romano
parent
43277148b2
commit
7157d60ed0
@@ -1,5 +1,10 @@
|
||||
# Alfresco Angular Components
|
||||
|
||||
**NOTE:** We are in the process of transferring docs from the component library
|
||||
README files to a new system. This file lists all the docs currently in the
|
||||
READMEs but the complete index for the docs can now be found in the
|
||||
[Component Docs Index](../docIndex.md).
|
||||
|
||||
<!-- markdown-toc start - Don't edit this section. npm run toc to generate it-->
|
||||
|
||||
<!-- toc -->
|
||||
|
134
ng2-components/config/buildFullDocIndex.js
Normal file
134
ng2-components/config/buildFullDocIndex.js
Normal file
@@ -0,0 +1,134 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
var angFilenameRegex = /([a-zA-Z0-9\-]+)\.((component)|(directive)|(model)|(service)|(widget))\.ts/;
|
||||
|
||||
var indexFileName = '../docIndex.md';
|
||||
var summaryFileName = path.resolve('..', 'docs', 'summary.json');
|
||||
|
||||
|
||||
function searchFolderRecursive(folderPath) {
|
||||
var items = fs.readdirSync(path.resolve(folderPath));
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var itemPath = path.resolve(folderPath, items[i]);
|
||||
var info = fs.statSync(itemPath);
|
||||
|
||||
if (info.isFile() && (items[i].match(angFilenameRegex))) {
|
||||
var nameNoSuffix = path.basename(items[i], '.ts');//items[i].substring(0, items[i].length - 4);
|
||||
|
||||
if(nameNoSuffix in docDict) {
|
||||
itemsWithDocs.push(itemPath);
|
||||
} else {
|
||||
itemsWithoutDocs.push(itemPath);
|
||||
}
|
||||
} else if (info.isDirectory()) {
|
||||
searchFolderRecursive(itemPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getDocFolderItems(docFolderPath) {
|
||||
var result = {};
|
||||
var items = fs.readdirSync(path.resolve(docFolderPath));
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].endsWith('.md')) {
|
||||
var nameNoSuffix = path.basename(items[i], '.md');
|
||||
result[nameNoSuffix] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function tidyName(name) {
|
||||
var result = name.replace(/-/g, " ");
|
||||
result = result.substr(0, 1).toUpperCase() + result.substr(1);
|
||||
return result;
|
||||
}
|
||||
|
||||
function makeSummaryIndex() {
|
||||
var summaryJson = fs.readFileSync(summaryFileName, 'utf8');
|
||||
var summary = JSON.parse(summaryJson);
|
||||
|
||||
var result = '';
|
||||
|
||||
for (var i = 0; i < summary.length; i++) {
|
||||
var item = summary[i];
|
||||
result += '- [' + item.title + '](docs/' + item.file + ')\n';
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
var docDict = getDocFolderItems(path.resolve('..', 'docs'));
|
||||
|
||||
var rootItems = fs.readdirSync(path.resolve('.'));
|
||||
|
||||
var libs = {}
|
||||
|
||||
for (var i = 0; i < rootItems.length; i++) {
|
||||
var itemPath = path.resolve(rootItems[i]);
|
||||
var info = fs.statSync(itemPath);
|
||||
|
||||
if (info.isDirectory() && rootItems[i].match(/ng2-/)) {
|
||||
libs[rootItems[i]] =[ [], [] ];
|
||||
var itemsWithDocs = libs[rootItems[i]][0];
|
||||
var itemsWithoutDocs = libs[rootItems[i]][1];
|
||||
searchFolderRecursive(path.resolve(itemPath, 'src'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var indexFileText = fs.readFileSync(indexFileName, 'utf8');
|
||||
|
||||
var libNames = Object.keys(libs);
|
||||
|
||||
for (var i = 0; i < libNames.length; i++) {
|
||||
var listItems = [];
|
||||
var libName = libNames[i];
|
||||
var libData = libs[libName];
|
||||
|
||||
if (libData[0].length > 0) {
|
||||
listItems.push('**Documented**\n');
|
||||
|
||||
for (var j = 0; j < libData[0].length; j++) {
|
||||
var libFilePath = libData[0][j];
|
||||
var libFileName = path.basename(libFilePath, '.ts');
|
||||
var nameSections = libFileName.split('.');
|
||||
var visibleName = tidyName(nameSections[0]) + ' ' + nameSections[1];
|
||||
var mdListItem = '- [' + visibleName + '](docs/' + libFileName + '.md)';
|
||||
listItems.push(mdListItem);
|
||||
}
|
||||
}
|
||||
|
||||
if (libData[1].length > 0) {
|
||||
listItems.push('\n**Undocumented**\n');
|
||||
|
||||
for (var j = 0; j < libData[1].length; j++) {
|
||||
var libFilePath = libData[1][j].replace(/\\/g, '/');
|
||||
var libFileName = path.basename(libFilePath, '.ts');
|
||||
var nameSections = libFileName.split('.');
|
||||
var visibleName = tidyName(nameSections[0]) + ' ' + nameSections[1];
|
||||
var relPath = libFilePath.substr(libFilePath.indexOf('/ng2-') + 1);
|
||||
var mdListItem = '- [' + visibleName + '](' + relPath + ')';
|
||||
listItems.push(mdListItem);
|
||||
}
|
||||
}
|
||||
|
||||
var libText = listItems.join('\n');
|
||||
var libStartMarker = '<!-- ' + libName + ' start -->';
|
||||
var libEndMarker = '<!-- ' + libName + ' end -->';
|
||||
var contentRegex = new RegExp('(?:' + libStartMarker + ')([\\s\\S]*)(?:' + libEndMarker + ')');
|
||||
indexFileText = indexFileText.replace(contentRegex, libStartMarker + '\n' + libText + '\n' + libEndMarker);
|
||||
}
|
||||
|
||||
var guideStartMarker = '<!-- guide start -->';
|
||||
var guideEndMarker = '<!-- guide end -->';
|
||||
var contentRegex = new RegExp('(?:' + guideStartMarker + ')([\\s\\S]*)(?:' + guideEndMarker + ')');
|
||||
indexFileText = indexFileText.replace(contentRegex, guideStartMarker + '\n' + makeSummaryIndex() + '\n' + guideEndMarker);
|
||||
|
||||
fs.writeFileSync(indexFileName, indexFileText, 'utf-8');
|
@@ -17,6 +17,7 @@
|
||||
"toc": "markdown-toc -i ng2-alfresco-core/README.md && markdown-toc -i ng2-alfresco-datatable/README.md && markdown-toc -i ng2-activiti-diagrams/README.md && markdown-toc -i ng2-activiti-analytics/README.md && markdown-toc -i ng2-activiti-form/README.md && markdown-toc -i ng2-activiti-tasklist/README.md && markdown-toc -i ng2-activiti-processlist/README.md && markdown-toc -i ng2-alfresco-documentlist/README.md && markdown-toc -i ng2-alfresco-login/README.md && markdown-toc -i ng2-alfresco-search/README.md && markdown-toc -i ng2-alfresco-tag/README.md && markdown-toc -i ng2-alfresco-upload/README.md && markdown-toc -i ng2-alfresco-viewer/README.md && markdown-toc -i ng2-alfresco-webscript/README.md && markdown-toc -i ng2-alfresco-webscript/README.md && markdown-toc -i ng2-alfresco-userinfo/README.md && markdown-toc -i ng2-alfresco-social/README.md && markdown-toc -i README.md",
|
||||
"markdownlint": "markdownlint ng2-alfresco-core/README.md && markdownlint ng2-alfresco-datatable/README.md && markdownlint ng2-activiti-diagrams/README.md && markdownlint ng2-activiti-analytics/README.md && markdownlint ng2-activiti-form/README.md && markdownlint ng2-activiti-tasklist/README.md && markdownlint ng2-activiti-processlist/README.md && markdownlint ng2-alfresco-documentlist/README.md && markdownlint ng2-alfresco-login/README.md && markdownlint ng2-alfresco-search/README.md && markdownlint ng2-alfresco-tag/README.md && markdownlint ng2-alfresco-upload/README.md && markdownlint ng2-alfresco-viewer/README.md && markdownlint ng2-alfresco-webscript/README.md && markdownlint ng2-alfresco-webscript/README.md && markdownlint ng2-alfresco-userinfo/README.md && markdownlint ng2-alfresco-social/README.md && markdownlint README.md",
|
||||
"doc": "npm run toc && npm run markdownlint && npm run webpack -- --config config/webpack.doc.js --progress --profile --bail",
|
||||
"docindex": "node config/buildFullDocIndex.js",
|
||||
"tslint": "",
|
||||
"prepublish": "",
|
||||
"tsc": "",
|
||||
|
Reference in New Issue
Block a user