Skip to content

Commit a5e697a

Browse files
committed
up-port style fixes
1 parent b3d9956 commit a5e697a

File tree

10 files changed

+478
-432
lines changed

10 files changed

+478
-432
lines changed

default-theme/README.md

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
1-
# documentation-theme-default
2-
3-
[![Circle CI](https://circleci.com/gh/documentationjs/documentation-theme-default.svg?style=svg)](https://circleci.com/gh/documentationjs/documentation-theme-default)
1+
# the default theme
42

53
![](screenshot.png)
64

75
This is the default theme for [documentationjs](https://github.com/documentationjs):
8-
it consists of Handlebars templates and a few assets: a [highlight.js](https://highlightjs.org/)
6+
it consists of underscore templates and a few assets: a [highlight.js](https://highlightjs.org/)
97
theme and [basscss](http://www.basscss.com/) as a basic CSS framework.
108

119
This is bundled by default in documentation: it is the default theme.
1210

1311
The contents are the following:
1412

15-
* `index.hbs`, the main template that defines the document structure
16-
* `section.hbs`, a partial used to render each chunk of documentation
13+
* `index._`, the main template that defines the document structure
14+
* `section._`, a partial used to render each chunk of documentation
1715
* `assets/*`, any assets, including CSS & JS
18-
19-
# Helpers
20-
21-
* `{{format_params}}`: format function parameters, including the types
22-
included within.
23-
* `{{permalink}}`: in the context of a documentation chunk,
24-
return the chunk's permalink
25-
* `{{autolink TEXT}}`: given a chunk of text that may be a reference to a
26-
method, property, or other namespaced item, link the text to the item
27-
* `{{md TEXT}}`: render Markdown-formatted text, parsing additional
28-
JSDoc inline tag syntax and linking links when necessary
29-
* `{{format_type}}`: format a type definition, like `{string}` within a
30-
param definition.

default-theme/assets/style.css

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ h4:hover .anchorjs-link {
8585
}
8686
}
8787

88-
.pre, pre, code {
88+
.pre, pre, code, .code {
8989
font-family: Source Code Pro,Menlo,Consolas,Liberation Mono,monospace;
9090
font-size: 14px;
9191
}
@@ -118,3 +118,26 @@ ul {
118118
border-radius: 3px;
119119
box-sizing: border-box;
120120
}
121+
122+
table {
123+
border-collapse: collapse;
124+
}
125+
126+
.prose table th,
127+
.prose table td {
128+
padding:8px;
129+
border:1px solid #ddd;
130+
}
131+
132+
.prose table {
133+
border:1px solid #ddd;
134+
}
135+
136+
.prose-big {
137+
font-size: 18px;
138+
line-height: 30px;
139+
}
140+
141+
.quiet {
142+
opacity: 0.7;
143+
}

default-theme/circle.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

default-theme/index._

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@
8080
<div class='px2'>
8181
<% docs.forEach(function(s) { %>
8282
<% if (s.kind !== 'note') { %>
83-
<div class='keyline-top-not py2'><%=renderSection({ section: s, renderSection: renderSection })%></div>
83+
<%= renderSection({
84+
section: s,
85+
renderSection: renderSection,
86+
renderSectionList: renderSectionList
87+
}) %>
8488
<% } else { %>
8589
<div class='keyline-top-not py2'><%=renderNote({ note: s })%></div>
8690
<% } %>

default-theme/index.js

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,47 @@ module.exports = function (comments, options, callback) {
1818
});
1919

2020
var imports = {
21-
signature: function (section) {
21+
shortSignature: function (section, hasSectionName) {
22+
var prefix = '';
23+
if (section.kind === 'class') {
24+
prefix = 'new ';
25+
}
26+
if (section.kind !== 'function' && !hasSectionName) {
27+
return '';
28+
}
29+
if (hasSectionName) {
30+
return prefix + section.name + formatParameters(section, true);
31+
} else if (!hasSectionName && formatParameters(section)) {
32+
return formatParameters(section, true);
33+
}
34+
return '()';
35+
},
36+
signature: function (section, hasSectionName) {
2237
var returns = '';
2338
var prefix = '';
2439
if (section.kind === 'class') {
2540
prefix = 'new ';
41+
} else if (section.kind !== 'function') {
42+
return section.name;
2643
}
2744
if (section.returns) {
2845
returns = ': ' +
2946
formatMarkdown.type(section.returns[0].type, namespaces);
3047
}
31-
return prefix + section.name +
32-
formatParameters(section) + returns;
48+
if (hasSectionName) {
49+
return prefix + section.name +
50+
formatParameters(section) + returns;
51+
} else if (!hasSectionName && formatParameters(section)) {
52+
return section.name + formatParameters(section) + returns;
53+
}
54+
return section.name + '()' + returns;
3355
},
3456
md: function (ast, inline) {
3557
if (inline && ast && ast.children.length && ast.children[0].type === 'paragraph') {
36-
return formatMarkdown({
58+
ast = {
3759
type: 'root',
38-
children: ast.children[0].children
39-
}, namespaces);
60+
children: ast.children[0].children.concat(ast.children.slice(1))
61+
};
4062
}
4163
return formatMarkdown(ast, namespaces);
4264
},
@@ -59,6 +81,9 @@ module.exports = function (comments, options, callback) {
5981
renderNote: _.template(fs.readFileSync(path.join(__dirname, 'note._'), 'utf8'), {
6082
imports: imports
6183
}),
84+
renderSectionList: _.template(fs.readFileSync(path.join(__dirname, 'section_list._'), 'utf8'), {
85+
imports: imports
86+
}),
6287
highlight: function (str) {
6388
return highlight(str);
6489
}

default-theme/lib/format_parameters.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
2+
23
var formatMarkdown = require('./format_markdown');
4+
var Syntax = require('doctrine').Syntax;
35

46
/**
57
* Format a parameter name. This is used in formatParameters
@@ -9,8 +11,12 @@ var formatMarkdown = require('./format_markdown');
911
* @param {Object} param a param as a type spec
1012
* @returns {string} formatted parameter representation.
1113
*/
12-
function formatParameter(param) {
13-
return param.name + ': ' + formatMarkdown.type(param.type).replace(/\n/g, '');
14+
function formatParameter(param, short) {
15+
if (short) {
16+
return param.type.type == Syntax.OptionalType ? '[' + param.name + ']' : param.name;
17+
} else {
18+
return param.name + ': ' + formatMarkdown.type(param.type).replace(/\n/g, '');
19+
}
1420
}
1521

1622
/**
@@ -21,12 +27,12 @@ function formatParameter(param) {
2127
* @param {Object} section comment node from documentation
2228
* @returns {string} formatted parameters
2329
*/
24-
module.exports = function formatParams(section) {
30+
module.exports = function formatParams(section, short) {
2531
if (section.params) {
2632
return '(' + section.params.map(function (param) {
27-
return formatParameter(param);
33+
return formatParameter(param, short);
2834
}).join(', ') + ')';
29-
} else if (!section.params && (section.type === 'function' || section.type === 'class')) {
35+
} else if (!section.params && (section.kind === 'function' || section.kind === 'class')) {
3036
return '()';
3137
}
3238
return '';

default-theme/screenshot.png

-192 KB
Binary file not shown.

0 commit comments

Comments
 (0)