[ADF-2764] Added tool to add links to type names in Markdown files (#3226)

* [ADF-2764] Added basic type linker tool

* [ADF-2764] Support for class links in body text

* [ADF-2764] Started support for multi-word class names (not working yet)

* [ADF-2764] Updated script to handle English component names
This commit is contained in:
Andy Stark
2018-04-24 14:30:51 +01:00
committed by Eugenio Romano
parent b580efb7f6
commit 8f27cd1758
4 changed files with 668 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
module.exports = {
"ngNameToDisplayName": ngNameToDisplayName,
"dekebabifyName": dekebabifyName,
"kebabifyClassName": kebabifyClassName,
"classTypes": ["component", "directive", "model", "pipe", "service", "widget"]
}
@@ -12,8 +13,23 @@ function ngNameToDisplayName(ngName) {
}
function displayNameToNgName(name) {
var noSpaceName = ngName.replace(/ ([a-zA-Z])/, "$1".toUpperCase());
return noSpaceName.substr(0, 1).toUpperCase() + noSpaceName.substr(1);
}
function dekebabifyName(name) {
var result = name.replace(/-/g, " ");
result = result.substr(0, 1).toUpperCase() + result.substr(1);
return result;
}
function kebabifyClassName(name) {
var result = name.replace(/(Component|Directive|Interface|Model|Pipe|Service|Widget)$/, match => {
return "." + match.toLowerCase();
});
result = result.replace(/([A-Z])/g, "-$1");
return result.substr(1).toLowerCase();
}