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

[RFC 0072] Switch to CommonMark for documentation #72

Merged
merged 10 commits into from
Nov 4, 2020
302 changes: 302 additions & 0 deletions rfcs/0000-commonmark-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
---
feature: commonmark-docs
start-date: 2020-07-05
author: mboes
---

# Summary
[summary]: #summary

Nix, Nixpkgs and NixOS documentation is currently in Docbook format.
We propose to migrate all existing content to CommonMark, a flavour of
Markdown.

# Motivation
[motivation]: #motivation

Documentation ought to be easy to write, easy to maintain, easy to
make pretty, and its format be so boring as to seldom be the object of
future RFC's. But beyond that, the significance of the documentation
format is in its very real impact on the perception of the project.
Documentation is the storefront of any project online in addition to
its front page. Modern looking documentation that can be edited at the
click of a button sends a signal: that the Nix* projects are forward
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@blaggacao blaggacao Aug 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And ventilating a little further my frustration of not having been able to get a doc improvement (construed and) merged myself within due effort: https://discourse.nixos.org/t/dockertools-imprecisions/8770/3 -- please read kindly: in the end, I just care.

looking, are welcoming to novice contributors and feel familiar.

The motivation to switch away from Docbook is that it's unfamiliar.
None of the [top 100 projects on Github][gitstar-rankings] use
Docbook. The motivation to switch to CommonMark is that among these
projects, since roughly 10 times more projects use Markdown (or some
variation thereof) than all other documentation formats combined, it
can be considered the default. It's worth considering alternatives,
but the burden ought to lie with the proponents of other format/tool
combinations to convince this community that following the precedent
set by the overwhelming majority of communities larger than ours won't
work well for us.

Increasing the number of contributors to the documentation, increasing
its coverage and improving its quality are social goals, not technical
requirements. To recruit more writers and users, should we make
support for callouts, admonitions and a precise taxonomy (like Docbook
has) requirements? Should literate programming and the ability to do
transclusions also be requirements? Does reducing documentation build
times from seconds to milliseconds matter? Maybe meeting these
requirements helps us reach our social goals. Maybe they are
immaterial. What we can go by is the following piece of evidence:
nearly all of the most beautifully laid out, high-quality and
easy-to-navigate documentation in the GitHub Top 100 are in
CommonMark. The only notable exception is the [Tensorflow
documentation][tensorflow-docs], which uses Jupyter notebooks for
everything.

Consider the following 5 examples of great Markdown documentation in
terms of breadth, presentation and richness (cross references,
definition lists, tables, callouts, integration with playgrounds,
etc):

- [GatsbyJS documentation][gatsby-docs] (using Gatsby with [MDX][mdx])
- Facebook's [React documentation][react-docs] (using Gatsby with
plain CommonMark)
- Microsoft's [VS Code documentation][vscode-docs] (using Jekyll)
- [Kubernetes documentation][kubernetes-docs] (using Hugo)
- The [Rust book][rust-docs] (using mdBook)

The goal of this RFC is to change the *form* of the current
documentation for Nix, Nixpkgs and NixOS to look similar to any one of
the above 5 projects (see requirements in the next section). We submit
that the least effort route to do so is to use the same toolchain as
they do (CommonMark or MDX input and one of Gatsby, Jekyll or Hugo to
generate a static site).

What all of the projects cited above have in common is a large
contributor base with heterogeneous skillsets and multiple
subcommunities. Just like in Nixpkgs, they cannot leverage the
hegemony of RST in Python, because not all their users are Python
programmers. They prefer not to count on writers learning Docbook or
Asciidoc, because many documentation patches are from casual
contributors. The *lingua franca* across subcommunities for both
Copy link
Member

@domenkozar domenkozar Jul 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's exactly where the marketing and reality of Markdown differs. There are many standards of Markdown and most tooling implements their own format extensions, meaning you're not using Markdown but a flavor.

For that reason it's important to talk about the tooling used, as each documentation tool will use a different flavor and thus define the "vendor lock-in".

