Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/shorten types #104

Merged
merged 5 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }); ?>