Files
alfresco-ng2-components/tools/doc/tools/sourceLinker.js
Eugenio Romano 5e54cd4d43 Increase timeout and modify login async (#4795)
* increase timeout and modify login async

* run e2e if testing is changed

* improve cdk fix

* fix travis update projects

* disable ghostMode lite server

* lint fix

* fix timeout

* multiple try

* Update content-services-e2e.sh

* Update search-e2e.sh

* Update process-services-e2e.sh

* Update core-e2e.sh

* Update protractor.conf.ts

* fix unit

* remove async

* increqase notification time

* 3 parallel

* dix path issue in save

* small refactor protractor ts

* fix save

* create license check first script adf cli

* modify regex check

* refactor notification history component

* decrease notification

* fix notification message problem

* fix test

* update packages wit high risk

* revert cahnge login sso e2e

* fix dep

* fix documentation duplication and issue

* fix after review

* fix after review

* try 6 parallel test

* back to 3 parallel test no real time improve with 6
2019-06-06 16:47:50 +01:00

46 lines
2.0 KiB
JavaScript

"use strict";
exports.__esModule = true;
var path = require("path");
var unist_util_select_1 = require("unist-util-select");
var ngHelpers = require("../ngHelpers");
var angFilenameRegex = /([a-zA-Z0-9\-]+)\.((component)|(dialog)|(directive)|(interface)|(model)|(pipe)|(service)|(widget))/;
function processDocs(mdCache, aggData) {
var pathnames = Object.keys(mdCache);
pathnames.forEach(function (pathname) {
var fileBaseName = path.basename(pathname, '.md');
if (!fileBaseName.match(angFilenameRegex)) {
return;
}
var tree = mdCache[pathname].mdOutTree;
var className = ngHelpers.ngNameToClassName(fileBaseName, aggData.config.typeNameExceptions);
var classInfo = aggData.classInfo[className];
var sourcePath = classInfo ? classInfo.sourcePath : '';
var titleHeading = unist_util_select_1.select('heading[depth=1]:first-of-type', tree);
var relDocPath = pathname.substring(pathname.indexOf('docs'));
var srcUrl = fixRelSrcUrl(relDocPath, sourcePath);
if (titleHeading && titleHeading.children[0] && titleHeading.children[0].type === "text") {
var titleText = titleHeading.children[0];
titleHeading.children[0] = {
type: 'link',
url: srcUrl,
title: "Defined in " + path.basename(sourcePath),
children: [titleText]
};
}
else if ((titleHeading && titleHeading.children[0].type === "link") && sourcePath) {
var linkElem = titleHeading.children[0];
linkElem.url = srcUrl,
linkElem.title = "Defined in " + path.basename(sourcePath);
}
});
}
exports.processDocs = processDocs;
function fixRelSrcUrl(docPath, srcPath) {
var docPathSegments = docPath.split(/[\\\/]/);
var dotPathPart = '';
for (var i = 0; i < (docPathSegments.length - 1); i++) {
dotPathPart += '../';
}
return dotPathPart + srcPath;
}