blob: 8f6d71e4ecbc4bee7fd4d3f47748d6a0af0a17e6 [file] [log] [blame]
Sean Silva5d499c22012-10-12 00:53:48 +00001==========================
2Sphinx Quickstart Template
3==========================
4
Sean Silva5d499c22012-10-12 00:53:48 +00005Introduction and Quickstart
6===========================
7
8This document is meant to get you writing documentation as fast as possible
9even if you have no previous experience with Sphinx. The goal is to take
10someone in the state of "I want to write documentation and get it added to
11LLVM's docs" and turn that into useful documentation mailed to llvm-commits
12with as little nonsense as possible.
13
14You can find this document in ``docs/SphinxQuickstartTemplate.rst``. You
15should copy it, open the new file in your text editor, write your docs, and
16then send the new document to llvm-commits for review.
17
18Focus on *content*. It is easy to fix the Sphinx (reStructuredText) syntax
19later if necessary, although reStructuredText tries to imitate common
20plain-text conventions so it should be quite natural. A basic knowledge of
21reStructuredText syntax is useful when writing the document, so the last
22~half of this document (starting with `Example Section`_) gives examples
23which should cover 99% of use cases.
24
25Let me say that again: focus on *content*.
26
27Once you have finished with the content, please send the ``.rst`` file to
28llvm-commits for review.
29
30Guidelines
31==========
32
33Try to answer the following questions in your first section:
34
35#. Why would I want to read this document?
36
37#. What should I know to be able to follow along with this document?
38
39#. What will I have learned by the end of this document?
40
41Common names for the first section are ``Introduction``, ``Overview``, or
42``Background``.
43
44If possible, make your document a "how to". Give it a name ``HowTo*.rst``
45like the other "how to" documents. This format is usually the easiest
46for another person to understand and also the most useful.
47
48You generally should not be writing documentation other than a "how to"
49unless there is already a "how to" about your topic. The reason for this
50is that without a "how to" document to read first, it is difficult for a
51person to understand a more advanced document.
52
53Focus on content (yes, I had to say it again).
54
55The rest of this document shows example reStructuredText markup constructs
56that are meant to be read by you in your text editor after you have copied
57this file into a new file for the documentation you are about to write.
58
59Example Section
60===============
61
62Your text can be *emphasized*, **bold**, or ``monospace``.
63
64Use blank lines to separate paragraphs.
65
Sean Silvacb644622013-02-08 21:51:26 +000066Headings (like ``Example Section`` just above) give your document its
Sean Silva5d499c22012-10-12 00:53:48 +000067structure. Use the same kind of adornments (e.g. ``======`` vs. ``------``)
68as are used in this document. The adornment must be the same length as the
69text above it. For Vim users, variations of ``yypVr=`` might be handy.
70
71Example Subsection
72------------------
73
74Make a link `like this <http://llvm.org/>`_. There is also a more
75sophisticated syntax which `can be more readable`_ for longer links since
76it disrupts the flow less. You can put the ``.. _`link text`: <URL>`` block
77pretty much anywhere later in the document.
78
79.. _`can be more readable`: http://en.wikipedia.org/wiki/LLVM
80
81Lists can be made like this:
82
83#. A list starting with ``#.`` will be automatically numbered.
84
85#. This is a second list element.
86
Sean Silvacb644622013-02-08 21:51:26 +000087 #. Use indentation to create nested lists.
Sean Silva5d499c22012-10-12 00:53:48 +000088
89You can also use unordered lists.
90
91* Stuff.
92
93 + Deeper stuff.
94
95* More stuff.
96
97Example Subsubsection
98^^^^^^^^^^^^^^^^^^^^^
99
100You can make blocks of code like this:
101
102.. code-block:: c++
103
104 int main() {
Sean Silvacb644622013-02-08 21:51:26 +0000105 return 0;
Sean Silva5d499c22012-10-12 00:53:48 +0000106 }
107
Sean Silvac5351a02012-12-13 20:14:25 +0000108For a shell session, use a ``console`` code block (some existing docs use
109``bash``):
Sean Silva5d499c22012-10-12 00:53:48 +0000110
Dmitri Gribenko8ba48802012-12-12 20:07:18 +0000111.. code-block:: console
Sean Silva5d499c22012-10-12 00:53:48 +0000112
113 $ echo "Goodbye cruel world!"
114 $ rm -rf /
115
Sean Silvac5351a02012-12-13 20:14:25 +0000116If you need to show LLVM IR use the ``llvm`` code block.
Sean Silva5d499c22012-10-12 00:53:48 +0000117
Sean Silvac5351a02012-12-13 20:14:25 +0000118.. code-block:: llvm
119
120 define i32 @test1() {
121 entry:
122 ret i32 0
123 }
124
125Some other common code blocks you might need are ``c``, ``objc``, ``make``,
126and ``cmake``. If you need something beyond that, you can look at the `full
127list`_ of supported code blocks.
128
129.. _`full list`: http://pygments.org/docs/lexers/
130
131However, don't waste time fiddling with syntax highlighting when you could
132be adding meaningful content. When in doubt, show preformatted text
133without any syntax highlighting like this:
Sean Silvab63ae852012-12-05 04:07:33 +0000134
135::
136
137 .
138 +:.
139 ..:: ::
140 .++:+:: ::+:.:.
141 .:+ :
142 ::.::..:: .+.
143 ..:+ :: :
144 ......+:. ..
145 :++. .. :
146 .+:::+:: :
147 .. . .+ ::
148 +.: .::+.
149 ...+. .: .
150 .++:..
151 ...
152
Sean Silva5d499c22012-10-12 00:53:48 +0000153Hopefully you won't need to be this deep
154""""""""""""""""""""""""""""""""""""""""
155
156If you need to do fancier things than what has been shown in this document,
157you can mail the list or check Sphinx's `reStructuredText Primer`_.
158
159.. _`reStructuredText Primer`: http://sphinx.pocoo.org/rest.html