Skip to content
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

Introduce DOCtor-RST #613

Merged
merged 14 commits into from
Feb 26, 2020
14 changes: 14 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
on: [push, pull_request]
name: Lint
jobs:
doctor-rst:
name: DOCtor-RST
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: DOCtor-RST
uses: docker://oskarstark/doctor-rst
with:
args: --short
env:
DOCS_DIR: 'Resources/doc/'
47 changes: 47 additions & 0 deletions Resources/doc/.doctor-rst.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
rules:
no_inheritdoc: ~
avoid_repetetive_words: ~
blank_line_after_directive: ~
short_array_syntax: ~
typo: ~
replacement: ~
versionadded_directive_should_have_version: ~
deprecated_directive_should_have_version: ~
max_blank_lines:
max: 2
american_english: ~
valid_use_statements: ~
no_composer_req: ~
composer_dev_option_not_at_the_end: ~
no_php_open_tag_in_code_block_php_directive: ~
no_blank_line_after_filepath_in_php_code_block: ~
no_blank_line_after_filepath_in_yaml_code_block: ~
no_blank_line_after_filepath_in_xml_code_block: ~
no_blank_line_after_filepath_in_twig_code_block: ~
php_prefix_before_bin_console: ~
use_deprecated_directive_instead_of_versionadded: ~
space_before_self_xml_closing_tag: ~
ensure_order_of_code_blocks_in_configuration_block: ~
lowercase_as_in_use_statements: ~
ordered_use_statements: ~
no_namespace_after_use_statements: ~
replace_code_block_types: ~
use_https_xsd_urls: ~
blank_line_before_directive: ~
extension_xlf_instead_of_xliff: ~
valid_inline_highlighted_namespaces: ~
indention: ~
unused_links: ~
no_app_bundle: ~

versionadded_directive_major_version:
major_version: 3

versionadded_directive_min_version:
min_version: '3.0'

deprecated_directive_major_version:
major_version: 3

deprecated_directive_min_version:
min_version: '3.0'
Comment on lines +37 to +47
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After up merging into 4.x this must be change accordingly. Same for master, if this will be next 5.0, otherwise not.

41 changes: 20 additions & 21 deletions Resources/doc/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Sample Configuration
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine_mongodb="http://symfony.com/schema/dic/doctrine/odm/mongodb"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb http://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb https://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">

<doctrine_mongodb:config default-database="hello_%kernel.environment%">
<doctrine_mongodb:connection id="default" server="mongodb://localhost:27017">
Expand Down Expand Up @@ -98,8 +98,8 @@ If you wish to use memcache to cache your metadata, you need to configure the
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine_mongodb="http://symfony.com/schema/dic/doctrine/odm/mongodb"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb http://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb https://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">

<doctrine_mongodb:config default-database="hello_%kernel.environment%">
<doctrine_mongodb:document-manager id="default">
Expand Down Expand Up @@ -195,8 +195,8 @@ The following configuration shows a bunch of mapping examples:
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine_mongodb="http://symfony.com/schema/dic/doctrine/odm/mongodb"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb http://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb https://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">

<doctrine_mongodb:config>
<doctrine_mongodb:document-manager id="default">
Expand Down Expand Up @@ -251,8 +251,8 @@ Filters may be registered with a document manager by using the following syntax:
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine="http://symfony.com/schema/dic/doctrine/odm/mongodb"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb http://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb https://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">

<doctrine:mongodb>
<doctrine:connection id="default" server="mongodb://localhost:27017" />
Expand Down Expand Up @@ -317,8 +317,8 @@ following syntax:
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine_mongodb="http://symfony.com/schema/dic/doctrine/odm/mongodb"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb http://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb https://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">

<doctrine_mongodb:config
default-database="hello_%kernel.environment%"
Expand Down Expand Up @@ -382,8 +382,8 @@ string as a comma separated list.
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine="http://symfony.com/schema/dic/doctrine/odm/mongodb"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb http://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb https://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">

<doctrine:mongodb>
<doctrine:connection id="default" server="mongodb://mongodb-01:27017,mongodb-02:27017,mongodb-03:27017" />
Expand Down Expand Up @@ -423,11 +423,11 @@ Otherwise you will get a *auth failed* exception.
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine="http://symfony.com/schema/dic/doctrine/odm/mongodb"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb http://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb https://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">

