Skip to content

Fixed code examples #1531

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 43 commits into from
Jul 14, 2012
Merged

Fixed code examples #1531

merged 43 commits into from
Jul 14, 2012

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Jul 6, 2012

This should be merged into the 2.0 branch, NOT the master branch. Excuse me for this mistake.

The code examples on the documentation where a little messy. I have changed all code examples to follow these rules:

Rules

  • The code follows the Coding Standards, the Symfony Coding Standards as well as the Twig Coding Standards.
  • When we fold one or more lines of code we place ... in a comment at the point where we fold some code. These comments are: // ... (php), # ... (yaml), {# ... #} (twig), <!-- ... --> (xml/html), ; ... (ini), ... (text)
  • When we fold a part of a line, e.g. a variable value, we put ... (without comment) at the place of the fold.
  • Description about the fold: (optional)

    If we fold some lines: The description can be placed after the ...

    If we fold a part of a line: The description can be placed before the line
  • If usefull, a codeblock begins with a comment with the filename. After this file comment should not be a blank line, except if the next line is a comment too

A very simple example:

// src/Foo/Bar/foo.php
function foo($bar) 
{
    // set foo with a value of bar
    $foo = ...;

    // ... check if $bar has the correct value

    return $foo->baz($bar);
}

Some rules that I haven't included, because it need some more discussion:

  • Do we use the sorthand :: or the codeblock .. code-block:: php for php code?
  • Do we put a $ before every bash line?

Points of attention

  • You should to put a space after { and before } in Yaml (e.g. { _controller: ... }), but this should not be done in Twig (e.g. {'hello' : 'value'}).

  • An array item is a piece of a line, not a total line. So don't use // ... but ..., (the comma because of the Coding Standards):

    array(
        'some value',
        ...,
    )
    

Because I have seen hunderts lines of code it is sure that I have missed some mistakes, so feel free to solve it or place a comment so I can solve it.

wouterj added 30 commits July 5, 2012 08:58
@weaverryan
Copy link
Member

Hey!

I see that you already noticed #1534, which I just merged into 2.0. Can you rebase your commits to include the latest and also make a new PR to the 2.0 branch? You mentioned that this should be merged into the 2.0 branch, but it'll be much easier to review if the PR is against 2.0 since the changeset is so heavy.

Thank you!

@wouterj
Copy link
Member Author

wouterj commented Jul 10, 2012

I have created a new PR: #1548

@weaverryan weaverryan merged commit 917be05 into symfony:master Jul 14, 2012
@wouterj wouterj deleted the fixed_code_examples branch December 31, 2012 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants