mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Fixes to the display of @example in th edefault template.
This commit is contained in:
parent
3fb43f45c2
commit
15e0b19960
@ -238,14 +238,8 @@
|
||||
}
|
||||
|
||||
function split(docletSrc) {
|
||||
var tagSrcs = [],
|
||||
indent = '',
|
||||
indentMatch;
|
||||
|
||||
// trim off any leading whitespace, up to the first (at)
|
||||
var m = /^([^\S\n\r]+)@\S/m.exec(docletSrc);
|
||||
indentMatch = (m && m[1])? new RegExp('^'+m[1], 'gm') : null;
|
||||
|
||||
var tagSrcs = [];
|
||||
|
||||
// split out the basic tags, keep surrounding whitespace
|
||||
// like: @tagTitle tagBody
|
||||
docletSrc
|
||||
@ -255,12 +249,8 @@
|
||||
if ($) {
|
||||
var parsedTag = $.match(/^(\S+)(:?\s+(\S[\s\S]*))?/);
|
||||
|
||||
if (parsedTag) {
|
||||
if (parsedTag) {
|
||||
var [, tagTitle, tagText] = parsedTag;
|
||||
|
||||
if (tagText && indentMatch) {
|
||||
tagText = tagText.replace(indentMatch, '');
|
||||
}
|
||||
|
||||
if (tagTitle) {
|
||||
tagSrcs.push({
|
||||
|
||||
@ -20,7 +20,8 @@
|
||||
*/
|
||||
this.files = [];
|
||||
|
||||
/** The name of this package.
|
||||
/** The kind of this package.
|
||||
@readonly
|
||||
@default
|
||||
*/
|
||||
this.kind = 'package';
|
||||
@ -47,16 +48,17 @@
|
||||
*/
|
||||
this.version = json.version;
|
||||
|
||||
/** The licenses of this package.
|
||||
@type {Array<Object>}
|
||||
@example
|
||||
"licenses": [
|
||||
{
|
||||
"type": "GPLv2",
|
||||
"url": "http://www.example.com/licenses/gpl.html",
|
||||
}
|
||||
]
|
||||
*/
|
||||
/**
|
||||
* The licenses of this package.
|
||||
* @type {Array<Object>}
|
||||
* @example
|
||||
* "licenses": [
|
||||
* {
|
||||
* "type": "GPLv2",
|
||||
* "url": "http://www.example.com/licenses/gpl.html",
|
||||
* }
|
||||
* ]
|
||||
*/
|
||||
this.licenses = json.licenses;
|
||||
}
|
||||
|
||||
|
||||
@ -146,7 +146,11 @@
|
||||
|
||||
dictionary.defineTag('example', {
|
||||
keepsWhitespace: true,
|
||||
mustHaveValue: true
|
||||
mustHaveValue: true,
|
||||
onTagged: function(doclet, tag) {
|
||||
if (!doclet.examples) { doclet.examples = []; }
|
||||
doclet.examples.push(tag.value);
|
||||
}
|
||||
});
|
||||
|
||||
dictionary.defineTag('exception', {
|
||||
|
||||
@ -171,7 +171,7 @@
|
||||
generate('Modules', modules, 'modules.html');
|
||||
generate('Classes', classes, 'classes.html');
|
||||
generate('Namespaces', namespaces, 'namespaces.html');
|
||||
|
||||
//dump(classes)
|
||||
function generate(title, docs, filename) {
|
||||
var path = outdir + '/' + filename,
|
||||
html = Mustache.to_html(
|
||||
|
||||
@ -182,16 +182,58 @@
|
||||
width: 85px;
|
||||
clear: both;
|
||||
}
|
||||
dl.param-properties dd.yesDef {
|
||||
text-indent: -5000px;
|
||||
}
|
||||
|
||||
.no-docs
|
||||
{
|
||||
|
||||
.no-docs {
|
||||
font-style: italic;
|
||||
font-weight: lighter;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.property {
|
||||
margin-left: 30px;
|
||||
}
|
||||
.property-head {
|
||||
margin-left: -30px;
|
||||
display: block;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
.property-head h4 {
|
||||
color: #4782B5;
|
||||
}
|
||||
.property-title {
|
||||
float: left;
|
||||
margin: 0;
|
||||
padding: 0 20px 0 0;
|
||||
font-style: italic;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
.property-summary {
|
||||
color: #999;
|
||||
font-size: 1em;
|
||||
}
|
||||
.property-details {
|
||||
clear: both;
|
||||
overflow: hidden;
|
||||
}
|
||||
.property-details dt {
|
||||
font-weight: bold;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
|
||||
.example-code
|
||||
{
|
||||
border: 1px solid #999;
|
||||
padding: 2px 2px 2px 8px;
|
||||
margin-right: 24px;
|
||||
background-color: #FFFDE1;
|
||||
}
|
||||
|
||||
.yesDef {
|
||||
text-indent: -5000px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
|
||||
@ -138,6 +138,8 @@
|
||||
text-indent: -5000px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
|
||||
@ -1,45 +1,70 @@
|
||||
<div class="property">
|
||||
|
||||
<dt class="furtherDetailHeading" id="method:{{name}}">
|
||||
<h4 class="property-title">{{name}}</h4>
|
||||
</dt>
|
||||
<dd>
|
||||
<dl class="type-details">
|
||||
{{#summary}}
|
||||
<dt>
|
||||
Summary
|
||||
</dt>
|
||||
<dd>
|
||||
{{{summary}}}
|
||||
</dd>
|
||||
{{/summary}}
|
||||
|
||||
{{#type}}
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
{{#names}}
|
||||
<span class="param-type">{{#linkTo}}{{.}}{{/linkTo}}</span>{{^last?}} | {{/last?}}{{#last?}} {{/last?}}
|
||||
{{/names}}
|
||||
</dd>
|
||||
{{/type}}
|
||||
|
||||
{{#nullable}}
|
||||
<dt>
|
||||
Nullable
|
||||
</dt>
|
||||
<dd class="yesDef">
|
||||
Yes
|
||||
</dd>
|
||||
{{/nullable}}
|
||||
|
||||
{{#defaultvalue}}
|
||||
<dt>
|
||||
Default Value
|
||||
</dt>
|
||||
<dd class="yesDef">
|
||||
{{defaultvalue}}
|
||||
</dd>
|
||||
{{/defaultvalue}}
|
||||
</dl>
|
||||
</dd>
|
||||
<dl class="property-head" id="property:{{name}}">
|
||||
<dt class="property-name">
|
||||
<h4 class="property-title">{{name}}</h4>
|
||||
</dt>
|
||||
<dd class="property-summary">
|
||||
{{{summary}}}
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="property-details">
|
||||
{{#description}}
|
||||
<dt>
|
||||
Description
|
||||
</dt>
|
||||
<dd>
|
||||
{{{description}}}
|
||||
</dd>
|
||||
{{/description}}
|
||||
|
||||
{{#type}}
|
||||
<dt>
|
||||
Type
|
||||
</dt>
|
||||
<dd>
|
||||
{{#names}}
|
||||
<span class="type-name">{{#linkTo}}{{.}}{{/linkTo}}</span>{{^last?}} | {{/last?}}{{#last?}} {{/last?}}
|
||||
{{/names}}
|
||||
</dd>
|
||||
{{/type}}
|
||||
|
||||
{{#readonly}}
|
||||
<dt>
|
||||
Readonly
|
||||
</dt>
|
||||
<dd class="yesDef">
|
||||
Yes
|
||||
</dd>
|
||||
{{/readonly}}
|
||||
|
||||
{{#nullable}}
|
||||
<dt>
|
||||
Nullable
|
||||
</dt>
|
||||
<dd class="yesDef">
|
||||
Yes
|
||||
</dd>
|
||||
{{/nullable}}
|
||||
|
||||
{{#defaultvalue}}
|
||||
<dt>
|
||||
Default Value
|
||||
</dt>
|
||||
<dd>
|
||||
{{defaultvalue}}
|
||||
</dd>
|
||||
{{/defaultvalue}}
|
||||
|
||||
{{#examples}}
|
||||
<dt>
|
||||
Example
|
||||
</dt>
|
||||
<dd>
|
||||
<div class="example-code">
|
||||
<pre class="prettyprint lang-js"><code>{{.}}</code></pre>
|
||||
</div>
|
||||
</dd>
|
||||
{{/examples}}
|
||||
</dl>
|
||||
</div>
|
||||
Loading…
x
Reference in New Issue
Block a user