mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
* refactor version 1 many todo
* split render from viewer
move alfresco render in content pack
* refactor part 2
* test fixed
* fix doc
* [AAE-10778] Fix lint issues
* [AAE-10778] Fix lint issue: remove duplicated declaration
* [AAE-10778] Fix lint issue: use flex shorthand rule
* [AAE-10778] Fix FormService and WidgetComponent imports
* [AAE-10778] Fix import FormModel, FormService, FormFieldModel from adf-core
* [AAE-10778] Implement missing oninit, onchanges and ondestroy
* [AAE-10778] Replace adf-viewer with adf-alfresco-viewer, update escape command to close the viewer
* [AAE-10778] Fix unit test: fix the class name to match the 'adf-viewer-render.image-viewer-scaling' get from the appConfigService
* [AAE-10778] Fix image-viewer unit tests: replace ContentService with UrlService
* [AAE-10778] Fix unit test 'should if the extension change extension Change event be fired': emit file extension when the filename extension change
* [AAE-10778] Fix unit test: expect for internalFileName value instead of display-name id because the display name logic has been moved to the alfresco-viewer.component
* [AAE-10778] Fix unit test: remove display name it because the unknown display name value is no longer handled after refactoring
* [AAE-10778] Fix e2e: [C260096] Should the Viewer able to accept a customToolbar
* [AAE-10778] Update selector to fix e2e: '[C362265] Should the Viewer be able to download a previous version of a file'
* [AAE-10778] Update selector to fix e2e: '[C260038] Should display first page, toolbar and pagination when opening a .pdf file'
* fix aftrer rebase
* fix unit test
* [AAE-10778] Add adf viewer component that is node agnostic, show adf-alfresco-viewer or adf-viewer into file-view-component if blob or node are set
* [AAE-10778] Update viewer export path
* [AAE-10778] Update selectors since have been updated in the viewer component
* [AAE-10778] Call adf-viewer from alfresco-viewer, project adf-alfresco-viewer content to adf-viewer
* [AAE-10778] Remove full screen unit tests from alfresco-viewer component becase that logic is handled in the viewer.component
* [AAE-10778] Export toolbar custom actions component
* [AAE-10778] Pass mimeType as input to adf-viewer to update mime icon
* [AAE-10778] Remove e2e because the custom name behaviour has been removed from the file-view.component (9f21b6dc69
\#diff-4b438dc59784dce9eb7634cfeca6d8db61362966343bd3d6895a3edafdf4cfd5L129)
* [AAE-10778] Use two-way binding for showViewer change to fix C260100
* [AAE-10778] Update prefix css selectors to adf-viewer because are related to the adf-viewer component
* [AAE-10778] Update prefix css selectors to adf-viewer in the unit tests because are related to the adf-viewer component
* [AAE-10778] Update the output name to showViewerChange to navigate to primary url after closing the viewer
* [AAE-10778] Pass right and left sidebar template context to viewer component (fix C362242)
* [AAE-10778] Add allowFullScreen input to disable/enable full screen behaviour
* [AAE-10778] Handle loading visualization only inside the viewer-render component
* [AAE-10778] PDF viewer: fix mat-progress-bar is not showed during the pdf loading, center progress bar
* [AAE-10778] Remove isLoading from unit tests because no longer exists
* [AAE-10778] Remove viewerType input from adf-viewer, viewerType will be handled by viewer-render
* [AAE-10778] Remove console.log
* [AAE-10778] Remove check full screen button is not displayed on the media file because is not needed anymore, we don't need to check for the fullscreen button in the viewer component
* [AAE-10778] Check for node rendtion before to assign to urlFileContent and mimeType
* [AAE-10778] Process Services Cloud: register file-viewer widget that uses adf-alfresco-viewer component to display content from ACS
* [AAE-10778] Core: rename file-viewer widget into base-viewer, base-viewer no longer accept nodeId, but will accept urlFile and blobFile
* [AAE-10778] Process Services: register file-viewer widget that uses adf-alfresco-viewer component to display content from ACS
* [AAE-10778] Base viewer widget: show viewer only if there's a file input
* [AAE-10778] Viewer component: check for fileName when urlFile is provided as Input
* [AAE-10778] Viewer component documentation
* [AAE-10778] Update upgrade guide with viewer changes
* [AAE-10778] Fix double quote lint issue after rebase
---------
Co-authored-by: Amedeo Lepore <amedeo.lepore@hyland.com>
Co-authored-by: Amedeo Lepore <amedeo.lepore85@gmail.com>
191 lines
7.3 KiB
JavaScript
191 lines
7.3 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.processDocs = void 0;
|
|
var fs = require("fs");
|
|
var path = require("path");
|
|
var replaceSection = require("mdast-util-heading-range");
|
|
var remark = require("remark");
|
|
var ejs = require("ejs");
|
|
var mdNav_1 = require("../mdNav");
|
|
var ngHelpers_1 = require("../ngHelpers");
|
|
var templateFolder = path.resolve('tools', 'doc', 'templates');
|
|
var nameExceptions;
|
|
function processDocs(mdCache, aggData) {
|
|
nameExceptions = aggData.config.typeNameExceptions;
|
|
var pathnames = Object.keys(mdCache);
|
|
var internalErrors;
|
|
pathnames.forEach(function (pathname) {
|
|
internalErrors = [];
|
|
updateFile(mdCache[pathname].mdOutTree, pathname, aggData, internalErrors);
|
|
if (internalErrors.length > 0) {
|
|
showErrors(pathname, internalErrors);
|
|
}
|
|
});
|
|
}
|
|
exports.processDocs = processDocs;
|
|
function showErrors(filename, errorMessages) {
|
|
console.log(filename);
|
|
errorMessages.forEach(function (message) {
|
|
console.log(' ' + message);
|
|
});
|
|
console.log('');
|
|
}
|
|
function updateFile(tree, pathname, aggData, errorMessages) {
|
|
var className = (0, ngHelpers_1.ngNameToClassName)(path.basename(pathname, '.md'), nameExceptions);
|
|
var classTypeMatch = className.match(/component|directive|service/i);
|
|
var compData = aggData.classInfo[className];
|
|
if (classTypeMatch && compData) {
|
|
var classType = classTypeMatch[0].toLowerCase();
|
|
// Copy docs back from the .md file when the JSDocs are empty.
|
|
var inputMD = getPropDocsFromMD(tree, 'Properties', 3);
|
|
var outputMD = getPropDocsFromMD(tree, 'Events', 2);
|
|
updatePropDocsFromMD(compData, inputMD, outputMD, errorMessages);
|
|
if (classType === 'service') {
|
|
var methodMD = getMethodDocsFromMD(tree);
|
|
updateMethodDocsFromMD(compData, methodMD, errorMessages);
|
|
}
|
|
var templateName = path.resolve(templateFolder, classType + '.ejs');
|
|
var templateSource = fs.readFileSync(templateName, 'utf8');
|
|
var template = ejs.compile(templateSource);
|
|
var mdText = template(compData);
|
|
mdText = mdText.replace(/^ +\|/mg, '|');
|
|
var newSection_1 = remark().parse(mdText.trim()).children;
|
|
replaceSection(tree, 'Class members', function (before, section, after) {
|
|
newSection_1.unshift(before);
|
|
newSection_1.push(after);
|
|
return newSection_1;
|
|
});
|
|
compData.errors.forEach(function (err) {
|
|
errorMessages.push(err);
|
|
});
|
|
}
|
|
return true;
|
|
}
|
|
function getPropDocsFromMD(tree, sectionHeading, docsColumn) {
|
|
var result = {};
|
|
var nav = new mdNav_1.MDNav(tree);
|
|
var classMemHeading = nav
|
|
.heading(function (h) {
|
|
return (h.children[0].type === 'text') && (h.children[0].value === 'Class members');
|
|
});
|
|
var propsTable = classMemHeading
|
|
.heading(function (h) {
|
|
return (h.children[0].type === 'text') && (h.children[0].value === sectionHeading);
|
|
}).table();
|
|
var propTableRow = propsTable.childNav
|
|
.tableRow(function () { return true; }, 1).childNav;
|
|
var i = 1;
|
|
while (!propTableRow.empty) {
|
|
var propName = propTableRow
|
|
.tableCell().childNav
|
|
.text().item.value;
|
|
var propDocText = propTableRow
|
|
.tableCell(function () { return true; }, docsColumn).childNav
|
|
.text().item;
|
|
if (propDocText) {
|
|
result[propName] = propDocText.value;
|
|
}
|
|
i++;
|
|
propTableRow = propsTable.childNav
|
|
.tableRow(function () { return true; }, i).childNav;
|
|
}
|
|
return result;
|
|
}
|
|
function getMethodDocsFromMD(tree) {
|
|
var result = {};
|
|
var nav = new mdNav_1.MDNav(tree);
|
|
var classMemHeading = nav
|
|
.heading(function (h) {
|
|
return (h.children[0].type === 'text') && (h.children[0].value === 'Class members');
|
|
});
|
|
var methListItems = classMemHeading
|
|
.heading(function (h) {
|
|
return (h.children[0].type === 'text') && (h.children[0].value === 'Methods');
|
|
}).list().childNav;
|
|
var methItem = methListItems
|
|
.listItem();
|
|
var i = 0;
|
|
while (!methItem.empty) {
|
|
var methNameSection = methItem.childNav
|
|
.paragraph().childNav
|
|
.strong().childNav;
|
|
var methName = '';
|
|
// Method docs must be in "new" format with names and types styled separately.
|
|
if (!methNameSection.empty) {
|
|
methName = methNameSection.text().item.value;
|
|
var methDoc = methItem.childNav
|
|
.paragraph().childNav
|
|
.html()
|
|
.text().value;
|
|
var params = getMDMethodParams(methItem);
|
|
result[methName] = {
|
|
'docText': methDoc.replace(/^\n/, ''),
|
|
'params': params
|
|
};
|
|
}
|
|
i++;
|
|
methItem = methListItems
|
|
.listItem(function (l) { return true; }, i);
|
|
}
|
|
return result;
|
|
}
|
|
function getMDMethodParams(methItem) {
|
|
var result = {};
|
|
var paramList = methItem.childNav.list().childNav;
|
|
var paramListItems = paramList
|
|
.listItems();
|
|
paramListItems.forEach(function (paramListItem) {
|
|
var paramNameNode = paramListItem.childNav
|
|
.paragraph().childNav
|
|
.emph().childNav;
|
|
var paramName;
|
|
if (!paramNameNode.empty) {
|
|
paramName = paramNameNode.text().item.value.replace(/:/, '');
|
|
}
|
|
else {
|
|
var item = paramListItem.childNav.paragraph().childNav
|
|
.strong().childNav.text();
|
|
if (paramName) {
|
|
paramName = item.value;
|
|
}
|
|
}
|
|
var paramDoc = paramListItem.childNav
|
|
.paragraph().childNav
|
|
.text(function (t) { return true; }, 1).value; // item.value;
|
|
result[paramName] = paramDoc.replace(/^[ -]+/, '');
|
|
});
|
|
return result;
|
|
}
|
|
function updatePropDocsFromMD(comp, inputDocs, outputDocs, errorMessages) {
|
|
comp.properties.forEach(function (prop) {
|
|
var propMDDoc;
|
|
if (prop.isInput) {
|
|
propMDDoc = inputDocs[prop.name];
|
|
}
|
|
else if (prop.isOutput) {
|
|
propMDDoc = outputDocs[prop.name];
|
|
}
|
|
// If JSDocs are empty but MD docs aren't then the Markdown is presumably more up-to-date.
|
|
if (!prop.docText && propMDDoc) {
|
|
prop.docText = propMDDoc;
|
|
errorMessages.push("Warning: empty JSDocs for property \"".concat(prop.name, "\" may need sync with the .md file."));
|
|
}
|
|
});
|
|
}
|
|
function updateMethodDocsFromMD(comp, methodDocs, errorMessages) {
|
|
comp.methods.forEach(function (meth) {
|
|
var currMethMD = methodDocs[meth.name];
|
|
// If JSDocs are empty but MD docs aren't then the Markdown is presumably more up-to-date.
|
|
if (!meth.docText && currMethMD && currMethMD.docText) {
|
|
meth.docText = currMethMD.docText;
|
|
errorMessages.push("Warning: empty JSDocs for method sig \"".concat(meth.name, "\" may need sync with the .md file."));
|
|
}
|
|
meth.params.forEach(function (param) {
|
|
if (!param.docText && currMethMD && currMethMD.params[param.name]) {
|
|
param.docText = currMethMD.params[param.name];
|
|
errorMessages.push("Warning: empty JSDocs for parameter \"".concat(param.name, " (").concat(meth.name, ")\" may need sync with the .md file."));
|
|
}
|
|
});
|
|
});
|
|
}
|