Closed marcoscaceres closed 5 years ago
For reference, this is what I'm working on:
reference(wrapped) {
switch (wrapped) {
case "maplike":
case "sequence":
case "record":
return hyperHTML`<a data-xref-type="dfn">${wrapped}</a>`;
case "Promise":
return hyperHTML`<a data-xref-type="dfn" data-lt="Promise type">${wrapped}</a>`;
default:
return hyperHTML`<a data-xref-type="_IDL_">${wrapped}</a>`;
}
},
It works nicely for everything except maplike
:) ... is there others?
Thing is that they are syntactic keywords rather than general IDL identifiers. maplike
/setlike
/iterable
are not even type names. I'd like to add a new hook for those syntactic things (mainly to link anonymous getters through the keyword getter
), but not sure what would be the best name.
keyword()
would work but then why some keywords but not others? 🤔
heh, see also "Promise type" 😂😭
keyword()
would be fine... it's really up to us to classify them.
Yeah... we can pass Promise
but we cannot pass maplike
as an argument 😁
I think generic()
(as a syntactic form) and modifier()
might work.
I'm happy with whatever you think is best.
Okay, I'll go generic()
first and modifier()
later.
Ok, does this look right then?:
generic(type){
switch (type) {
case "Promise":
return hyperHTML`<a data-xref-type="dfn" data-lt="Promise type">${type}</a>`;
default:
// sequence, record...
return hyperHTML`<a data-xref-type="dfn">${type}</a>`;
}
},
modifier(keyword) {
// maplike, setlike, and iterable
return hyperHTML`<a data-xref-type="dfn">${keyword}</a>`
},
reference(wrapped) {
return hyperHTML`<a data-xref-type="_IDL_">${wrapped}</a>`;
},
oops, let me fix the above.
I'll go generic()
for generic-like syntactic forms including maplike
, and modifier()
for getter
, stringifier
etc.
@saschanaz, not sure this is right, but I think
maplike
should be passed to thereference()
template handler (same way that sequence, record, and Promise are passed). I can then link "maplike" to the WebIDL spec via the template.