Menu

[r6271]: / trunk / py4science / doc / rest_basics.txt  Maximize  Restore  History

Download this file

173 lines (110 with data), 5.0 kB

  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
=================================
reST (reSTructured Text) basics
=================================
.. Author: Fernando Perez
.. Contact: Fernando.Perez@colorado.edu
.. Time-stamp: "2007-08-29 15:50:06 fperez"
.. contents::
..
1 What is reST?
2 Markup summary
3 Emacs cheat sheet
4 Tests
5 Things I don't like
What is reST?
=============
It's a simple text markup format which can be converted easily into other
formats (html, latex, pdf) while being easily readable in its plaintext
version. This document is a little example of reST basics for my own
reference.
As shown above, it's good practice to start any reST document with a title and
simple metadata. The two leading dots indicate a comment or special markup
directive in reST. The time stamp can be updated with the emacs command
``time-stamp`` (these two back-quotes mean 'inline literal', which is normally
rendered as monospace font).
The metadata above was enclosed inside comment fields, so it won't be visible
in the generated document. You can instead use reST fields if you want these
values to be automatically formatted in produced documents:
:Author: Fernando Perez
:Contact: Fernando.Perez@colorado.edu
:Date: January 4, 2007
The table of contents is auto-updated by Emacs with 'C-c p u', and it is also
rendered in HTML by the rst2html compiler. This can be invoked from Emacs via
the ``rst-compile`` command. Additionally, Emacs makes each entry in the TOC
an internal clickable link, which is great for navigation.
This_ link is a quick reference to the reST markup (links are made by an
underscore at the end of the word, and the same word following shortly with the
underscore preceding it instead, and its target indicated after a colon).
.. _This: http://docutils.sourceforge.net/docs/user/rst/quickref.html
Making websites: look at http://www.voidspace.org.uk/python/rest2web
Markup summary
==============
These are taken from the quickref mentioned above, and are just a small subset
of the more common markup options. See that document for more details.
- *emphasis*: Normally rendered as italics.
- **strong emphasis**: Normally rendered as boldface.
- ``inline literal``: Normally rendered as monospaced text. Spaces should be
preserved, but line breaks will not be. For multiline literal blocks, use
``::`` preceding the literal block (if it's at the end of a sentence, it gets
converted into a single ':').
- reference_: A simple, one-word hyperlink reference.
- `phrase reference`_: A reference with spaces or punctuation.
- footnote reference [1]_: See quickref for details.
- citation reference [CIT2002]_: See quickref for details.
Note: the above are listed using bullet list markup. reST also has markup for
enumerated, options, definitions and fields lists.
Emacs cheat sheet
=================
These are a few useful Emacs bindings, copied from the help and support source
code. C-= is by far the most common and useful one::
C-c p a (also C-=): rst-adjust
Updates or rotates the section title around point or promotes/demotes
the decorations within the region (see full details below).
Note that C-= is a good binding, since it allows you to specify a
negative arg easily with C-- C-= (easy to type), as well as ordinary
prefix arg with C-u C-=.
C-c p h: rst-display-decorations-hierarchy
Displays the level decorations that are available in the file.
C-c p t: rst-toc
Displays the hierarchical table-of-contents of the document and allows
you to jump to any section from it.
C-c p i: rst-toc-insert
Inserts a table-of-contents in the document at the column where the
cursor is.
C-c p u: rst-toc-insert-update
Finds an existing inserted table-of-contents in the document an
updates it.
C-c p p, C-c p n (C-c C-p, C-c C-n): rst-backward-section,
rst-forward-section
Navigate between section titles.
C-c p l, C-c p r (C-c C-l, C-c C-r): rst-shift-region-left,
rst-shift-region-right
Shift the region left or right by two-char increments, which is perfect
for bulleted lists.
M-S center-paragraph
M-s center-line
Tests
=====
some text
- a bulleted
- list
- without indentation
more text
* a bulleted
* list that uses '*' for markers and leaves whitespace in between each item.
This is equally acceptable, and more legible when items are long.
more text
- and another bullet list
- but indented in the plaintext source
and more text.
Trying block quotes::
foo bar
baz
normal text
Things I don't like
===================
- The fact that indented bulleted lists in the source end up double-indented in
the rendered doc. Since the default rendering of bullet lists indents (in
html), then the source should be the same.
- Requiring indentation for block literals. This sucks for pasting code in and
out of reST docs.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.