Skip to content

Commit

Permalink
Fixes to the display of @example in th edefault template.
Browse files Browse the repository at this point in the history
  • Loading branch information
micmath committed Feb 5, 2011
1 parent 3fb43f4 commit 15e0b19
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 75 deletions.
16 changes: 3 additions & 13 deletions modules/jsdoc/doclet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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({
Expand Down
24 changes: 13 additions & 11 deletions modules/jsdoc/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
*/
this.files = [];

/** The name of this package.
/** The kind of this package.
@readonly
@default
*/
this.kind = 'package';
Expand All @@ -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;
}

Expand Down
6 changes: 5 additions & 1 deletion modules/jsdoc/tag/dictionary/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
2 changes: 1 addition & 1 deletion templates/default/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
52 changes: 47 additions & 5 deletions templates/default/tmpl/container.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
2 changes: 2 additions & 0 deletions templates/default/tmpl/index.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
text-indent: -5000px;
}
</style>
</head>

Expand Down
113 changes: 69 additions & 44 deletions templates/default/tmpl/properties.mustache
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 15e0b19

Please sign in to comment.