Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML presentation ("cosmetic") controls #42

Closed
VladimirAlexiev opened this issue Jul 4, 2022 · 9 comments
Closed

YAML presentation ("cosmetic") controls #42

VladimirAlexiev opened this issue Jul 4, 2022 · 9 comments
Labels
out-of-scope Out of Scope UCR Issue on Use Case/Recommendation
Projects

Comments

@VladimirAlexiev
Copy link
Contributor

VladimirAlexiev commented Jul 4, 2022

As an information architect.
When serializing YAML.
I want control over all YAML presentation ("cosmetic") features.
So that I can obtain a YAML representation that is most readable and usable for my case.

What "cosmetic" features do I mean:

  • optional header --- and footer ...
  • Number of spaces used to indent
  • Use of flow-style vs block-style for particular pieces of YAML
  • Ordering of keys
  • Alias names
  • Formatting of text blocks
  • String quoting
  • Use of escapes and code points in strings
  • Serialization of booleans
  • etc etc

How to list all controllable features systematically?

Here are the options of some serializers:

Most of these are for Perl, could you please add links to serializers in other languages?

Maybe we should also turn to linters. https://megalinter.github.io/latest/descriptors/yaml/ can use 3 YAML linters:

Finally, this specifically aims to fix presentation, but currently has a somewhat limited set of options

@VladimirAlexiev VladimirAlexiev added the UCR Issue on Use Case/Recommendation label Jul 4, 2022
@ioggstream
Copy link
Contributor

ioggstream commented Jul 4, 2022

@VladimirAlexiev do you think we should define a recommended serialization for YAML-LD, or just to define a linter configuration for this repo (:+1: ) ?

I think YAML serialization configuration should be delegated to YAML and implementations, because they will improve over time.

An interesting caveat is instead the one related to multiple documents in the same stream, e.g.

---
a: 1
...
---
a: 2
...

This was referenced Jul 4, 2022
@VladimirAlexiev
Copy link
Contributor Author

@ioggstream We should definitely use a consistent style of all our examples, so we need a linter configuration for this repo.

serialization configuration should be delegated to YAML and implementations,

Maybe. However:

  • The JSON-LD Context defines a lot about the form of serialized JSON: in fact all information aspects, but no presentation aspects.
  • If the primary goal of YAML-LD is readability, why shouldn't presentation aspects be part of a "YAML-LD Context" (YAML-LD context and frame #44)?

@gkellogg gkellogg added this to UCR in YAML-LD Jul 4, 2022
@gkellogg
Copy link
Member

gkellogg commented Jul 4, 2022

I think adopting a consistent style for our examples is important, but 👎 on putting anything about a required style in the spec itself. In any case, that should be a YAML concern, not a YAML-LD concern.

@OR13
Copy link

OR13 commented Jul 6, 2022

I'm struggling to grok exactly what is proposed here, but I interpret this as a call for supporting the "non round trip-able to JSON features"... which I am in favor of... just we need to start using unique names for both cases.

I suggest we just start considering them different media types...

application/ld+yaml vs application/ld+json+yaml.

One is JSON-LD round trip-able... the other is not.

application/ld+yaml should allow for cosmetic features... +1 to the proposal.

@ioggstream
Copy link
Contributor

ioggstream commented Jul 7, 2022

@OR13 I will vote after the testcases are written :) These days I'm struggling even with very simple issues like extending fragment identification to YAML streams ietf-wg-httpapi/mediatypes#55 since I just discovered that future versions of YAML might consider that docs in a stream are not independent :P

@VladimirAlexiev
Copy link
Contributor Author

I agree with @gkellogg and @ioggstream that the spec shouldn't claim any required style. But it can point to a linter configuration as a useful resource.

@gkellogg
Copy link
Member

gkellogg commented Sep 1, 2022

I agree with @gkellogg and @ioggstream that the spec shouldn't claim any required style. But it can point to a linter configuration as a useful resource.

Any such mechanism should probably work for JSON as well. But, I'm not aware of any such convention, or how we might signal that, other than through API extensions.

@gkellogg
Copy link
Member

Discussed at TPAC F2F and resolved to close as out-of-scope.

YAML-LD automation moved this from UCR to Done Sep 13, 2022
@gkellogg gkellogg added the out-of-scope Out of Scope label Sep 13, 2022
@VladimirAlexiev
Copy link
Contributor Author

@gkellogg

such mechanism should probably work for JSON as well

YAML has a lot more formatting options, eg to limit display line length of strings.
In JSON you can only vary the indentation and newlines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
out-of-scope Out of Scope UCR Issue on Use Case/Recommendation
Projects
Development

No branches or pull requests

4 participants