Skip to content

Fix code-diff #14971

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions configuration/dot-env-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,18 @@ changes can be made to any Symfony 3.4 or higher app:
#. Update ``.gitignore``:

.. code-block:: diff
:dedent: 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to set this in the config without the need to change all examples?

Copy link
Member Author

@jderusse jderusse Feb 13, 2021

Choose a reason for hiding this comment

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

In fact we don't care about this flag, it just helps Sphinx to get the indentation.
Here are 2 identical exemples

.. code-block:: diff
    + added
      not changed
.. code-block:: diff
      added
    + not changed

In the first one, Sphinx is able to get that indentation of the bloc is 4. But in the second, is it 6 like suggested by the first line? or 4?
So we need something to help Sphinx to figure out the indentation of the bloc.

I would need Sphinx locally to test if this is really needed, maybe you can help me with that?


# .gitignore
# ...
# .gitignore
# ...

###> symfony/framework-bundle ###
###> symfony/framework-bundle ###
- /.env
+ /.env.local
+ /.env.local.php
+ /.env.*.local

# ...
# ...

#. Rename ``.env`` to ``.env.local`` and ``.env.dist`` to ``.env``:

Expand Down
11 changes: 6 additions & 5 deletions controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,18 @@ Add the ``use`` statement atop your controller class and then modify
``LuckyController`` to extend it:

.. code-block:: diff
:dedent: 0

// src/Controller/LuckyController.php
namespace App\Controller;
// src/Controller/LuckyController.php
namespace App\Controller;

+ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

- class LuckyController
+ class LuckyController extends AbstractController
{
// ...
}
{
// ...
}

That's it! You now have access to methods like :ref:`$this->render() <controller-rendering-templates>`
and many others that you'll learn about next.
Expand Down
15 changes: 8 additions & 7 deletions doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -279,21 +279,22 @@ This adds the new ``description`` property and ``getDescription()`` and ``setDes
methods:

.. code-block:: diff
:dedent: 0

// src/Entity/Product.php
// ...
// src/Entity/Product.php
// ...

class Product
{
// ...
class Product
{
// ...

+ /**
+ * @ORM\Column(type="text")
+ */
+ private $description;

// getDescription() & setDescription() were also added
}
// getDescription() & setDescription() were also added
}

The new property is mapped, but it doesn't exist yet in the ``product`` table. No
problem! Generate a new migration:
Expand Down
17 changes: 9 additions & 8 deletions frontend/encore/cdn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ Are you deploying to a CDN? That's awesome :) Once you've made sure that your
built files are uploaded to the CDN, configure it in Encore:

.. code-block:: diff
:dedent: 0

// webpack.config.js
// ...
// webpack.config.js
// ...

Encore
.setOutputPath('public/build/')
// in dev mode, don't use the CDN
.setPublicPath('/build');
// ...
;
Encore
.setOutputPath('public/build/')
// in dev mode, don't use the CDN
.setPublicPath('/build');
// ...
;

