1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
|
.. _developers-rst-for-markdown-expats:
ReStructured Text for those who know Markdown
=============================================
You can think of RST as "Markdown, but much better". Meaning:
#. RST is basically just as simple as Markdown
#. But RST is both more precise, and has more available formatting
constructs (without getting crazy complicated)
The full Sphinx / RST documentation is available here:
https://www.sphinx-doc.org/en/master/index.html
If you're familiar with Markdown, the following sections contain some
tips to get you started in RST.
Whitespace and indenting
------------------------
* MD: Whitespace and indenting generally doesn't matter in most
cases. It does matter with bullets and sub bullets, but the rules
get pretty weird, and vary between different Markdown renderers.
* RST: **Indenting matters**. A lot. Just like Python. In
general, you indent all RST text to keep it within the same level.
For example, all this text would be a single paragraph
**Blank lines also matter**. A lot. You use blank lines to
delimit sections within an indenting level. For example, the
blank line before this paragraph denotes a paragraph break.
.. note:: RST was created by the Python community. Hence,
whitespace is quite important.
* Indenting matters
* Blank lines between content matter
Using a blank line and outdenting indicates the end of the previous
item. For example, this paragraph is not part of the MD/RST
bulleted list.
Fixed width font
----------------
* MD: Use single quotes:
.. code-block:: md
`hello world`
* RST: Use a pair of single quotes:
.. code-block:: rst
``hello world``
Italics
-------
* MD: ``*hello world*`` or ``_hello world_``
* RST: ``*hello world*``
Boldface
--------
* MD: ``**hello world**``
* RST: Same as MD
Chapter and section delimiters
------------------------------
* MD: Either use one or more pound signs (#, ##, ###) to the left of
the line of text, or underline the line of text with pound signs
* RST: Have a single line of text, underlined by non-ASCII
characters.
* The length of the underlying *must* be at least as long as the
line of text
* Which non-ASCII character is used for the underlying does not
matter, but the order in which they are used denotes chapters
/ sections / subsections / etc.
In these OpenPMIx docs, the sequence of underline characters we use
are:
.. code-block:: rst
Chapter 1: hello world
======================
.. code-block:: rst
Section 1: hello world
----------------------
.. code-block:: rst
Subsection 1: hello world
^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: rst
Subsubsection 1: hello world
++++++++++++++++++++++++++++
Meaning: underlines made of ``=`` denotes chapters, underlines
made of ``-`` denotes sections, underlines made of ``^`` denotes
subsections, and underlines made of ``+`` denote subsubsections.
Multi-line code/fixed-width font
--------------------------------
* MD: Use three single quotes to delimit blocks of text. Optionally
include a token keyword to denote the syntax highlighting to use
inside that block.
.. code-block:: md
```c
int main() { printf("Hello world\n"); return 0 }
```
* RST: Use ``.. code-block:: KEYWORD`` to start a section of code.
.. code-block:: rst
.. code-block:: c
int main() { printf("Hello world\n"); return 0 }
* KEYWORD indicates which syntax highlighting to use (e.g., ``c``,
``c++`` ``make``, ``sh``, ``ini``, ``Fortran``, ``diff``,
``python``, ``java``, ``rst``, ... etc.).
* KEYWORD can be omitted if no specific highlighting is to be
used.
* There *MUST* be a blank line after the ``code-block`` line.
* The lines in the block must be indented to the same column as the
first ``c`` in ``code-block``. For example:
.. code-block:: rst
.. code-block:: sh
shell$ tar xf pmix-<version>.tar.bz2
shell$ cd pmix-<version>
shell$ ./configure --prefix=<path> |& tee config.out
Note that the code block will be rendered at the same level as
where the first ``.`` of ``.. code-block::`` starts. In this
case, the example code block will be rendered in the bulleted
item.
Whereas this parargraph and code block will be outside of the
above bulleted list:
.. code-block:: sh
shell$ tar xf pmix-<version>.tar.bz2
shell$ cd pmix-<version>
shell$ ./configure --prefix=<path> |& tee config.out
# Fun note: the code-block can contain blank lines.
The code-block is terminated by a blank line and then outdent back
to the same level as the first ``.`` in ``.. code-block::``.
Un-numbered bullets
-------------------
* MD: Start lines with ``*`` or ``-``
* RST: Start lines with ``*``. You can wrap lines at the same
indenting level to make paragraphs in the same bullet.
Having a blank line and then more text at the same indenting level
makes another paragraph in the same bullet. You even put other
directives in this same indenting level.
* For example, you can start a sub bullet.
This text is the next paragraph in the same sub bullet.
.. code-block:: none
This is a verbatim code block within this same sub bullet.
More about code-blocks below.
This is the next paragraph (after the code block) in the same
sub bullet.
* If you start a new bullet, that terminates the previous bullet.
* You **MUST** put blank lines between bullets!
Numbered bullets:
-----------------
* MD: Start lines with ``#``
* RST: Start lines with ``#.``
.. important:: Yes, the trailing ``.`` is important
For example:
.. code-block:: rst
#. Item number 1
#. The second item
#. A third item
All the same rules for indentation apply as described above.
Comments
--------
* MD: Enclose content in ``<!--`` and ``-->`` (i.e., HTML comments,
but they are included in the output)
* RST: Start a line with two periods and a space.
For example, the following block is a comment, and will not be
included in the output:
.. code-block:: rst
.. Hello world. This is a comment. This whole block is a
comment. You can leave it here in the final document, and it
will not be included in the rendered output.
Your comment can even include blank lines. You terminate a
comment -- just like most other things in RST -- by a blank
line and then outdenting back out to the same column as the
first ".".
This line is no longer part of the comment.
Including files
---------------
* MD: You cannot include files in Markdown.
* RST: Use the ``.. include:: FILENAME`` directive. For example:
.. code-block:: rst
.. include:: features-extensions.rst
.. include:: features-java.rst
Those directives include those 2 files right here in this RST file.
.. important:: Chapter/section/subsection delimiters will be
continued in those files as part of rendering this
file.
Hyperlinks to URLs
------------------
* MD:
.. code-block:: md
[this is the link text](https://example.com/)
* RST:
.. code-block:: rst
`this is the link text <https://example.com/>`_
.. important:: Yes, the trailing underscore in RST is important.
It's a little weird, but you'll cope.
Hyperlinks to anchors
---------------------
* MD: I forget offhand how to make anchors and links to them in MD.
* RST: Use the ``:ref:`` directive.
Make an anchor like this:
.. code-block:: rst
.. _ANCHOR_NAME:
It *must* start with and underscore and end with a colon.
I've typically used anchor names that either begin with ``label-``
or end in ``-label`` to make it blatantly obvious that it's a
label. For example:
.. code-block:: rst
.. _building-and-installing-section-label:
Then you can use the ``:ref:`` directive:
.. code-block:: rst
be sure to see :ref:`the VPATH build section
<building-and-installing-section-label>`.
Hyperlinks to other (RST) pages
-------------------------------
* MD:
.. code-block:: md
[link text](page_name)
* RST: Use the ``:doc:`` directive.
General format:
.. code-block:: rst
:doc:`link text <PAGE_PATH>`
For example:
.. code-block:: rst
You should read :doc:`the Developer's Guide </developers>`.
The page path is relative to the ``docs`` dir in the OpenPMIx git tree.
Macros
------
* MD: There are no macros in Markdown.
* RST: We have defined a few OpenPMIx-specific macros in RST. You can
insert these macros anywhere in RST content text.
* ``|ompi_ver|`` is the full OpenPMIx version number, including
alpha/beta/rc/greek denotation. For example ``5.0.0rc1``.
* ``|ompi_series|`` is the major/minor OpenPMIx version, e.g.,
``5.0.x``.
.. important:: Think twice about hard-coding the OpenPMIx version
number or series when referring to the current
version or series. It can be appropriate to
hard-code an "x.y.0" version to denote a
generational epoch, but in most other cases, you
probably want to use one of the macros.
* ``|mdash|`` is a unicode long dash, an "em" dash. Use it instead
of ``--``.
* ``|rarrow|`` is a unicode right arrow. Use it instead of ``->``
or ``-->``.
Brightly-colored boxes
----------------------
* MD: There are no brightly-colored boxes in MD.
* RST: You can use various directives to make brightly-colored
"note" boxes (Called admonitions) in RST. For example:
.. important:: a green box with a "!" icon
Standard indenting rules apply for the content in the box. You
can have multiple lines and multiple paragraphs, for example.
Yippee.
* You can even have bullets.
.. code-block:: none
You can even have code blocks inside the bullet inside the
caution box.
* All the standard indenting rules apply.
.. hint:: a green box with a "!" icon
.. note:: a blue box with a "!" icon
.. caution:: an orange box with a "!" icon
.. attention:: an orange box with a "!" icon
.. warning:: an orange box with a "!" icon
.. error:: a red box with a "!" icon
.. danger:: a red box with a "!" icon
.. admonition:: Custom title
:class: tip
You can name this box whatever you want:
.. code-block:: rst
.. admonition:: Custom title
:class: tip
Content of your box here.
Custom text for this custom admonition. Note that the ``:class: <type>``
will change the coloring to the color for the basic admonition of that
type. E.g., ``:class: tip`` makes the box be green.
|