speced / respec

A tool for creating technical documents and web standards
https://respec.org/
Other
718 stars 388 forks source link

should maplike be passed to `reference()`? #2321

Closed marcoscaceres closed 5 years ago

marcoscaceres commented 5 years ago

@saschanaz, not sure this is right, but I think maplike should be passed to the reference() template handler (same way that sequence, record, and Promise are passed). I can then link "maplike" to the WebIDL spec via the template.

marcoscaceres commented 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?

saschanaz commented 5 years ago

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? 🤔

marcoscaceres commented 5 years ago

heh, see also "Promise type" 😂😭

marcoscaceres commented 5 years ago

keyword() would be fine... it's really up to us to classify them.

saschanaz commented 5 years ago

Yeah... we can pass Promise but we cannot pass maplike as an argument 😁

I think generic() (as a syntactic form) and modifier() might work.

marcoscaceres commented 5 years ago

I'm happy with whatever you think is best.

saschanaz commented 5 years ago

Okay, I'll go generic() first and modifier() later.

marcoscaceres commented 5 years ago

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>`;
    },
marcoscaceres commented 5 years ago

oops, let me fix the above.

saschanaz commented 5 years ago

I'll go generic() for generic-like syntactic forms including maplike, and modifier() for getter, stringifier etc.