json-schema-org / json-schema-spec

The JSON Schema specification
http://json-schema.org/
Other
3.82k stars 266 forks source link

Convert the spec to Markdown #1335

Closed gregsdennis closed 1 year ago

gregsdennis commented 2 years ago

As we are no longer publishing with IETF, we don't need to use their tools. Going forward, we'd like to use markdown to author the spec instead of the current XML.

The first tasks are:

jdesrosiers commented 2 years ago

I have an idea about how hopefully make this process a bit less painful that it sounds. I believe the IETF tooling has the ability to convert from XML style to Markdown style. It's an IETF specific markdown flavor, but it should be easier to convert from one Markdown flavor to another than it would be to convert from XML to Markdown.

gregsdennis commented 1 year ago

We now have two approaches: #1357 (plain Markdown) and #1412 (IETF Kramdown).

I thought it would be wise to enumerate the document features we need/want. Then we can decide which of these approaches best captures that.

Looking at the current (IETF XML) published spec in HTML form, here's what's used:

In addition to the above, JSON Path (IETF Kramdown) also has these:

In addition to the features our current spec uses, OpenAPI (appears to use simple Markdown) also uses:

In addition to all of the above, do we also want (or could we make use of):


Lastly,

If we decide to go with basic Markdown, I think we might benefit from "borrowing" some rendering code from OpenAPI's process.

gregsdennis commented 1 year ago

After some time to consider the options, I think I prefer the simple markdown, assuming we can "borrow" the rendering from OpenAPI to extract the TOC and get automatic section numbering.

I'd also like to see support for comments for what we now have as CREFs. It doesn't have to be like the example I've linked to, but I think we need something.

jdesrosiers commented 1 year ago

I agree. I'll work on a proof of concept to ensure we can get a table of contents and automatic section numbering using a markdown engine that supports plugins such as https://remark.js.org/. Assuming that works out (I'm sure it will), I think we're ready to move forward with this step.

jdesrosiers commented 1 year ago

I finished the poc. The markdown I used is here and you can see the rendered result here. (I used water.css for some light default styling. It's not built-in to the rendering.)

Remark appears to be very powerful. There's not much we wouldn't be able to do, but we might have to get our hands dirty if we want to do anything terribly fancy. For example, I had to write a plugin to get numbered headings.

gregsdennis commented 1 year ago

Thanks for putting that together (and quickly). Would it be possible to update the markdown to include all the features we're currently using? Ordered and unordered lists will be a must, and special rendering for comments (CREFs) would be nice.

It's good that we can create plugins, and I really like that the code blocks have syntax highlighting!

jdesrosiers commented 1 year ago

I added a demo of ordered/unordered lists and tables as requested. I also added support for callout boxes, which can be used for comments as well as highlighting experimental sections.

Something missing is a references summary at the end, if that's something we want. We'd have to write a plugin, but I'm fairly confident I could handle that.

gregsdennis commented 1 year ago

That looks great, thanks! A little CSS love (not necessary for this POC), and I think we're good to go!