+ if (Encore.isProduction()) {
+ Encore.setPublicPath('https://my-cool-app.com.global.prod.fastly.net');
Expand Down
9 changes: 5 additions & 4 deletions frontend/encore/copy-files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ Webpack - like a template - you can use the ``copyFiles()`` method to copy those
files into your final output directory.

.. code-block:: diff
:dedent: 0

// webpack.config.js
// webpack.config.js

Encore
// ...
.setOutputPath('public/build/')
Encore
// ...
.setOutputPath('public/build/')

+ .copyFiles({
+ from: './assets/images',
Expand Down
9 changes: 5 additions & 4 deletions frontend/encore/custom-loaders-plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ via the ``addPlugin()`` method. For example, if you use `Moment.js`_, you might
to use the `IgnorePlugin`_ (see `moment/moment#2373`_):

.. code-block:: diff
:dedent: 0

// webpack.config.js
// webpack.config.js
+ var webpack = require('webpack');

Encore
// ...
Encore
// ...

+ .addPlugin(new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/))
;
;

.. _`handlebars-loader`: https://github.com/pcardune/handlebars-loader
.. _`plugins`: https://webpack.js.org/plugins/
Expand Down
9 changes: 5 additions & 4 deletions frontend/encore/dev-server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ you'll need to also tell the dev-server to use HTTPS. To do this, you can reuse
server SSL certificate:

.. code-block:: diff
:dedent: 0

// webpack.config.js
// ...
// webpack.config.js
// ...
+ const path = require('path');

Encore
// ...
Encore
// ...

+ .configureDevServerOptions(options => {
+ options.https = {
Expand Down
11 changes: 6 additions & 5 deletions frontend/encore/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ If your app does not live at the root of your web server (i.e. it lives under a
like ``/myAppSubdir``), you will need to configure that when calling ``Encore.setPublicPath()``:

.. code-block:: diff
:dedent: 0

// webpack.config.js
Encore
// ...
// webpack.config.js
Encore
// ...

.setOutputPath('public/build/')
.setOutputPath('public/build/')

- .setPublicPath('/build')
+ // this is your *true* public path
Expand All @@ -76,7 +77,7 @@ like ``/myAppSubdir``), you will need to configure that when calling ``Encore.se
+ // this is now needed so that your manifest.json keys are still `build/foo.js`
+ // (which is a file that's used by Symfony's `asset()` function)
+ .setManifestKeyPrefix('build')
;
;

If you're using the ``encore_entry_script_tags()`` and ``encore_entry_link_tags()``
Twig shortcuts (or are :ref:`processing your assets through entrypoints.json <load-manifest-files>`
Expand Down
12 changes: 7 additions & 5 deletions frontend/encore/legacy-applications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ jQuery plugins often expect that jQuery is already available via the ``$`` or
``webpack.config.js`` file:

.. code-block:: diff
:dedent: 0

Encore
// ...
Encore
// ...
+ .autoProvidejQuery()
;
;

After restarting Encore, Webpack will look for all uninitialized ``$`` and ``jQuery``
variables and automatically require ``jquery`` and set those variables for you.
Expand Down Expand Up @@ -73,9 +74,10 @@ For example, in your ``app.js`` file that's processed by Webpack and loaded on e
page, add:

.. code-block:: diff
:dedent: 0

// require jQuery normally
const $ = require('jquery');
// require jQuery normally
const $ = require('jquery');

+ // create global $ and jQuery variables
+ global.$ = global.jQuery = $;
Expand Down
28 changes: 16 additions & 12 deletions frontend/encore/postcss.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,35 @@ Next, create a ``postcss.config.js`` file at the root of your project:
Then, enable the loader in Encore!

.. code-block:: diff
:dedent: 0

// webpack.config.js
// webpack.config.js

Encore
// ...
Encore
// ...
+ .enablePostCssLoader()
;
;

Because you just modified ``webpack.config.js``, stop and restart Encore.

That's it! The ``postcss-loader`` will now be used for all CSS, Sass, etc files.
You can also pass options to the `postcss-loader`_ by passing a callback:

.. code-block:: diff
:dedent: 0

// webpack.config.js
// webpack.config.js
+ const path = require('path');

Encore
// ...
Encore
// ...
+ .enablePostCssLoader((options) => {
+ options.postcssOptions = {
+ // the directory where the postcss.config.js file is stored
+ config: path.resolve(__dirname, 'sub-dir', 'custom.config.js'),
+ };
+ })
;
;

.. _browserslist_package_config:

Expand All @@ -65,26 +67,28 @@ support. The best-practice is to configure this directly in your ``package.json`
(so that all the tools can read this):

.. code-block:: diff
:dedent: 0

{
{
+ "browserslist": [
+ "defaults"
+ ]
}
}

The ``defaults`` option is recommended for most users and would be equivalent
to the following browserslist:

.. code-block:: diff
:dedent: 0

{
{
+ "browserslist": [
+ "> 0.5%",
+ "last 2 versions",
+ "Firefox ESR",
+ "not dead"
+ ]
}
}

See `browserslist`_ for more details on the syntax.

Expand Down
11 changes: 6 additions & 5 deletions frontend/encore/reactjs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ Using React? First add some dependencies with Yarn:
Enable react in your ``webpack.config.js``:

.. code-block:: diff
:dedent: 0

// webpack.config.js
// ...
// webpack.config.js
// ...

Encore
// ...
Encore
// ...
+ .enableReactPreset()
;
;


Then restart Encore. When you do, it will give you a command you can run to
Expand Down
33 changes: 19 additions & 14 deletions frontend/encore/simple-example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ We'll use jQuery to print this message on the page. Install it via:
Great! Use ``import`` to import ``jquery`` and ``greet.js``:

.. code-block:: diff
:dedent: 0

// assets/app.js
// ...
// assets/app.js
// ...

+ // loads the jquery package from node_modules
+ import jquery from 'jquery';
Expand Down Expand Up @@ -208,14 +209,15 @@ etc.). To handle this, create a new "entry" JavaScript file for each page:
Next, use ``addEntry()`` to tell Webpack to read these two new files when it builds:

.. code-block:: diff
:dedent: 0

// webpack.config.js
Encore
// ...
.addEntry('app', './assets/app.js')
// webpack.config.js
Encore
// ...
.addEntry('app', './assets/app.js')
+ .addEntry('checkout', './assets/checkout.js')
+ .addEntry('account', './assets/account.js')
// ...
// ...

And because you just changed the ``webpack.config.js`` file, make sure to stop
and restart Encore:
Expand All @@ -232,9 +234,10 @@ Finally, include the ``script`` and ``link`` tags on the individual pages where
you need them:

.. code-block:: diff
:dedent: 0

{# templates/.../checkout.html.twig #}
{% extends 'base.html.twig' %}
{# templates/.../checkout.html.twig #}
{% extends 'base.html.twig' %}

+ {% block stylesheets %}
+ {{ parent() }}
Expand Down Expand Up @@ -262,21 +265,23 @@ CSS you can also use Sass, LESS or Stylus. To use Sass, rename the ``app.css``
file to ``app.scss`` and update the ``import`` statement:

.. code-block:: diff
:dedent: 0

// assets/app.js
// assets/app.js
- import './styles/app.css';
+ import './styles/app.scss';

Then, tell Encore to enable the Sass pre-processor:

.. code-block:: diff
:dedent: 0

// webpack.config.js
Encore
// ...
// webpack.config.js
Encore
// ...

+ .enableSassLoader()
;
;

Because you just changed your ``webpack.config.js`` file, you'll need to restart
Encore. When you do, you'll see an error!
Expand Down
Loading