ReStructuredText vs. Markdown for documentation
zverovich.net
zverovich.net
If you're a tech writer, you're probably interested in using the best tool for the job, because writing documentation is what you do day in, day out. If ReStructuredText is the most powerful format, then you're going to strongly lean toward that.
If you're a developer, however, writing documentation -- while you may recognize its necessity -- is a task that is often a slog. It's something you do so you can get it out of the way, and you really don't want to spend very much time thinking about the "how." You especially don't want to spend very much time learning the intricacies of a new markup format, unless you absolutely have to.
I say this as a developer who is also a writer. I enjoy writing, but I know many developers don't. And if Markdown makes it easier for them to write documentation, either because they're already familiar with it or because it's just a simpler format, then I'm all for it, even if ReStructuredText might be a bit powerful overall.
RST header markup is more readable in plain text. In Markdown, the less important a header is, the more hash marks. In RST, I am free to make less important headers have less visual weight.
They're standardised but I wouldn't say they're clearer as the "level" of a specific over/under symbol only depends where it first appeared in the document, I've seen projects where two documents side by side used different underline symbols for the same depths, that gets confusing.
I'd like rST/Sphinx to be stricter on this point, maybe I should open an issue/PR allowing upfront definition of the over/underline hierarchy for the project.
Really - I don't get this impulse at all. From my perspective, the entire point of markdown (and RST I assume, though I haven't used it) is that you can easily read and write it using any plain text editor.
If you are going to need a specialized editor to write it, you might as well use html, docbook, docx, odt, troff, rtf, or any of the zillion other formats.
- Key bindings
- Syntax coloring
- Toggle preview within the editor
I found Markdown generally had much wider support than RST.
ReStructuredText is not hard. Yes, unusual features are hard to memorize, but a quick google search beats it being impossible every time.
Otherwise, if you haven't learned any of those two and are wondering which one you should pick, it's cool, because
> You especially don't want to spend very much time learning the intricacies of a new markup format, unless you absolutely have to.
is moot anyway. Starting to write in RST is not more complicated than starting with MD. No need to learn the minute details to write basic documents. You will have plenty of time afterward to refine the thing once you're accustomed to it and feel the need to produce more advanced outputs.
I actually recently introduced RST and Sphinx to our documentation team of 4 non-developers, and the most difficult hurdle was actually teaching them to use git (even with GUI SourceTree). Getting multiple non-developers (2 are remote) how to install Xcode and Docker produced more confusion then I thought it would. We've finally gotten into a flow, and better documented how to install the documentation tools, and it's been working quite well.
https://www.gnu.org/prep/standards/standards.html#GNU-Manual...
On the contrary, when I'm trying to write a manual larger than a few screens, say, docs for an API with more than 20 entries, I have to think about the tools to write, compile and display the documentation in a way to be comfortable for both the developer and the user. I'm not in a mood to write my own, and the Internet recommends me to use something that requires installing whole Ruby dev-stack (and I don't use Ruby) and produces something hardly even readable. That's why using markdown + pandoc, or even google docs might be something I resort to.
If somebody would show me "The Way", spending a day or even a week to get fluent with the tooling I can use from now on would seem to me a minor nuisance, hardly even noticeable.
I prefer Markdown.
It's readable and easy to start writing by non-technical folk. More than that that, it's less flexible and isn't as likely to be destructive. At the end of the day rST is as complicated and as flexible as something like HTML. The biggest problem is its ability to nest markup. Markdown is pretty flat and you're not putting lists within tables within blockquotes. As someone making a theme, it was pretty difficult to style against the level of nesting that people end up using rST for. This is of course me bitching about how people write their rST, but there it is. I think rST by nature leads to inconsistent markup.
Basically what I'm saying is. At that point, I'd rather just write HTML. rST sits in some weird middle world where it can get very verbose, but you end up losing all the simplicity that you wanted in the first place.
Also want to note that rST doesn't HAVE to be so complicated. Plenty of people write clean, rST docs. However, as someone who spent a good deal of time learning the Sphinx system and the markup quirks of rST, in general I ended up seeing people use it in all sorts of crazy ways which then led to weird styling errors.
When it came time to document my own projects, I just built a simple markdown system with a tree structure and added some syntax highlighting. That's gonna get most projects 95% of the way there. While you can do a lot more with rST and it is really powerful, I really think it's only for those 5% of projects or more than likely, scientific documentation that needs more context.
Markdown doesn't have that problem because you can't do much with Markdown.
> http://thread.gmane.org/gmane.comp.version-control.git/57643...
Ultimately, I lean towards rST since you can combat complexity with "good practices" (as a Python guy this is akin to being Pythonic) but the opposite is not true for less complex implementations.
But there are merits to both approaches.
And from my comment in that thread:
After having written a fairly popular 400+ page book, and dozens of documentation sets in Markdown (and having worked on a few in other languages), I have to say—Markdown is _good enough_.
It will take an order-of-magnitude difference to unseat Markdown as the 'simple plain text formatting syntax' default, IMO. But use what makes you productive and is most conducive to writing effortlessly!
I have spent a lot of time trying to make Asciidoc create beautiful PDFs for technical documentation, but Asciidoctor makes it all a lot easier to customize its own stylesheets.
The only negative thing about it is that it is hard to install since it typically isn't found in your distros package repo by default.
But its tables beat both hands down. You can include a csv file with some headers or micromanage merged cells, alignment and such.
[1] http://docutils.sourceforge.net/docs/ref/rst/directives.html...
I wonder if that thing ever took off. Previously, it was said, that they were working in docbook (XML)
AFAIK (I have a few friends who have written for O'reilly) this is their canonical mode of publishing. It uses Git and Asciidoctor (not asciidoc) with a few additional plugins
[1] http://www.balisage.net/Proceedings/vol10/print/Kleinfeld01/...
AsciiDoc has some very newbie-hostile quirks, at least as of now it more or less requires asciidoctor, and even then its output HTML is terrible. Terrible as in Wrong, as in...
<div class="paragraph"><p>Oh no...</p></div>
In fact, since I have not yet found an asciidoc converter that produces decent HTML, and I don't have time to write one, I may yet fall back into the "everything sorta supports Markdown" trap.I dare anyone to write a scientific paper or book using Markdown. In Asciidoc it's doable. And before you say that a markup language is the wrong tool for the job, let me remind you that nowadays authors might want to produce different formats (HTML, ePub, text-only) from the same source file which is difficult with LaTeX.
I wish I had time to evaluate them in more detail, but so far I've stayed with LaTeX, which I feel is not the right tool for the job for material that's not going to be printed on paper.
I would never try to write a book in Markdown, no matter how extended; but considering the HTML produced by asciidoc|tor, you might also say "don't use AsciiDoc for simple Web publishing."
What I find much more fascinating is the question why there is no good general-purpose format that works equally well for blogging and for scientific papers and for books?
Is it really that hard a problem?
That being said, while the user documentation is (mostly) excellent, the developer documentation is abysmal to non-existent. On the positive side, though, the developers are quite active and responsive on Github. But if you're only writing documents instead of extending the language with new macros, you won't notice anything of that.
Edit: it's also available in Ruby, JS and on JVM!
To me, this is like watching intense baseball fans argue who was better, Babe Ruth or Joe Dimaggio - neither one of them is going to play again.
So here's a story: I work at a large engineering company building custom automated research systems. The system engineers do the the design/development/testing and documentation.
I have been searching for nearly 9 months for a documentation system to replace our current documentation system (500 Word docs in an EDMS). Goal is to increase re-usability and decrease maintenance cost by something more like a wiki/markdown system.
The problem is, even though formatting and maintenance of Word docs is abysmal, they make inserting images and references drop dead simple. Plus, everyone has it installed on their machine.
All the markdown versions don't have good references or image support (plus the best IDE is gitbooks which is... buggy). RsT is too much of a burden to setup. These are engineers writing, not programmers.
I've looked into Confluence, Gitbooks, Dozuki, Inkling, Sphinx, ... nothing is quite so friction-less to "just write the docs" than Word.
I still wish I had a publishing toolchain that produced multi-format output (HTML5, docx, ePub, Kindle, and plain text) from the same source file. It can be done with LaTeX sources but the result is sub-optimal.
For an enterprise organization with a full gamut of technical ranges from "maintain 40 github repos for fun" to "I still don't trust anything but Word, Excel, Powerpoint and email", pandoc is not the solution (as nice a tool as it is).
....but image support. Ugh don't get me started. Thankfully we use it right now for simple articles so the figure doesn't need to do much.
1. Do you want to write something that MD is sufficient for? Write MD.
2. Do you want to write something that you need RST for?
2a. Is your document already in RST or is there no document? Write RST.
2b. Is your document in MD? Pandoc to RST. Pretty print. Write RST.
The reason this is useful is that the 90% use-case is probably hit by MD. You may never need RST. And you won't spend more time deciding and discussing than actually doing because this algorithm only takes a few seconds to execute.
The (only) good thing about Markdown is it's (allegedly) simple. IMO it's on the one hand not simple enough (e.g. HTML has got to go) and on the other hand it's too simplistic.
Ideally I would like to have a tiny core specification with a clean and simple standardized mechanism for extensions like roles and directives. With a bunch of standardized but optional extensions. Only the most important features (90% of usage) should get special syntax (bold, bullet lists, titles, roles, directives). For everything else (90% of features) there should be a named role or directive.
Trac actually uses a similar system. linkExtensionName:content, [[extensionName(content)]] or {{{#!extensionName multiline-content }}} is all you need to remember. Could be simplified a bit, but it's quite usable.
In RST you must indent child bullets exactly to the indentation level where the text starts in the parent bullet.
# Remove the spaces at the start to put in a file (HN rendering)
* Bullet 1
* Sub-bullet 2
* Bullet 2
# Both worked fine: $ rst2html --verbose test.rst test.html
$ pandoc --output test.html test.rst
b. In RST you must indent child bullets exactly to the indentation level where the text starts in the parent bullet.Also untrue as far as I can see. Vim does do automatic indents for me so they have to be consistent AFAIK, but not to the `exact` same level as where the text starts in the parent bullet.
Check the specification: http://docutils.sourceforge.net/docs/ref/rst/restructuredtex... See "examples of incorrectly formatted bullet lists", or http://docutils.sourceforge.net/docs/dev/rst/problems.html#b... or http://docutils.sourceforge.net/FAQ.html#could-the-requireme... It's a well known problem.
b. Check the spec. It must be exactly aligned. If it's not exact it's not a child list. It's just an independent list with random indentation.
See e.g. http://stackoverflow.com/questions/5550089/how-to-create-a-n...
https://github.com/rtfd/recommonmark
However, commonmark currently lack support for tables, so I fall back on rst for tables(actually I think the syntax for tables in rst is much better than tables in other markdown flavors).
Also, resolving links using commonmark in sphinx is a mess, right now. I actually extended recommonmark so sphinx will properly resolve cross references(including reference to elements in a domain). However, I had to update sphinx as well, which I have a PR open with no response from them, here:
https://github.com/sphinx-doc/sphinx/pull/2644
It seems unfortunate that sphinx devs are unresponsive to contributions. The devs for mkdocs are a lot more responsive, but seem more interested in monetary contributions, unfortunately.
A <----- B -----\
|
V
C
Then there was a link in the discussion to a similar tool.Still haven't time to play with it, but it looks nice.
I find ReST incredibly awkward to use, really, because it's anything but intuitive - both Textile and Markdown are easier to write off the cuff.
More importantly, though, I really wish that Textile, Markdown, ReST, etc., were formally specified as PEG grammars or similar. There's just too much variation, and "standards" or specs defining them tend to be written in ambiguous English rather than something that could be formally validated and easily ported across to new languages (rather than the spaghetti messes of regexps that most parsers turn out to be when you look at the source).
We have Unicode but most of its symbols are a pain to generate on conventional keyboards.
We have touch-screens but desktop computer keyboards don’t offer them and software on phones/pads still tries a bit too hard to emulate a conventional keyboard layout.
Imagine if all standard keyboards had touch displays on the side to quickly flip between tables of related symbols, optionally with some context-sensitive mode? Then, instead of having to use creative ASCII tricks to make it “simple” to describe what you want, you just do it through your input device.
Ultimately I think markup languages will have to distill their features down to a few structural elements, and rely on Unicode (and easier Unicode input methods) to handle what is currently being done with ASCII hacks.
https://www.google.com/search?q=Optimus+Maximus+keyboard&tbm...
https://en.wikipedia.org/wiki/Optimus_Maximus_keyboard
It exists but hasn't taken over the world.
Apparently Apple's working an OLED display above their keyboard.
http://9to5mac.com/2016/05/23/apple-prepping-thinner-macbook...
As someone who context-switches from XCode to IntelliJ to Photoshop to Emacs, sometimes I confuse the shortcuts, and I don't learn more shortcuts because I'm afraid they will not carry over to other programs. Having discoverable shortcuts would be amazing.
Let authors use the fucking tools they know and prefer.
Organise common text through translation tools. Pandoc is fucking amazing.
Formatting for final production is a separate task.
(Not without some irony, I'm reviewing a set of guides and commentaries on productivity and creativity in a few other tabs....).
When you are writing your most important task is to capture the gist of what's in your head onto a tangible medium. If that means fucking Messinian marble and diamond chisels, so be it.
The marginal productivity gains for someone already proficient in a tool are low in switching to something else, relative to domain knowledge.
The challenge is that you're then stuck with high-level, vs. low-level definitions and tools. Which is where the whole "what do I use for creating my documents" question ends up at.
Systems such as HTML5 (the semantic elements, not all the canvas and DRM crap), or LaTeX, or DocBook, are hugely useful here because their definitions are largely semantic. You write the structure, not the style.
After that, so long as a tool or language can produce ingestible input given an author's output, that's fine.
And, frankly, by the time you're worried about specific low-level structure, use a dedicated tool which provides that. My experience with LaTeX was that it was actually _amazingly_ simple to use for basic creation -- it gets out of the way. Paragraphs as linefeeds, rather than HTML's incessent <p> </p> pairs, helps immensely. For more complex structures, you can go back and add what's needed later.
Markdown offers a wide set of capabilities with the option of fallback to HTML, which again is powerful and a good option for composing.
And there's value in simplicity.
I've come to rue this decision in some ways. I like what I've been able to accomplish, but I've found most customization of default Sphinx and docutils behavior to be torture. I don't mean to drag contributors to those projects through the mud--they work well if you can just write documentation without fiddling much.
It's a Python package that allows you to extend markdown through pandoc filters. It allows you to easily manipulate the AST created by Pandoc to add any number of features.
For instance, I wrote my dissertation in Markdown , and used this to include algorithms, CSV tables, include directives, etc.
As I started writing the documentation though, Markdown's drawbacks became more apparent. Especially as the software I'm making is multi-platform and there are features that exist in one platform and not the other and I'd like to include/exclude documentation of those features based on platform, and the fact that I'd like the documentation for each platform to contain images from the program running on that platform, and so on, and this is not something that Markdown handles well.
And so I switched to ReStructuredText. RST is not as clean or as simple to write compared to Markdown, however if you are producing documentation then it is much more flexible. I can live with less clean syntax in order to get the flexibility to do what I need to do.
Hacker news, tumblr, reddit, github all do it. Honestly, if it didn't look fine in the editor and then throw an apeshit fit when posted, it wouldn't be that frustrating. But I'm so damn tired of hitting "preview" or editing my posts after posting because of misleading previews and text boxes.
In both, it is difficult to have a block of code with one line in bold, or italicized for emphasis. (The same seems to hold for asciidoc.)
Which is why I eventually gravitate back to HTML. (See https://github.com/oreillymedia/HTMLBook as well - full disclosure: I have done writing for O'Reilly.)
The lightweight language is an authoring tool, but it shouldn't get in the way of full expression as needs be.
(Markdown allows integrated HTML, though not all Markdown implementations / uses provide that, particularly online Web tools. Which are horribly inconsistent, IME.)
There are some other RST table types:
a. List table: Pretty simple to use (http://docutils.sourceforge.net/docs/ref/rst/directives.html...)
b. CSV table Supposed to be used for CSV imports I guess but I've never used it (http://docutils.sourceforge.net/docs/ref/rst/directives.html...)
I wrote a number of documents in FrameMaker back in the 90s and I loved it. I really wish I had something like it now.
Please point to towards an API or library documentation written in the native format of either of those. In 10 years as a developer, I've never come across such a thing.
> Yet another flavor of Markdown is not helping.
Agreed. That's pretty much what the article states, and RST, luckily, is not that.
In any case, there's a lot of things people use in-house and never bother to tell the outside world about, and you'd be surprised how far that is from what people on HN or Github habitually use.