[ADF-3801] Added source linking tool and updated content services docs (#4037)

* [ADF-3801] Added source linking tool

* [ADF-3801] Added source links to doc files
This commit is contained in:
Andy Stark
2018-11-30 11:59:36 +00:00
committed by Eugenio Romano
parent 164abecc06
commit 4b68c98007
63 changed files with 142 additions and 61 deletions

View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: 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)|(directive)|(interface)|(model)|(pipe)|(service)|(widget))/;
function processDocs(mdCache, aggData, errorMessages) {
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);
if (titleHeading.children[0].type === "text") {
var titleText = titleHeading.children[0];
titleHeading.children[0] = {
type: 'link',
url: "../../" + sourcePath,
title: "Defined in " + path.basename(sourcePath),
children: [titleText]
};
}
else if (titleHeading.children[0].type === "link") {
var linkElem = titleHeading.children[0];
linkElem.url = "../../" + sourcePath;
linkElem.title = "Defined in " + path.basename(sourcePath);
}
});
}
exports.processDocs = processDocs;

View File

@@ -0,0 +1,42 @@
import * as path from "path";
import { select } from "unist-util-select";
import * as ngHelpers from "../ngHelpers";
const angFilenameRegex = /([a-zA-Z0-9\-]+)\.((component)|(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);
if (titleHeading.children[0].type === "text") {
let titleText = titleHeading.children[0];
titleHeading.children[0] = {
type: 'link',
url: `../../${sourcePath}`,
title: `Defined in ${path.basename(sourcePath)}`,
children: [titleText]
}
} else if (titleHeading.children[0].type === "link") {
let linkElem = titleHeading.children[0];
linkElem.url = `../../${sourcePath}`;
linkElem.title = `Defined in ${path.basename(sourcePath)}`;
}
});
}