Skip to content
This repository was archived by the owner on Jun 16, 2024. It is now read-only.

Support typedefs #60

Closed
wants to merge 2 commits into from
Closed
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
16 changes: 15 additions & 1 deletion publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ const builtins = {
"*": "#" // blerg
};

/**
* These are real @typedef's, neither callbacks nor import('abc').xyz
* This means they all have at least one property in `properties`.
*
* @type {Record<string, import('jsdoc').Doclet}
*/
const realTypedefs = {};

// Return an anchor link string from a type
const typeLink = (type) => {
// Get the name from string or type object
Expand All @@ -320,7 +328,7 @@ const typeLink = (type) => {
const builtin = builtins[name.toLowerCase()];
if (builtin) {
url = builtin;
} else if (name.endsWith('Callback')) {
} else if (name.endsWith('Callback') || realTypedefs[type]) {
url = `pc.html#${name}`;
} else {
url = clsUrl(name);
Expand Down Expand Up @@ -472,6 +480,12 @@ exports.publish = (taffyData, opts, tutorials) => {

// Strip all typedefs that are not callbacks
data(function () {
if (this.kind === 'typedef' && !this.name.endsWith('Callback')) {
if (this.properties?.length) {
realTypedefs[this.name] = this;
return false;
}
}
return this.kind === 'typedef' && !this.name.endsWith('Callback');
}).remove();

Expand Down
10 changes: 10 additions & 0 deletions tmpl/typedef.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,14 @@
{{/each}}
</table>
{{/if}}
{{#if obj.properties}}
<h4>Properties</h4>
<table>
{{#each obj.properties}}
<tr>
<td>{{name}}</td><td>{{{type-link type}}}</td><td>{{{parse description}}}</td>
</tr>
{{/each}}
</table>
{{/if}}
</div>