If not, does the RFC propose to ban extensions of the format?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why the title of this RFC has CommonMark in it, not Markdown. CommonMark is a well specified dialect of Markdown that is also a de facto standard (understood by GitHub, Sphinx, Gatsby, Pandoc and many others). We propose to use CommonMark for now: nothing added, nothing less.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's quite nice in theory, but in practice the need for extensions quickly arises. My bet is we'll use one even as we port the existing documentation.

For example there are no footnotes, tables in CommonMark, what do you propose to do with the existing ones?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TOC is another example of such feature.

Copy link
Member

@domenkozar domenkozar Jul 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only looking at the rust book, it's not just CommonMark as it uses extensions for includes: https://github.com/rust-lang/book/blob/master/src/ch18-03-pattern-syntax.md

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only looking at the rust book, it's not just CommonMark as it uses extensions for includes:

That's true. They use a preprocessor on top of Markdown. So do the projects I mention who use Hugo or Jekyll as their static site generator. These toolchains add special macros for includes. The Gatsby and React projects don't use that, and I believe we can get by just fine without a preprocessor given the current content.

Macros for textual includes could conceivably become useful down the road, but it will have little impact on users, who can still just write the CommonMark they know.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TOC is another example of such feature.

TOC's are a must in my book. I think we're in alignment there. Whether they need to be programmable from within the document markup is a different matter. The ReactJS documentation (and our demos) have TOC's auto-generated from the document structure. They are prominently displayed in the sidebar. Gatsby's documentation also has that. Although this is one other place where they use an MDX component: they go the extra mile and generate section specific "site maps" at the bottom of a few of their documentation pages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think CommonMark allows us to get most of the documentation writing done without many issues. In case one does touch upon its limits, things get harder, and one has to fallback to another language like e.g. HTML.

In my opinion this RFC should define what we fall back to. E.g., fallback to HTML, or, fallback to say reStructuredText? See e.g. how one can create a table with Sphinx + CommonMark:

    ```eval_rst
    +------------+------------+-----------+ 
    | Header 1   | Header 2   | Header 3  | 
    +============+============+===========+ 
    | body row 1 | column 2   | column 3  | 
    +------------+------------+-----------+ 
    | body row 2 | Cells may span columns.| 
    +------------+------------+-----------+ 
    ```

Clearly this now becomes toolchain-dependent. In this case falling back to reStructuredText instead of HTML still allows the creation of pdf's.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As soon as you start using HTML, you lose portability of any kind (which may not be a requirement, but then we need to pick the tooling and commit to it).

That's true, but in practice:

  1. HTML is seldom needed except for a few key things (tables and callouts),
  2. different parts of the documentation are written for different media types.

The man pages are written for man. Tables in man pages are not a must have (and even if they were they are still supported by a number of man generation tools even if they were, like go-md2man, Pandoc and possibly Sphinx). Some users may be interested in PDF output rather than HTML output, but that's a matter of having decent CSS for the print media type. Likewise, I don't think EPUB support should be the deciding factor either, and we likely don't want to support that officially. But for those users who really want it Pandoc understands CommonMark (including HTML tables) as an input very well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearly this now becomes toolchain-dependent. In this case falling back to reStructuredText instead of HTML still allows the creation of pdf's.

@FRidh what you're saying is that there exist corner cases, but those corner cases don't mean we're SOL - just that what happens then is not specified by any spec. I agree. AFAICS there are two or more tool choices available for all such corner cases (in particular tables) and all media types (in particular man pages). So long as this holds true, we're in a good place: it means we don't need to commit as part of this process to a specific implementation - just agree on the requirements for any such implementation, safe in the knowledge that satisfying the requirements won't be onerous.

There was enough bikeshedding in #64 that I'd rather make progress by agreeing on the format and the requirements for any toolchain, so that implementers don't have to spend heaps of time working towards a dead end because the community can't agree on the format (or indeed the requirements). (cc @domenkozar)

