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

HTML output: Display all levels of parameter properties. #933

Merged
merged 5 commits into from
Oct 4, 2017
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
127 changes: 119 additions & 8 deletions __tests__/__snapshots__/bin.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ exports[`--config 1`] = `
#withOptions
</a></li>

<li><a
href='#klasswithdeepoptions'
class='regular pre-open'>
#withDeepOptions
</a></li>

</ul>


Expand Down Expand Up @@ -773,16 +779,20 @@ k.isArrayOfBuffers();</pre>
<tbody class='mt1'>

<tr>
<td class='break-word'><span class='code bold'>options.foo</span> <code class='quiet'><a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String\\">string</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>
<td class='break-word'><span class='code bold'>options.foo</span> <code class='quiet'><a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String\\">string</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>



<tr>
<td class='break-word'><span class='code bold'>options.bar</span> <code class='quiet'><a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number\\">number</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>
<td class='break-word'><span class='code bold'>options.bar</span> <code class='quiet'><a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number\\">number</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>



</tbody>
</table>
Expand Down Expand Up @@ -813,6 +823,107 @@ k.isArrayOfBuffers();</pre>



</section>

</div>
</div>

<div class='border-bottom' id='klasswithdeepoptions'>
<div class=\\"clearfix small pointer toggle-sibling\\">
<div class=\\"py1 contain\\">
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
<span class='code strong strong truncate'>withDeepOptions(options)</span>
</div>
</div>
<div class=\\"clearfix display-none toggle-target\\">
<section class='p2 mb2 clearfix bg-white minishadow'>



<p>A function with a deep options parameter</p>


<div class='pre p1 fill-light mt0'>withDeepOptions(options: <a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\\">Object</a>)</div>











<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>

<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\\">Object</a>)</code>

</div>

<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>

<tr>
<td class='break-word'><span class='code bold'>options.foo</span> <code class='quiet'><a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String\\">string</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>



<tr>
<td class='break-word'><span class='code bold'>options.bar</span> <code class='quiet'><a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\\">Object</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>


<tr>
<td class='break-word'><span class='code bold'>options.bar.buz</span> <code class='quiet'><a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String\\">string</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>






</tbody>
</table>

</div>

</div>















</section>

</div>
Expand Down
127 changes: 119 additions & 8 deletions __tests__/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,12 @@ exports[`html nested.input.js 1`] = `
#withOptions
</a></li>

<li><a
href='#klasswithdeepoptions'
class='regular pre-open'>
#withDeepOptions
</a></li>

</ul>


Expand Down Expand Up @@ -1538,16 +1544,20 @@ k.isArrayOfBuffers();</pre>
<tbody class='mt1'>

<tr>
<td class='break-word'><span class='code bold'>options.foo</span> <code class='quiet'><a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String\\">string</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>
<td class='break-word'><span class='code bold'>options.foo</span> <code class='quiet'><a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String\\">string</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>



<tr>
<td class='break-word'><span class='code bold'>options.bar</span> <code class='quiet'><a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number\\">number</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>
<td class='break-word'><span class='code bold'>options.bar</span> <code class='quiet'><a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number\\">number</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>



</tbody>
</table>
Expand Down Expand Up @@ -1578,6 +1588,107 @@ k.isArrayOfBuffers();</pre>



</section>

</div>
</div>

<div class='border-bottom' id='klasswithdeepoptions'>
<div class=\\"clearfix small pointer toggle-sibling\\">
<div class=\\"py1 contain\\">
<a class='icon pin-right py1 dark-link caret-right'>▸</a>
<span class='code strong strong truncate'>withDeepOptions(options)</span>
</div>
</div>
<div class=\\"clearfix display-none toggle-target\\">
<section class='p2 mb2 clearfix bg-white minishadow'>



<p>A function with a deep options parameter</p>


<div class='pre p1 fill-light mt0'>withDeepOptions(options: <a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\\">Object</a>)</div>











<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>

<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\\">Object</a>)</code>

</div>

<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>

<tr>
<td class='break-word'><span class='code bold'>options.foo</span> <code class='quiet'><a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String\\">string</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>



<tr>
<td class='break-word'><span class='code bold'>options.bar</span> <code class='quiet'><a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\\">Object</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>


<tr>
<td class='break-word'><span class='code bold'>options.bar.buz</span> <code class='quiet'><a href=\\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String\\">string</a></code>
</td>
<td class='break-word'><span></span></td>
</tr>






</tbody>
</table>

</div>

</div>















</section>

</div>
Expand Down
9 changes: 9 additions & 0 deletions __tests__/fixture/html/nested.input.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ Klass.prototype.getFoo = function() {
*/
Klass.prototype.withOptions = function(options, otherOptions) {};

/**
* A function with a deep options parameter
* @param {Object} options
* @param {string} options.foo
* @param {Object} options.bar
* @param {string} options.bar.buz
*/
Klass.prototype.withDeepOptions = function(options) {};

/**
* @typedef CustomError
* @name CustomError
Expand Down
3 changes: 2 additions & 1 deletion src/default_theme/index._
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
<%= renderSection({
section: s,
renderSection: renderSection,
renderSectionList: renderSectionList
renderSectionList: renderSectionList,
renderParamProperty: renderParamProperty
}) %>
<% } else { %>
<div class='keyline-top-not py2'><%=renderNote({ note: s })%></div>
Expand Down
17 changes: 11 additions & 6 deletions src/default_theme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ module.exports = function(
comments: Array<Comment>,
config: DocumentationConfig
) {
var linkerStack = new LinkerStack(
config
).namespaceResolver(comments, function(namespace) {
var slugger = new GithubSlugger();
return '#' + slugger.slug(namespace);
});
var linkerStack = new LinkerStack(config).namespaceResolver(
comments,
function(namespace) {
var slugger = new GithubSlugger();
return '#' + slugger.slug(namespace);
}
);

var formatters = createFormatters(linkerStack.link);

Expand Down Expand Up @@ -98,6 +99,10 @@ module.exports = function(
fs.readFileSync(path.join(__dirname, 'note._'), 'utf8'),
sharedImports
);
sharedImports.imports.renderParamProperty = _.template(
fs.readFileSync(path.join(__dirname, 'paramProperty._'), 'utf8'),
sharedImports
);

var pageTemplate = _.template(
fs.readFileSync(path.join(__dirname, 'index._'), 'utf8'),
Expand Down
15 changes: 15 additions & 0 deletions src/default_theme/paramProperty._
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<tr>
<td class='break-word'><span class='code bold'><%- property.name %></span> <code class='quiet'><%= formatType(property.type) %></code>
<% if (property.default) { %>
(default <code><%- property.default %></code>)
<% } %></td>
<td class='break-word'><span><%= md(property.description, true) %></span></td>
</tr>
<% if(property.properties && property.properties.length) { %>
<% property.properties.forEach(function(childProperty) { %>
<%= renderParamProperty({
property: childProperty,
renderParamProperty: renderParamProperty
}) %>
<% }) %>
<% } %>
Loading