Skip to content

Commit ca2be48

Browse files
committed
Add custom typedoc theme
1 parent c28d398 commit ca2be48

5 files changed

Lines changed: 323 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
.tsd-index-panel ul.tsd-index-list {
20+
-webkit-column-count: 1!important;
21+
-moz-column-count: 1!important;
22+
-ms-column-count: 1!important;
23+
-o-column-count: 1!important;
24+
column-count: 1!important;
25+
}
26+
27+
.tsd-page-title h1 {
28+
font-size: 1em;
29+
margin-top: 0.5em;
30+
}
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
( function () { // eslint-disable-line func-names, no-restricted-syntax
22+
/**
23+
* Removes extraneous information from a path.
24+
*
25+
* @private
26+
* @param {string} txt - text 1
27+
* @returns {string} cleaned text
28+
*/
29+
function cleanPath( txt ) {
30+
var j;
31+
if (
32+
txt.charCodeAt( 0 ) === 34 && // "
33+
txt.charCodeAt( txt.length-1 ) === 34 // "
34+
) {
35+
txt = txt.slice( 1, txt.length-1 );
36+
}
37+
j = txt.indexOf( '/docs/types/' );
38+
if ( j >= 0 ) {
39+
txt = txt.slice( 0, j );
40+
}
41+
return txt;
42+
}
43+
44+
/**
45+
* Cleans up link text.
46+
*
47+
* @private
48+
* @param {Array<DOMElement>} el - list of anchor elements to clean
49+
*/
50+
function cleanLinks( el ) {
51+
var i;
52+
for ( i = 0; i < el.length; i++ ) {
53+
el[ i ].innerHTML = cleanPath( el[ i ].innerHTML );
54+
}
55+
}
56+
57+
/**
58+
* Updates and removes extraneous information from a heading.
59+
*
60+
* @private
61+
* @param {string} txt - text
62+
* @returns {string} cleaned text
63+
*/
64+
function cleanHeading( txt ) {
65+
if ( txt.indexOf( 'External module' ) === 0 ) {
66+
txt = 'Package: ' + cleanPath( txt.slice( 16 ) );
67+
}
68+
return txt;
69+
}
70+
71+
/**
72+
* Cleans up heading text.
73+
*
74+
* @private
75+
* @param {Array<DOMElement>} el - list of heading elements to clean
76+
*/
77+
function cleanHeadings( el ) {
78+
var i;
79+
for ( i = 0; i < el.length; i++ ) {
80+
el[ i ].innerHTML = cleanHeading( el[ i ].innerHTML );
81+
}
82+
}
83+
84+
/**
85+
* Updates a description.
86+
*
87+
* @private
88+
* @param {string} txt - description
89+
* @returns {string} updated description
90+
*/
91+
function updateDescription( txt ) {
92+
var ch;
93+
if ( txt.length === 0 ) {
94+
return txt;
95+
}
96+
ch = txt[ 0 ].toUpperCase();
97+
if ( ch !== txt[ 0 ] ) {
98+
txt = ch + txt.slice( 1 );
99+
}
100+
if ( txt.charCodeAt( txt.length-1 ) !== 46 ) { // .
101+
txt += '.';
102+
}
103+
return txt;
104+
}
105+
106+
/**
107+
* Updates `@param` and `@returns` descriptions.
108+
*
109+
* @private
110+
* @param {Array<DOMElement>} el - list of elements containing descriptions
111+
*/
112+
function updateDescriptions( el ) {
113+
var i;
114+
for ( i = 0; i < el.length; i++ ) {
115+
el[ i ].innerHTML = updateDescription( el[ i ].innerHTML );
116+
}
117+
}
118+
119+
/**
120+
* Main execution sequence.
121+
*
122+
* @private
123+
*/
124+
function main() {
125+
var el;
126+
127+
el = document.querySelectorAll( '.tsd-kind-external-module a' );
128+
cleanLinks( el );
129+
130+
el = document.querySelectorAll( '.tsd-breadcrumb a' );
131+
cleanLinks( el );
132+
133+
el = document.querySelectorAll( '.tsd-page-title h1' );
134+
cleanHeadings( el );
135+
136+
el = document.querySelectorAll( '.tsd-description .tsd-parameters .tsd-comment p' );
137+
updateDescriptions( el );
138+
139+
el = document.querySelectorAll( '.tsd-description .tsd-returns-title + p' );
140+
updateDescriptions( el );
141+
}
142+
143+
main();
144+
})();
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!doctype html>
2+
<html class="default no-js">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>{{#ifCond model.name '==' project.name}}{{project.name}}{{else}}{{model.name}} | {{project.name}}{{/ifCond}}</title>
7+
<meta name="description" content="">
8+
<meta name="viewport" content="width=device-width, initial-scale=1">
9+
10+
<link rel="stylesheet" href="{{relativeURL "assets/css/main.css"}}">
11+
<link rel="stylesheet" href="{{relativeURL "assets/css/overrides.css"}}">
12+
</head>
13+
<body>
14+
15+
{{> header}}
16+
17+
<div class="container container-main">
18+
<div class="row">
19+
<div class="col-8 col-content">
20+
{{{contents}}}
21+
</div>
22+
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
23+
<nav class="tsd-navigation primary">
24+
<ul>
25+
{{#each navigation.children}}
26+
{{> navigation}}
27+
{{/each}}
28+
</ul>
29+
</nav>
30+
31+
<nav class="tsd-navigation secondary menu-sticky">
32+
<ul class="before-current">
33+
{{#each toc.children}}
34+
{{> toc.root}}
35+
{{/each}}
36+
</ul>
37+
</nav>
38+
</div>
39+
</div>
40+
</div>
41+
42+
{{> footer}}
43+
44+
<div class="overlay"></div>
45+
<script src="{{relativeURL "assets/js/main.js"}}"></script>
46+
<script src="{{relativeURL "assets/js/theme.js"}}"></script>
47+
<script>if (location.protocol == 'file:') document.write('<script src="{{relativeURL "assets/js/search.js"}}"><' + '/script>');</script>
48+
49+
{{> analytics}}
50+
51+
</body>
52+
</html>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{#with comment}}
2+
{{#if hasVisibleComponent}}
3+
<div class="tsd-comment tsd-typography">
4+
{{#if shortText}}
5+
<div class="lead">
6+
{{#markdown}}{{{shortText}}}{{/markdown}}
7+
</div>
8+
{{/if}}
9+
{{#if text}}
10+
{{#markdown}}{{{text}}}{{/markdown}}
11+
{{/if}}
12+
{{#if tags}}
13+
{{#each tags}}
14+
{{#ifCond tagName "!==" "example"}}
15+
{{#if @first}}
16+
<dl class="tsd-comment-tags">
17+
{{/if}}
18+
<dt>{{tagName}}</dt>
19+
<dd>{{#markdown}}{{{text}}}{{/markdown}}</dd>
20+
{{#if @last}}
21+
</dl>
22+
{{/if}}
23+
{{/ifCond}}
24+
{{/each}}
25+
{{/if}}
26+
</div>
27+
{{/if}}
28+
{{/with}}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{{#unless hideSources}}
2+
{{> member.sources}}
3+
{{/unless}}
4+
5+
{{> comment}}
6+
7+
{{#if typeParameters}}
8+
<h4 class="tsd-type-parameters-title">Type parameters</h4>
9+
{{> typeParameters}}
10+
{{/if}}
11+
12+
{{#if parameters}}
13+
<h4 class="tsd-parameters-title">Parameters</h4>
14+
<ul class="tsd-parameters">
15+
{{#each parameters}}
16+
<li>
17+
<h5>{{#compact}}
18+
{{#each flags}}
19+
<span class="tsd-flag ts-flag{{this}}">{{this}}</span>&nbsp;
20+
{{/each}}
21+
{{#if flags.isRest}}<span class="tsd-signature-symbol">...</span>{{/if}}
22+
{{name}}:&nbsp;
23+
{{#with type}}{{>type}}{{/with}}
24+
{{#if defaultValue}}
25+
<span class="tsd-signature-symbol">
26+
&nbsp;=&nbsp;
27+
{{defaultValue}}
28+
</span>
29+
{{/if}}
30+
{{/compact}}</h5>
31+
32+
{{> comment}}
33+
34+
{{#if type.declaration}}
35+
{{#with type.declaration}}
36+
{{> parameter}}
37+
{{/with}}
38+
{{/if}}
39+
</li>
40+
{{/each}}
41+
</ul>
42+
{{/if}}
43+
44+
{{#if type}}
45+
<h4 class="tsd-returns-title">Returns {{#with type}}{{>type}}{{/with}}</h4>
46+
47+
{{#if comment.returns}}
48+
{{#markdown}}{{{comment.returns}}}{{/markdown}}
49+
{{/if}}
50+
51+
{{#if type.declaration}}
52+
{{#with type.declaration}}
53+
{{> parameter}}
54+
{{/with}}
55+
{{/if}}
56+
{{/if}}
57+
58+
{{#if comment}}
59+
{{#with comment}}
60+
{{#if tags}}
61+
{{#each tags}}
62+
{{#ifCond tagName "===" "example"}}
63+
<h4 class="tsd-example-title">Example</h4>
64+
<div>{{#markdown}}```javascript{{{text}}}```{{/markdown}}</div>
65+
{{/ifCond}}
66+
{{/each}}
67+
{{/if}}
68+
{{/with}}
69+
{{/if}}

0 commit comments

Comments
 (0)