humans and their toolchains is Markdown. It's all the more easy to
create good looking documentation with Markdown that the tools
available to process it are plentiful and flexible (JavaScript
converters with plugin support like [Remark][remark], static site
generators by the dozen, [MDX][mdx] to extend CommonMark with
arbitrary React components, etc).

[gatsby-docs]: https://www.gatsbyjs.org/docs/
[gitstar-rankings]: https://gitstar-ranking.com/repositories
[kubernetes-docs]: https://kubernetes.io/docs/home/
[react-docs]: https://reactjs.org/docs/getting-started.html
[rust-docs]: https://doc.rust-lang.org/book/
[tensorflow-docs]: https://github.com/tensorflow/docs
[vscode-docs]: https://code.visualstudio.com/docs
[mdx]: https://github.com/mdx-js/mdx
[remark]: https://remark.js.org/

mboes marked this conversation as resolved.
Show resolved Hide resolved
# Detailed design
[design]: #detailed-design

AsciiDoc, CommonMark and RST are all formats that support basic
markup: emphasis, bold, (nested) (un)numbered lists, headings, inline
and display code, tables (as HTML in the case of CommonMark), etc. The
requirements we set below pertain to the appearance of the
documentation available on the website.

The key requirements we work towards are:

1. easy-to-find "Edit on GitHub" button to increase drive-by
contributions,
1. good quality documentation search engine,
1. syntax highlighting of all code,
1. separate page per chapter, instead of the current monolithic page
for each manual,
1. table of content for each chapter available in a side bar to easily
jump through long content,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “good quality search engine” part becomes less of a problem when you put everything on one page, because the browser’s search bar is a tool that works everywhere, without internet connection.

