-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Refactored Doc standards #2481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Refactored Doc standards #2481
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ Contributing Documentation | |
|
||
overview | ||
format | ||
standards | ||
translations | ||
license |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
Documentation Standards | ||
======================= | ||
|
||
In order to help the reader as much as possible and to create code examples that | ||
look and feel familiar, you should follow these standards. | ||
|
||
Sphinx | ||
------ | ||
|
||
* The following characters are choosen for different heading levels: level 1 | ||
is ``=``, level 2 ``-``, level 3 ``~``, level 4 ``.`` and level 5 ``"``; | ||
* Each line should break approximately after the first word that crosses the | ||
72nd character (so most lines end up being 72-78 characters); | ||
* The ``::`` shorthand is *preferred* over ``.. code-block:: php`` to begin a PHP | ||
code block (read `the Sphinx documentation`_ to see when you should use the | ||
shorthand); | ||
* Inline hyperlinks are **not** used. Seperate the link and their target | ||
definition, which you add on the bottom of the page; | ||
* You should use a form of *you* instead of *we*. | ||
|
||
Example | ||
~~~~~~~ | ||
|
||
.. code-block:: ReST | ||
|
||
Example | ||
======= | ||
|
||
When you are working on the docs, you should follow the `Symfony Docs`_ | ||
standards. | ||
|
||
Level 2 | ||
------- | ||
|
||
A PHP example would be:: | ||
|
||
echo 'Hello World'; | ||
|
||
Level 3 | ||
~~~~~~~ | ||
|
||
.. code-block:: php | ||
|
||
echo 'You cannot use the :: shortcut here'; | ||
|
||
.. _`Symfony Docs`: http://symfony.com/doc/current/contributing/documentation/standards.html | ||
|
||
Code Examples | ||
------------- | ||
|
||
* The code follows the :doc:`Symfony Coding Standards</contributing/code/standards>` | ||
as well as the `Twig Coding Standards`_; | ||
* To avoid horizontal scrolling on code blocks, we prefer to break a line | ||
correctly if it crosses the 85th character; | ||
* When you fold one or more lines of code, place ``...`` in a comment at the point | ||
of the fold. These comments are: ``// ...`` (php), ``# ...`` (yaml/bash), ``{# ... #}`` | ||
(twig), ``<!-- ... -->`` (xml/html), ``; ...`` (ini), ``...`` (text); | ||
* When you fold a part of a line, e.g. a variable value, put ``...`` (without comment) | ||
at the place of the fold; | ||
* Description of the folded code: (optional) | ||
If you fold several lines: the description of the fold can be placed after the ``...`` | ||
If you fold only part of a line: the description can be placed before the line; | ||
* If useful, a ``codeblock`` should begin with a comment containing the filename | ||
of the file in the code block. Don't place a blank line after this comment, | ||
unless the next line is also a comment; | ||
* You should put a ``$`` in front of every bash line. | ||
|
||
Formats | ||
~~~~~~~ | ||
|
||
Configuration examples should show all supported formats using | ||
:ref:`configuration blocks <docs-configuration-blocks>`. The supported formats | ||
(and their orders) are: | ||
|
||
* **Configuration** (including services and routing): Yaml, Xml, Php | ||
* **Validation**: Yaml, Annotations, Xml, Php | ||
* **Doctrine Mapping**: Annotations, Yaml, Xml, Php | ||
|
||
Example | ||
~~~~~~~ | ||
|
||
.. code-block:: php | ||
|
||
// src/Foo/Bar.php | ||
|
||
// ... | ||
class Bar | ||
{ | ||
// ... | ||
|
||
public function foo($bar) | ||
{ | ||
// set foo with a value of bar | ||
$foo = ...; | ||
|
||
// ... check if $bar has the correct value | ||
|
||
return $foo->baz($bar, ...); | ||
} | ||
} | ||
|
||
.. caution:: | ||
|
||
In Yaml you should put a space after ``{`` and before ``}`` (e.g. ``{ _controller: ... }``), | ||
but this should not be done in Twig (e.g. ``{'hello' : 'value'}``). | ||
|
||
.. _`the Sphinx documentation`: http://sphinx-doc.org/rest.html#source-code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about an example below all of this that shows these rules in action (as much as possible).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that. I need to think of a good example, it's hard to put most standards in one example without the example being to dummy... :)