Sort properties first/last
Closed this issue · 2 comments
Right now, properties and methods are mixed, so a class description could look like this when sorted:
Class
Class.aMethod
Class.bMethod
Class.cProperty
Class.dMethod
Class.eProperty
It would be great if there was an option to sort first (or last) methods and then properties, so the class description would look like this:
Class
Class.aMethod
Class.bMethod
Class.dMethod
Class.cProperty
Class.eProperty
or (properties first):
Class
Class.cProperty
Class.eProperty
Class.aMethod
Class.bMethod
Class.dMethod
I am planning to add the option to the template I am working on but am not sure how to do it: I guess I could do that in the route
event?
As you noted, this is a template-related feature rather than core. The default template that will come with Docma v2 will have a quick-filter toolbar for symbol types. This is not exactly what you want but serves a similar purpose.
If you're creating a custom template, one way to do it is via dust templates. Take a look at sidebar.html partial in default template for an example. This uses the docma.symbols
string array for the sidebar list but you need the full symbol definition to be able to filter in parse-time. So instead, you should use docma.documentation
object.
In dust templates, docma
is global so you'd directly use documentation
.
{#documentation}
{@eq key=kind value="function"}
<span class="function">{longname}</span>
{/eq}
{/documentation}
...
Another way would be, via the render
event:
docma.on('render', function (currentRoute) {
if (currentRoute && currentRoute.type === 'api') {
// if this is a route for API docs... (so you have the symbols sidebar)
// alter DOM here..
}
});
Closing this. Feel free to re-open if needed.
UPDATE: v2.0.0 has improved sorting logic. See BuildConfiguration
for jsdoc.sort
option.