Do we have too much documentation to fit everything on one page? Or what is the reasoning behind splitting it up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. The reasoning for the split-up is that this is what other projects with extensive documentation do as well. Presumably to make the documentation less intimidating (imagine coming to a project for the first time and realizing you're going to need to wade through 40k+ words of documentation...), but I'm not a tech writer so I'm not sure whether there are strong reasons.

Navigating from section to section currently isn't easy. But that can be solved with a sidebar TOC whether we're in single-page or multi-page.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think that the wall of text that are the current manuals is intimidating for first-time users. A collapsible TOC on the side would greatly help, plus it also degrades gracefully to the current experience when one has no JS.

I do think a one-page-man is more annoying (and resource-intentive) on mobile devices, though.

Emacsy projects usually have both split and unified manpages; that could be another option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our single page manual is no longer indexed by Google.

Copy link
Member

@domenkozar domenkozar Jul 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasoning of split-up is that google will rank one-page SEO farms quite low.

Additionally, URLs have to be search engine friendly so that random first-time Nix contributor blog is not ranked higher than the official documentation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which instances are the manuals not shown?

I assume if you search for content that exists in the manual, the results won't be found by google (or rated very low).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “good quality search engine” part becomes less of a problem when you put everything on one page

I disagree. When I was new to Nix(OS) and I didn't know the terminology too well, I often had trouble finding things in the manual because I used too general terms (e.g. "build derivation") which resulted in a lot of unrelated results.

Also, on a search engine you can just combine terms that are relevant for the search, when performing a content-search in the manual using a browser you can't search e.g. for something like "nix rust derivation".

Don't get me wrong though, I really love the offline manual (including the PDF variants). Ideally, I'd love to see a split-up documentation on nixos.org and keep a single-page manual available offline (e.g. via nixos-help as it is currently the case).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which instances are the manuals not shown?

I assume if you search for content that exists in the manual, the results won't be found by google (or rated very low).

I googled "declarative package management" and the nixpkgs manual is the 3rd result.

@grahamc @domenkozar is this a case of the ranking being too low? It seems like the page is definitely indexed though.

Copy link
Member

@mweinelt mweinelt Jul 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One problem with the one-page manual is that Google won't do proper deeplinking. Search for makeWrapper for example and it will send you to https://nixos.org/nixpkgs/manual/, no anchor applied.

This is less of a problem, when the pages itself are shorter and are more on topic for the search request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The manual pages are also becoming more and more difficult to render on lower powered devices. It seems that throwing text on the screen using modern browsers is a hard task.

This, thus, reduces the accessibility of the manuals from users that don't have access to top tier machines like I figure a good chunk of Nixpkgs developers have.

While this is becoming less and less true in the developed world, bad internet that slows to a crawl is still a reality that exists. Splitting in distinct pages will also help accessibility in these instances.

1. make warning and info boxes stand out from the rest of the content
with colour,
1. easy to customize HTML and CSS, since tired old templates we've all
seen too many times are best avoided. The objective is to make
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is your justification for the claim that the Nix documentation's HTML and CSS should be customized because the "tired old templates we've all seen too many times are best avoided"? If, as this RFC also claims, a choice's being common means that it is a good choice, then I note that much Rust documentation, including the Rust Book that this RFC uses as an example, uses the same default, or at least very common, mdBook theme seen in the example mdBook Nix manual that edolstra has posted. Why is that theme "best avoided"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's my opinion about that:

First, it's a branding thing, mdbook AFAIK was made for the Rust documentation, so it's already their branding for their docs.

Then, this simple objective is a way to avoid locking ourselves into what the tool provides. It may be that we need such capabilities not to brand the docs, but to implement missing features according to our needs. If extensibility is hard, or impossible, it's like painting us in a corner.

Finally, a throwback to the first point, is that we don't want to lose features. The current documentation toolchain allows a tight integration of the docs into the website. If the chosen solution doesn't allow us to integrate the docs in the website "as native as it can be", it's a loss of functionality.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mdbook is customizable, see https://rust-lang.github.io/mdBook/format/theme/index.html. However, I don't think the current tight integration (e.g. that the docs have the same navbar as the rest of the site) is essential. I think it would be enough to have a visual style that looks similar to the rest of the site.

Or we could just upload the docs to readthedocs.io...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mdbook AFAIK was made for the Rust documentation, so it's already their branding for their docs.

Ah, I didn't know that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a highlight.js that can provide syntax highlighting for nix and bash.

Copy link
Member

@evanjs evanjs Jul 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Started a mdBook docset for a different project lately, and found it's extremely easy (like most things with mdBook so far) to add additional languages for highlight.js.

I downloaded a script with the languages I needed from https://highlightjs.org/download/ and dropped it in src/highlight.js.
The available syntax highlighting for Nix also works great, of course.


One thing that irritates me is the default code-block width, but we could style this as needed.

Without said custom styles, I had to add a few line breaks to large expressions, such as this one.
Otherwise, it only displayed ~50% of the code block.

Small code block width

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(In case it wasn't obvious, I wasn't talking badly about mdbook, I haven't looked into any of the tooling options since anyway this RFC is not about tooling.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evanjs Thanks, I've added a highlight.js with Nix support to the manual. Example: https://hydra.nixos.org/build/124655688/download/1/manual/expressions/language-constructs.html

a statement to newcomers that the community takes documentation
seriously, with both good form and good content.

Satisfying all requirements above is possible with a number of
toolchains, including Asciidoc-specific or RST-specific toolchains
(not just Markdown). We propose CommonMark as the documentation
format. The choice of toolchain is left at the discretion of the
implementers. We feature two demos below (one uses [Gatsby][gatsby]
and another uses [Sphinx][sphinx]).

The one-time conversion from Docbook to CommonMark is lossy, because
CommonMark has far less expressive markup. It is done using
[Pandoc][pandoc], which has a reader available for Docbook and
a high-quality writer available for CommonMark. The Pandoc Docbook
reader isn't perfect, but in the process of putting together the quick
demo below, it was easy to fix 5 bugs already.

We propose to keep the man pages as Docbook for now. They are
self-contained documents, whose form is constrained by convention and
the limits of the man page format. When the time comes to convert the
man pages as well, we can turn here again to prior art. The Kurnetes
zimbatm marked this conversation as resolved.
Show resolved Hide resolved
project uses [md2man][md2man] to generate man pages from CommonMark.
This is a small Go command with a 4.1MB closure size (including 2MB
for `tzdata`).

[gatsby]: https://gatsbyjs.org
[sphinx]: https://www.sphinx-doc.org
[pandoc]: https://pandoc.org/

mboes marked this conversation as resolved.
Show resolved Hide resolved
# Examples and Interactions
[examples-and-interactions]: #examples-and-interactions

This RFC is *not* about vetting a single implementation choice. The
five large projects cited above use one of Hugo, Gatsby, Jekyll, or
mdBook. We can add Sphinx to the set of available implementation
choices, which likewise has excellent support for Markdown. In this
section we show how two of these choices could work in the context of
the Nix* projects. *Selecting a toolchain is left to the discretion of
the implementors. Discussing implementation choices that are
transparent to the user is out of scope for an RFC process*.

The following demo shows how to satisfy all requirements above using
CommonMark as the input format and a Gatsby-based [starter kit from
Hasura][hasura-docs-starter] to generate a ready-to-deploy static
website:

https://nixos-docs-mockup.netlify.app

It features the following sections of the Nix manual:
* introduction
* quickstart and installation
* the Nix expressions chapter
* advanced topics

The content is the unedited output of running the Pandoc conversion,
which still has bugs (in particular the handling of cross-references).

This other demo shows how to satisfy many of the same requirements
using Sphinx, again with CommonMark as the input:

https://nixpkgs-manual-sphinx-markedown-example.netlify.app
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. I should include a lot more detail in the RFC. The source for that site is here: https://github.com/garbas/nixpkgs/blob/manual-markdown-sphinx/nixos/doc/manual-rst/. The README explains the history of that branch. It's based on @nlewo's earlier RST prototype prepared as part of #64, but with one file converted to Markdown. See https://github.com/garbas/nixpkgs/blob/manual-markdown-sphinx/nixos/doc/manual-rst/source/installation/installing.xml.md.


The look and feel is customizable, and indeed could be made the same
in both cases. Both are examples meant to demonstrate that choosing
CommonMark as the input format doesn't force unreasonable compromises.

[hasura-docs-starter]: https://github.com/hasura/gatsby-gitbook-starter

# Drawbacks
[drawbacks]: #drawbacks

The current DocBook format is semantically richer. There are specific
tags for definitions, environment variables, user accounts, various
types of callouts, etc. CommonMark's data model isn't nearly as rich,
so in converting to CommonMark, some information is lost. However,
experience in other very large ecosystems with many users tells us
that authors are happy to make do with an inexpressive but familiar
format, which in any case *can* be extended with the wise use of
`<span>`-like HTML tags and custom tags that expand to HTML. That
appears to be seldom necessary in practice (see e.g. the five
documentation examples in [Motivation][motivation]).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drawback: no support for PDF, epub or manual pages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need PDF or epub. Manpages are apparently supported by Sphinx.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the tooling matters here again, otherwise we will have to ditch services.nixosManual.showManual option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? That option only requires an HTML rendering of the manual.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, I forgot that uses HTML instead of the manual page.


# Alternatives
[alternatives]: #alternatives

Other formats share the desirable properties of the various flavours
of Markdown (of which CommonMark is but one):

- textual format that is easy to diff,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my experience, diffs are more often broken by re-flowing paragraphs than by markup. This is an issue for any format, which is why I tried to disable wrapping in Nixpkgs docs but the change was reverted 🤷‍♀️).

- reuses familiar conventions from decades of plain text emails,
- terseness of the markup and consistent levels of indentation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is still needed for lists. And unlike in Docbook, I need to do it manually instead of leaving it to code formatter.


The main two other contenders are AsciiDoc and RST. There are
technical reasons to prefer either of them to CommonMark, despite
social factors in favour of CommonMark.

## AsciiDoc

AsciiDoc has the same data model as Docbook - just a different syntax.
This makes the two formats interchangeable in principle. The markup
language is arguably better designed than CommonMark and is more
expressive. However, AsciiDoc is not as precisely specified as
CommonMark. It has only two extant toolchains ([Asciidoc][asciidoc]
and [Asciidoctor][asciidoctor]) for transforming into HTML, one of
which is infrequently maintained (3 releases in 7 years). In the top
100 projects on GitHub, only one project uses Asciidoc for their
documentation format.

Asciidoc is also effectively a format transformer dead-end:
round-tripping via Docbook using `asciidoc` and `docbookrx` doesn't
work and Pandoc does not support Asciidoc as an input.

[asciidoc]: https://asciidoc.org/
[asciidoctor]: https://asciidoctor.org/

## reStructuredText

Pros:

- reStructuredText (RST) has wider adoption than Asciidoc.
- Most Python projects use it. The Python ecosystem is deep and wide.
- Good and mature toolchains like Sphinx exist to process RST files.

Cons:

- the syntax for simple things like links or inline code is
non-standard. Inline code requires double backticks, but single
backticks is legal syntax and used for links, so it's easy to get
things wrong that don't lead to build errors.
- RST constructs do not compose nearly as well as they should. What is
trivial in CommonMark is impossible in RST. For example, links with
inline code in the title are not expressible. Links with italics in
the title are not expressible either. In general, inline markup does
not concatenate well. Backslashes are required in common constructs
like the following:
```
Python ``list``\s use square bracket syntax.
This is a long\ *ish* paragraph
```
- nesting block elements suffers from gotchas (like [this
one][rst-nested-lists]).

[rst-nested-lists]: https://stackoverflow.com/questions/44557957/unexpected-indentation-with-restructuredtext-list

## Are they popular?

The extra expressiveness of Asciidoc or RST over CommonMark was not
deemed to be a crucial requirement by many other large projects. In
the GitHub Top 100 (projects ranked by number of stars), only one
project (Spring Boot) uses Asciidoc, and only two projects (Ansible
and Linux) use RST other than the predominantly Python projects. Swift
uses a mix of RST and Markdown, what with being in the middle of
a transition to full Markdown (grep for `[Gardening] De-RST` in [the
history][swift-docs-history]).

[swift-docs-history]: https://github.com/apple/swift/tree/master/docs

# Unresolved questions
[unresolved]: #unresolved-questions

We propose to take CommonMark as a baseline. This is sufficient to
support all the markup we need. It's also a stepping stone towards
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think other reviewer comments rebut the claim that "CommonMark [...] is sufficient to support all the markup we need".

[MDX][mdx], which enables embedding custom widgets if so desired. For
example, Gatsby uses MDX to include newsletter signup forms, embed
videos from third-party training websites, or to generate
documentation sitemaps within a section (e.g. the bottom of [this
page][gatsby-graphql]). It's unclear that custom widgets are worth the
trouble at this stage.
Copy link
Member

@jtojnar jtojnar Jul 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nicer to use MDX from get-go for admonitions, rather than using <div> HTML element.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all for using MDX, but that may be a more controversial choice than plain CommonMark, or even well supported slight extensions of it, like GFM. I agree that MDX would be nicer for admonitions, because inside a <div> CommonMark markup is not interpreted. React (ab)uses blockquotes for admonitions (see e.g. here). It's a good enough solution, but yes, MDX would be even nicer if the community can stomach it.


The choice of toolchain to publish the documentation on the website
and as man pages is left open.

[gatsby-graphql]: https://www.gatsbyjs.org/docs/graphql/

# Future work
[future]: #future-work

- Build out the documentation demo above into a full replacement for
each of the Nix, Nixpks and NixOS user manuals online.
- Fix all Pandoc bugs encountered along the way, in particular to get
working cross-references.
- Customize the CSS and layout of the demo to be more in line with Nix
branding.
- Integrate the result into the Nix and Nixpkgs repositories and hook
into their respective CI/CD pipelines.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the way https://cert-manager.io/ does give you a binary choice on their landing page: Docs or Repo? The githup repos are integral part of the experience and most often your primary (google) search intent pivots around exactly this binary choice.

I feel this is out of scope for this RFC, but might result as a collateral of the concrete implementation.