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

Conversation

MichelSimonot
Copy link
Contributor

Hello,

I ran into an issue where certain portions of the JSON output was not being included in the HTML output. Specifically, properties underneath parameter properties (section.params.properties.properties). These sub-properties are included in the MD output, so I assumed they should be part of the HTML output. So here's my fix.

JSDoc

// testFile.js
/**
 * Documentation for some function.
 * @name testFunction
 * @param {Object} options An options parameter.
 * @param  {Object} options.firstLevelOne A property of the options parameter.
 * @param  {Boolean} options.firstLevelOne.secondLevelOne A second level property.
 * @param  {Boolean} options.firstLevelOne.secondLevelTwo A second second level property.
 * @param  {Boolean} options.firstLevelTwo A second first level property.
 */
export function testFunction(options) {
    return options;
}

Expected HTML Output

paramproperty - expected html

Actual HTML Output

As above, but both of the secondLevel... property rows are omitted.

The sub-properties were being omitted because section._ only iterates over param.properties and doesn't check for anything underneath it (here). So I created a new template (paramProperty._) (to replace that portion of section._) that recursively checks for properties and renders them (here). With this, the actual HTML output matches [my] expected HTML output.

I updated the test case input (html/nested.input.js) to include a case for this, but haven't updated the snapshots to reflect the new output. Wasn't sure what your process is for this.

MichelSimonot added 4 commits October 3, 2017 11:02
    - Split the parameter property template portion into its own partial.
    - Have the new partial recursively call itself if there are sub-properties.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 86.031% when pulling ae2bdf3 on MichelSimonot:master into e203df5 on documentationjs:master.

@tmcw
Copy link
Member

tmcw commented Oct 4, 2017

Awesome! What I usually do to update snapshots is run ./node_modules/.bin/jest -u, which should do it.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 86.031% when pulling 1e7e1bc on MichelSimonot:master into e203df5 on documentationjs:master.

@tmcw
Copy link
Member

tmcw commented Oct 4, 2017

👍 Awesome, thanks!

@tmcw tmcw merged commit 7a548eb into documentationjs:master Oct 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants