Proof-of-concept implementation of the Web Publ. Manifest -> JavaScript per WebIDL

Dear all,

I have implemented, last week and this, a conversion from our definition of a manifest to a JavaScript class instance that embodies the WebIDL specification as it is today[1]. The result is on [2].

I did this as a means to see whether (a) it is doable in the first place and (b) whether there are undefined things in the draft; in other words, it was my way for a first check of the draft. It complements the great work of Hadrien defining the JSON Schema for the WPM (I actually plan to incorporate the schema checking into the implementation at some point.)

The answer on (a) is obviously a yes. I would also say that it is not that complex either, although it has lots of repetitive  tasks. These include turning most of the input into arrays (no big deal, but had to be done almost everywhere) or turning most of the string values into Localizable strings. None of them are big deal.

To answer on (b) some issues were raised last week due to questions I was asking myself while doing the implementation. I also took some decisions on how to react on error situations, something that we will have to specifiy in the spec; my basic approach was:

- No exception should be raised if there are issues but, rather, warning/errors are stored in a separate place. I believe in a real implementation situation this is a better way than some sort of a draconian reaction…
- If a value (e.g., a PublicationLink without a url, or a Localizable string without a value) is unusable, then remove it from the results (with a suitable error message). Eg, that value would be missing when looking at the list of authors.
- In general, return values when looking at an attribute should either be a proper value or a single clear value of missing entry (in JavaScript, I return `undefined` everywhere).

Obviously, the next step would be to document the essence of the code in the current draft, completing/changing the Publication Lifecycle[3] section in the draft.

I hope it will prove to be useful at some point. If some other proof-of-concept implementers want to re-use the code, I would just be thrilled (but I am not a really good JS programmer, so do it with care:-)

Ivan


[1] https://w3c.github.io/wpub/#webidl <https://w3c.github.io/wpub/#webidl>
[2] https://github.com/iherman/WPManifest <https://github.com/iherman/WPManifest>
[3] https://w3c.github.io/wpub/#wp-lifecycle <https://w3c.github.io/wpub/#wp-lifecycle>

----
Ivan Herman, W3C
Publishing@W3C Technical Lead
Home: http://www.w3.org/People/Ivan/ <http://www.w3.org/People/Ivan/>
mobile: +31-641044153
ORCID ID: https://orcid.org/0000-0003-0782-2704 <https://orcid.org/0000-0003-0782-2704>

Received on Friday, 10 August 2018 07:10:21 UTC