1
1
Documentation Format
2
2
====================
3
3
4
- The Symfony2 documentation uses `reStructuredText `_ as its markup language and
5
- `Sphinx `_ for building the output (HTML, PDF, ...).
4
+ The Symfony documentation uses `reStructuredText `_ as its markup language and
5
+ `Sphinx `_ for generating the documentation in the formats read by the end users,
6
+ such as HTML and PDF.
6
7
7
8
reStructuredText
8
9
----------------
9
10
10
- reStructuredText *"is an easy-to-read, what-you-see-is-what-you-get plaintext
11
- markup syntax and parser system" *.
11
+ reStructuredText is a plaintext markup syntax similar to Markdown, but much
12
+ stricter with its syntax. If you are new to reStructuredText, take some time to
13
+ familiarize with this format by reading the existing `Symfony documentation `_
12
14
13
- You can learn more about its syntax by reading existing Symfony2 ` documents `_
14
- or by reading the `reStructuredText Primer `_ on the Sphinx website .
15
+ If you prefer to learn more about this format, check out the ` reStructuredText Primer `_
16
+ tutorial and the `reStructuredText Reference `_ .
15
17
16
18
.. caution ::
17
19
@@ -24,14 +26,14 @@ or by reading the `reStructuredText Primer`_ on the Sphinx website.
24
26
Sphinx
25
27
------
26
28
27
- Sphinx is a build system that adds some nice tools to create documentation
28
- from reStructuredText documents. As such, it adds new directives and
29
- interpreted text roles to the standard reST ` markup `_.
29
+ Sphinx is a build system that provides tools to create documentation from
30
+ reStructuredText documents. As such, it adds new directives and interpreted text
31
+ roles to the standard reST markup. Read more about the ` Sphinx Markup Constructs `_.
30
32
31
33
Syntax Highlighting
32
34
~~~~~~~~~~~~~~~~~~~
33
35
34
- All code examples uses PHP as the default highlighted language . You can change
36
+ PHP is the default syntax highlight applied to all code blocks . You can change
35
37
it with the ``code-block `` directive:
36
38
37
39
.. code-block :: rst
@@ -41,7 +43,7 @@ it with the ``code-block`` directive:
41
43
{ foo: bar, bar: { foo: bar, bar: baz } }
42
44
43
45
If your PHP code begins with ``<?php ``, then you need to use ``html+php `` as
44
- the highlighted pseudo-language :
46
+ the name of the highlighted syntax :
45
47
46
48
.. code-block :: rst
47
49
@@ -51,16 +53,18 @@ the highlighted pseudo-language:
51
53
52
54
.. note ::
53
55
54
- A list of supported languages is available on the `Pygments website `_.
56
+ Besides all of the major programming languages, the syntax highlighter
57
+ supports all kinds of markup and configuration languages. Check out the
58
+ list of `supported languages `_ on the syntax highlighter website.
55
59
56
60
.. _docs-configuration-blocks :
57
61
58
62
Configuration Blocks
59
63
~~~~~~~~~~~~~~~~~~~~
60
64
61
- Whenever you show a configuration, you must use the ``configuration-block ``
65
+ Whenever you include a configuration sample, use the ``configuration-block ``
62
66
directive to show the configuration in all supported configuration formats
63
- (``PHP ``, ``YAML ``, and ``XML ``)
67
+ (``PHP ``, ``YAML ``, and ``XML ``). Example:
64
68
65
69
.. code-block :: rst
66
70
@@ -96,32 +100,32 @@ The previous reST snippet renders as follow:
96
100
97
101
The current list of supported formats are the following:
98
102
99
- =============== ==============
100
- Markup format Displayed
101
- =============== ==============
102
- html HTML
103
- xml XML
104
- php PHP
105
- yaml YAML
106
- jinja Twig
107
- html+jinja Twig
108
- html+php PHP
109
- ini INI
110
- php-annotations Annotations
111
- php-standalone Standalone Use
112
- php-symfony Framework Use
113
- =============== ==============
103
+ =================== ======================== ==============
104
+ Markup format Use it to display
105
+ =================== ======================== ==============
106
+ `` html `` HTML
107
+ `` xml `` XML
108
+ `` php `` PHP
109
+ `` yaml `` YAML
110
+ `` jinja `` Pure Twig markup
111
+ `` html+jinja `` Twig markup blended with HTML
112
+ `` html+php `` PHP code blended with HTML
113
+ `` ini `` INI
114
+ `` php-annotations `` PHP Annotations
115
+ `` php-standalone `` Pure PHP code
116
+ `` php-symfony `` PHP code with special Symfony features
117
+ =================== ======================== ==============
114
118
115
119
Adding Links
116
120
~~~~~~~~~~~~
117
121
118
- To add links to other pages in the documents use the following syntax:
122
+ ** Internal links** to other documentation pages use the following syntax:
119
123
120
124
.. code-block :: rst
121
125
122
126
:doc:`/path/to/page`
123
127
124
- Using the path and filename of the page without the extension, for example:
128
+ The page name should not include the file extension (`` .rst ``). For example:
125
129
126
130
.. code-block :: rst
127
131
@@ -131,14 +135,15 @@ Using the path and filename of the page without the extension, for example:
131
135
132
136
:doc:`/cookbook/configuration/environments`
133
137
134
- The link text will be the main heading of the document linked to. You can
135
- also specify alternative text for the link :
138
+ The title of the linked page will be automaticall used as the text of the link.
139
+ If you want to modify that title, use this alternative syntax :
136
140
137
141
.. code-block :: rst
138
142
139
143
:doc:`Spooling Email </cookbook/email/spool>`
140
144
141
- You can also add links to the API documentation:
145
+ **Links to the API ** follow a different syntax, where you must specify the type
146
+ of linked resource (``namespace ``, ``class `` or ``method ``):
142
147
143
148
.. code-block :: rst
144
149
@@ -148,7 +153,7 @@ You can also add links to the API documentation:
148
153
149
154
:method:`Symfony\\Component\\HttpKernel\\Bundle\\Bundle::build`
150
155
151
- and to the PHP documentation:
156
+ ** Links to the PHP documentation** follow a pretty similar syntax :
152
157
153
158
.. code-block :: rst
154
159
@@ -158,20 +163,55 @@ and to the PHP documentation:
158
163
159
164
:phpfunction:`iterator_to_array`
160
165
166
+ New Features or Behavior Changes
167
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
168
+
169
+ If you're documenting a brand new feature or a change that's been made in
170
+ Symfony2, you should precede your description of the change with a
171
+ ``.. versionadded:: 2.X `` directive and a short description:
172
+
173
+ .. code-block :: text
174
+
175
+ .. versionadded:: 2.3
176
+ The ``askHiddenResponse`` method was introduced in Symfony 2.3.
177
+
178
+ You can also ask a question and hide the response. This is particularly...
179
+
180
+ If you're documenting a behavior change, it may be helpful to *briefly * describe
181
+ how the behavior has changed.
182
+
183
+ .. code-block :: text
184
+
185
+ .. versionadded:: 2.3
186
+ The ``include()`` function is a new Twig feature that's available in
187
+ Symfony 2.3. Prior, the ``{% include %}`` tag was used.
188
+
189
+ Whenever a new minor version of Symfony2 is released (e.g. 2.4, 2.5, etc),
190
+ a new branch of the documentation is created from the ``master `` branch.
191
+ At this point, all the ``versionadded `` tags for Symfony2 versions that have
192
+ reached end-of-life will be removed. For example, if Symfony 2.5 were released
193
+ today, and 2.2 had recently reached its end-of-life, the 2.2 ``versionadded ``
194
+ tags would be removed from the new 2.5 branch.
195
+
161
196
Testing Documentation
162
197
~~~~~~~~~~~~~~~~~~~~~
163
198
164
- To test documentation before a commit:
199
+ When submitting a new content to the documentation repository or when changing
200
+ any existing resource, an automatic process will check if your documentation is
201
+ free of syntax errors and is ready to be reviewed.
202
+
203
+ Nevertheless, if you prefer to do this check locally on your own machine before
204
+ submitting your documentation, follow these steps:
165
205
166
206
* Install `Sphinx `_;
167
- * Install the Sphinx extensions using git submodules: ``git submodule update --init ``;
168
- * (Optionally) Install the bundle docs and CMF docs: ``bash install.sh ``;
169
- * Run ``make html `` and view the generated HTML in the ``build `` directory.
170
-
171
- .. _ reStructuredText : http://docutils.sourceforge.net/rst.html
172
- .. _ Sphinx : http://sphinx-doc.org/
173
- .. _ documents : https://github.com/symfony/symfony-docs
174
- .. _ reStructuredText Primer : http://sphinx-doc.org/rest.html
175
- .. _ markup : http://sphinx-doc.org/markup/
176
- .. _ Pygments website : http://pygments .org/languages /
177
- .. _ Sphinx quick setup : http://sphinx-doc .org/tutorial.html#setting-up-the-documentation-sources
207
+ * Install the Sphinx extensions using git submodules: ``$ git submodule update --init ``;
208
+ * (Optionally) Install the bundle docs and CMF docs: ``$ bash install.sh ``;
209
+ * Run ``make html `` and view the generated HTML in the ``build/ `` directory.
210
+
211
+ .. _ `reStructuredText` : http://docutils.sourceforge.net/rst.html
212
+ .. _ `Sphinx` : http://sphinx-doc.org/
213
+ .. _ `Symfony documentation` : https://github.com/symfony/symfony-docs
214
+ .. _ `reStructuredText Primer` : http://sphinx-doc.org/rest.html
215
+ .. _ `reStructuredText Reference` : http://docutils.sourceforge.net/docs/user/rst/quickref.html
216
+ .. _ `Sphinx Markup Constructs` : http://sphinx-doc .org/markup /
217
+ .. _ `supported languages` : http://pygments .org/languages/
0 commit comments