<doctrine:mongodb>
<doctrine:connection id="default" server="mongodb://localhost:27017"/>
<doctrine:connection id="default" server="mongodb://localhost:27017" />
<doctrine:options
username="someuser"
password="somepass"
Expand Down Expand Up @@ -481,11 +481,11 @@ You can then use this service in your configuration:
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine="http://symfony.com/schema/dic/doctrine/odm/mongodb"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb http://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb https://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">

<doctrine:mongodb>
<doctrine:connection id="default" server="mongodb://localhost:27017"/>
<doctrine:connection id="default" server="mongodb://localhost:27017" />
<doctrine:driver-options
context="app.mongodb.context_service"
>
Expand All @@ -494,7 +494,6 @@ You can then use this service in your configuration:
</doctrine:mongodb>
</container>


Retrying Connections and Queries
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -589,8 +588,8 @@ Full Default Configuration
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine="http://symfony.com/schema/dic/doctrine/odm/mongodb"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb http://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine/odm/mongodb https://symfony.com/schema/dic/doctrine/odm/mongodb/mongodb-1.0.xsd">

<doctrine:config
auto-generate-hydrator-classes="0"
Expand Down
33 changes: 15 additions & 18 deletions Resources/doc/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ So, in this tutorial we begin with the model for a ``User`` document:
// src/Acme/AccountBundle/Document/User.php
namespace Acme\AccountBundle\Document;

use Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique as MongoDBUnique;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique as MongoDBUnique;

/**
* @MongoDB\Document(collection="users")
Expand Down Expand Up @@ -90,31 +90,31 @@ Next, create the form for the ``User`` model:
// src/Acme/AccountBundle/Form/Type/UserType.php
namespace Acme\AccountBundle\Form\Type;

use Acme\AccountBundle\Document\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Acme\AccountBundle\Document\User;

class UserType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('email', EmailType::class);
$builder->add('password', RepeatedType::class, array(
'first_name' => 'password',
'second_name' => 'confirm',
'type' => PasswordType::class
));
$builder->add('password', RepeatedType::class, [
'first_name' => 'password',
'second_name' => 'confirm',
'type' => PasswordType::class
]);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
$resolver->setDefaults([
'data_class' => User::class,
));
]);
}
}

Expand Down Expand Up @@ -143,9 +143,8 @@ represents the "registration":
// src/Acme/AccountBundle/Form/Model/Registration.php
namespace Acme\AccountBundle\Form\Model;

use Symfony\Component\Validator\Constraints as Assert;

use Acme\AccountBundle\Document\User;
use Symfony\Component\Validator\Constraints as Assert;

class Registration
{
Expand Down Expand Up @@ -197,7 +196,7 @@ Next, create the form for this ``Registration`` model:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('user', UserType::class);
$builder->add('terms', CheckboxType::class, array('property_path' => 'termsAccepted'));
$builder->add('terms', CheckboxType::class, ['property_path' => 'termsAccepted']);
}
}

Expand All @@ -217,19 +216,18 @@ controller for displaying the registration form:
// src/Acme/AccountBundle/Controller/AccountController.php
namespace Acme\AccountBundle\Controller;

use Acme\AccountBundle\Form\Model\Registration;
use Acme\AccountBundle\Form\Type\RegistrationType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

use Acme\AccountBundle\Form\Type\RegistrationType;
use Acme\AccountBundle\Form\Model\Registration;

class AccountController extends Controller
{
public function registerAction()
{
$form = $this->createForm(RegistrationType::class, new Registration());

return $this->render('AcmeAccountBundle:Account:register.html.twig', array('form' => $form->createView()));
return $this->render('AcmeAccountBundle:Account:register.html.twig', ['form' => $form->createView()]);
}
}

Expand All @@ -238,7 +236,6 @@ and its template:
.. code-block:: html+jinja

{# src/Acme/AccountBundle/Resources/views/Account/register.html.twig #}

<form action="{{ path('create')}}" method="post" {{ form_enctype(form) }}>
{{ form_widget(form) }}

Expand Down Expand Up @@ -267,7 +264,7 @@ the validation and saves the data into MongoDB:
return $this->redirect(...);
}

return $this->render('AcmeAccountBundle:Account:register.html.twig', array('form' => $form->createView()));
return $this->render('AcmeAccountBundle:Account:register.html.twig', ['form' => $form->createView()]);
}

That's it! Your form now validates, and allows you to save the ``User``
Expand Down
Loading