Skip to content

Commit 8c042f1

Browse files
committed
Merge pull request #2481 from WouterJ/doc_standards
Refactored Doc standards
2 parents 484399c + 1118d1e commit 8c042f1

File tree

5 files changed

+113
-49
lines changed

5 files changed

+113
-49
lines changed

contributing/documentation/format.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ the highlighted pseudo-language:
5252

5353
A list of supported languages is available on the `Pygments website`_.
5454

55+
.. _docs-configuration-blocks:
56+
5557
Configuration Blocks
5658
~~~~~~~~~~~~~~~~~~~~
5759

contributing/documentation/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ Contributing Documentation
66

77
overview
88
format
9+
standards
910
translations
1011
license

contributing/documentation/overview.rst

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -161,55 +161,8 @@ tags would be removed from the new 2.5 branch.
161161
Standards
162162
---------
163163

164-
In order to help the reader as much as possible and to create code examples that
165-
look and feel familiar, you should follow these rules:
166-
167-
* The code follows the :doc:`Symfony Coding Standards</contributing/code/standards>`
168-
as well as the `Twig Coding Standards`_;
169-
* Each line should break approximately after the first word that crosses the
170-
72nd character (so most lines end up being 72-78 characters);
171-
* To avoid horizontal scrolling on code blocks, we prefer to break a line
172-
correctly if it crosses the 85th character;
173-
* When you fold one or more lines of code, place ``...`` in a comment at the point
174-
of the fold. These comments are: ``// ...`` (php), ``# ...`` (yaml/bash), ``{# ... #}``
175-
(twig), ``<!-- ... -->`` (xml/html), ``; ...`` (ini), ``...`` (text);
176-
* When you fold a part of a line, e.g. a variable value, put ``...`` (without comment)
177-
at the place of the fold;
178-
* Description of the folded code: (optional)
179-
If you fold several lines: the description of the fold can be placed after the ``...``
180-
If you fold only part of a line: the description can be placed before the line;
181-
* If useful, a ``codeblock`` should begin with a comment containing the filename
182-
of the file in the code block. Don't place a blank line after this comment,
183-
unless the next line is also a comment;
184-
* You should put a ``$`` in front of every bash line;
185-
* The ``::`` shorthand is preferred over ``.. code-block:: php`` to begin a PHP
186-
code block;
187-
* You should use a form of *you* instead of *we*.
188-
189-
An example::
190-
191-
// src/Foo/Bar.php
192-
193-
// ...
194-
class Bar
195-
{
196-
// ...
197-
198-
public function foo($bar)
199-
{
200-
// set foo with a value of bar
201-
$foo = ...;
202-
203-
// ... check if $bar has the correct value
204-
205-
return $foo->baz($bar, ...);
206-
}
207-
}
208-
209-
.. caution::
210-
211-
In Yaml you should put a space after ``{`` and before ``}`` (e.g. ``{ _controller: ... }``),
212-
but this should not be done in Twig (e.g. ``{'hello' : 'value'}``).
164+
All documentation in the Symfony Documentation should follow
165+
:doc:`the documentation standards <standards>`.
213166

214167
Reporting an Issue
215168
------------------
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
Documentation Standards
2+
=======================
3+
4+
In order to help the reader as much as possible and to create code examples that
5+
look and feel familiar, you should follow these standards.
6+
7+
Sphinx
8+
------
9+
10+
* The following characters are choosen for different heading levels: level 1
11+
is ``=``, level 2 ``-``, level 3 ``~``, level 4 ``.`` and level 5 ``"``;
12+
* Each line should break approximately after the first word that crosses the
13+
72nd character (so most lines end up being 72-78 characters);
14+
* The ``::`` shorthand is *preferred* over ``.. code-block:: php`` to begin a PHP
15+
code block (read `the Sphinx documentation`_ to see when you should use the
16+
shorthand);
17+
* Inline hyperlinks are **not** used. Seperate the link and their target
18+
definition, which you add on the bottom of the page;
19+
* You should use a form of *you* instead of *we*.
20+
21+
Example
22+
~~~~~~~
23+
24+
.. code-block:: ReST
25+
26+
Example
27+
=======
28+
29+
When you are working on the docs, you should follow the `Symfony Docs`_
30+
standards.
31+
32+
Level 2
33+
-------
34+
35+
A PHP example would be::
36+
37+
echo 'Hello World';
38+
39+
Level 3
40+
~~~~~~~
41+
42+
.. code-block:: php
43+
44+
echo 'You cannot use the :: shortcut here';
45+
46+
.. _`Symfony Docs`: http://symfony.com/doc/current/contributing/documentation/standards.html
47+
48+
Code Examples
49+
-------------
50+
51+
* The code follows the :doc:`Symfony Coding Standards</contributing/code/standards>`
52+
as well as the `Twig Coding Standards`_;
53+
* To avoid horizontal scrolling on code blocks, we prefer to break a line
54+
correctly if it crosses the 85th character;
55+
* When you fold one or more lines of code, place ``...`` in a comment at the point
56+
of the fold. These comments are: ``// ...`` (php), ``# ...`` (yaml/bash), ``{# ... #}``
57+
(twig), ``<!-- ... -->`` (xml/html), ``; ...`` (ini), ``...`` (text);
58+
* When you fold a part of a line, e.g. a variable value, put ``...`` (without comment)
59+
at the place of the fold;
60+
* Description of the folded code: (optional)
61+
If you fold several lines: the description of the fold can be placed after the ``...``
62+
If you fold only part of a line: the description can be placed before the line;
63+
* If useful, a ``codeblock`` should begin with a comment containing the filename
64+
of the file in the code block. Don't place a blank line after this comment,
65+
unless the next line is also a comment;
66+
* You should put a ``$`` in front of every bash line.
67+
68+
Formats
69+
~~~~~~~
70+
71+
Configuration examples should show all supported formats using
72+
:ref:`configuration blocks <docs-configuration-blocks>`. The supported formats
73+
(and their orders) are:
74+
75+
* **Configuration** (including services and routing): Yaml, Xml, Php
76+
* **Validation**: Yaml, Annotations, Xml, Php
77+
* **Doctrine Mapping**: Annotations, Yaml, Xml, Php
78+
79+
Example
80+
~~~~~~~
81+
82+
.. code-block:: php
83+
84+
// src/Foo/Bar.php
85+
86+
// ...
87+
class Bar
88+
{
89+
// ...
90+
91+
public function foo($bar)
92+
{
93+
// set foo with a value of bar
94+
$foo = ...;
95+
96+
// ... check if $bar has the correct value
97+
98+
return $foo->baz($bar, ...);
99+
}
100+
}
101+
102+
.. caution::
103+
104+
In Yaml you should put a space after ``{`` and before ``}`` (e.g. ``{ _controller: ... }``),
105+
but this should not be done in Twig (e.g. ``{'hello' : 'value'}``).
106+
107+
.. _`the Sphinx documentation`: http://sphinx-doc.org/rest.html#source-code

contributing/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
* :doc:`Overview </contributing/documentation/overview>`
1515
* :doc:`Format </contributing/documentation/format>`
16+
* :doc:`Documentation Standards </contributing/documentation/standards>`
1617
* :doc:`Translations </contributing/documentation/translations>`
1718
* :doc:`License </contributing/documentation/license>`
1819

0 commit comments

Comments
 (0)