mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-01 14:41:32 +00:00
* [ADF-4152] Initial GraphQL implementation * [ADF-4152] Schema updates * [ADF-4152] Rounded out basic fields * [ADF-4152] Added basic template functionality * [ADF-4152] Added full template generation * [ADF-4152] Moved proc services doc files to new folders * [ADF-4152] Updated README.md with section from new template * [ADF-4152] Fixed another problem with relative URLs * [ADF-4152] Fixed links and some more bugs * [ADF-4152] Removed proc services folder README file
55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
import * as path from "path";
|
|
|
|
import { select } from "unist-util-select";
|
|
|
|
import * as ngHelpers from "../ngHelpers";
|
|
|
|
|
|
const angFilenameRegex = /([a-zA-Z0-9\-]+)\.((component)|(dialog)|(directive)|(interface)|(model)|(pipe)|(service)|(widget))/;
|
|
|
|
|
|
export function processDocs(mdCache, aggData, errorMessages) {
|
|
var pathnames = Object.keys(mdCache);
|
|
|
|
pathnames.forEach(pathname => {
|
|
let fileBaseName = path.basename(pathname, '.md');
|
|
|
|
if (!fileBaseName.match(angFilenameRegex)) {
|
|
return;
|
|
}
|
|
|
|
let tree = mdCache[pathname].mdOutTree;
|
|
let className = ngHelpers.ngNameToClassName(fileBaseName, aggData.config.typeNameExceptions);
|
|
let classInfo = aggData.classInfo[className];
|
|
let sourcePath = classInfo ? classInfo.sourcePath : '';
|
|
let titleHeading = select('heading[depth=1]:first-of-type', tree);
|
|
let relDocPath = pathname.substring(pathname.indexOf('docs'));
|
|
let srcUrl = fixRelSrcUrl(relDocPath, sourcePath);
|
|
|
|
if (titleHeading.children[0].type === "text") {
|
|
let titleText = titleHeading.children[0];
|
|
titleHeading.children[0] = {
|
|
type: 'link',
|
|
url: srcUrl,//`../../${sourcePath}`,
|
|
title: `Defined in ${path.basename(sourcePath)}`,
|
|
children: [titleText]
|
|
}
|
|
} else if ((titleHeading.children[0].type === "link") && sourcePath) {
|
|
let linkElem = titleHeading.children[0];
|
|
linkElem.url = srcUrl, //`../../${sourcePath}`;
|
|
linkElem.title = `Defined in ${path.basename(sourcePath)}`;
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
function fixRelSrcUrl(docPath: string, srcPath: string) {
|
|
let docPathSegments = docPath.split(/[\\\/]/);
|
|
let dotPathPart = '';
|
|
|
|
for (let i = 0; i < (docPathSegments.length - 1); i++) {
|
|
dotPathPart += '../';
|
|
}
|
|
|
|
return dotPathPart + srcPath;
|
|
} |