Skip to content

Commit

Permalink
Merge pull request #104 from MatthewFallon/feature/shorten-types
Browse files Browse the repository at this point in the history
Feature/shorten types
  • Loading branch information
ar2rsawseen authored Nov 15, 2022
2 parents 8099822 + 7d7e898 commit 2331d06
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Docdash supports the following options:
"private": [false|true], // set to false to not show @private in navbar
"removeQuotes": [none|all|trim],// Remove single and double quotes, trim removes only surrounding ones
"scripts": [], // Array of external (or relative local copied using templates.default.staticFiles.include) js or css files to inject into HTML,
"ShortenTypes": [false|true], // If set to true this will resolve the display name of all types as the shortened name only (after the final period).
"menu": { // Adding additional menu items after Home
"Project Website": { // Menu item name
"href":"https://myproject.com", //the rest of HTML properties to add to manu item
Expand Down
25 changes: 22 additions & 3 deletions tmpl/type.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
<?js
var data = obj;
var self = this;
data.forEach(function(name, i) { ?>
<span class="param-type"><?js= self.linkto(name, self.htmlsafe(name)) ?></span>
data.forEach(function(name, i) {
if (env && env.conf && env.conf.docdash && env.conf.docdash.shortenTypes === true) {
var nameArr = name.split(/[\.~#]/);
var resolvedName = nameArr[nameArr.length - 1];
if (name.startsWith("Array.<")) {
if (nameArr.length === 2) {
resolvedName = name;
} else {
resolvedName = resolvedName.replace(">", "");
var longname = name.replace("Array.<","").replace(">", "");
}
}
} else {
var resolvedName = name;
}
var link = self.linkto(name, self.htmlsafe(resolvedName));
if (longname) {
link = link.replace(longname, resolvedName);
}
?>
<span class="param-type"><?js= link?></span>
<?js if (i < data.length-1) { ?>|<?js } ?>
<?js }); ?>
<?js }); ?>

0 comments on commit 2331d06

Please sign in to comment.