Skip to content

Commit

Permalink
Use Terminal lexer for console examples
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj authored and xabbuh committed Sep 21, 2016
1 parent c72dde0 commit ecf5d16
Show file tree
Hide file tree
Showing 84 changed files with 252 additions and 223 deletions.
23 changes: 23 additions & 0 deletions _build/_theme/_exts/symfonycom/sphinx/lexer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from pygments.lexer import RegexLexer, bygroups, using
from pygments.token import *
from pygments.lexers.shell import BashLexer, BatchLexer

class TerminalLexer(RegexLexer):
name = 'Terminal'
aliases = ['terminal']
filenames = []

tokens = {
'root': [
('^\$', Generic.Prompt, 'bash-prompt'),
('^[^\n>]+>', Generic.Prompt, 'dos-prompt'),
('^#.+$', Comment.Single),
('^.+$', Generic.Output),
],
'bash-prompt': [
('(.+)$', bygroups(using(BashLexer)), '#pop')
],
'dos-prompt': [
('(.+)$', bygroups(using(BatchLexer)), '#pop')
],
}
2 changes: 2 additions & 0 deletions _build/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from pygments.lexers.special import TextLexer
from pygments.lexers.text import RstLexer
from pygments.lexers.web import PhpLexer
from symfonycom.sphinx.lexer import TerminalLexer

# -- General configuration -----------------------------------------------------

Expand Down Expand Up @@ -108,6 +109,7 @@
lexers['rst'] = RstLexer()
lexers['varnish3'] = CLexer()
lexers['varnish4'] = CLexer()
lexers['terminal'] = TerminalLexer()

config_block = {
'markdown': 'Markdown',
Expand Down
6 changes: 3 additions & 3 deletions assetic/asset_management.rst
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ environment is just too slow.
Instead, each time you use your application in the ``prod`` environment (and therefore,
each time you deploy), you should run the following command:

.. code-block:: bash
.. code-block:: terminal
$ php app/console assetic:dump --env=prod --no-debug
Expand Down Expand Up @@ -565,7 +565,7 @@ the following change in your ``config_dev.yml`` file:
Next, since Symfony is no longer generating these assets for you, you'll
need to dump them manually. To do so, run the following command:

.. code-block:: bash
.. code-block:: terminal
$ php app/console assetic:dump
Expand All @@ -574,7 +574,7 @@ environment. The big disadvantage is that you need to run this each time
you update an asset. Fortunately, by using the ``assetic:watch`` command,
assets will be regenerated automatically *as they change*:

.. code-block:: bash
.. code-block:: terminal
$ php app/console assetic:watch
Expand Down
2 changes: 1 addition & 1 deletion assetic/php.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ associated libraries. Therefore, before enabling the filters used in this articl
you must install two libraries. Open a command console, browse to your project
directory and execute the following commands:

.. code-block:: bash
.. code-block:: terminal
$ composer require leafo/scssphp
$ composer require patchwork/jsqueeze
Expand Down
12 changes: 6 additions & 6 deletions assetic/uglifyjs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ The global installation method makes all your projects use the very same UglifyJ
version, which simplifies its maintenance. Open your command console and execute
the following command (you may need to run it as a root user):

.. code-block:: bash
.. code-block:: terminal
$ npm install -g uglify-js
Now you can execute the global ``uglifyjs`` command anywhere on your system:

.. code-block:: bash
.. code-block:: terminal
$ uglifyjs --help
Expand All @@ -43,7 +43,7 @@ It's also possible to install UglifyJS inside your project only, which is useful
when your project requires a specific UglifyJS version. To do this, install it
without the ``-g`` option and specify the path where to put the module:

.. code-block:: bash
.. code-block:: terminal
$ cd /path/to/your/symfony/project
$ npm install uglify-js --prefix app/Resources
Expand All @@ -55,7 +55,7 @@ an npm `package.json`_ file and specify your dependencies there.
Now you can execute the ``uglifyjs`` command that lives in the ``node_modules``
directory:

.. code-block:: bash
.. code-block:: terminal
$ "./app/Resources/node_modules/.bin/uglifyjs" --help
Expand Down Expand Up @@ -113,7 +113,7 @@ your JavaScripts:
The path where UglifyJS is installed may vary depending on your system.
To find out where npm stores the ``bin`` folder, execute the following command:

.. code-block:: bash
.. code-block:: terminal
$ npm bin -g
Expand Down Expand Up @@ -249,7 +249,7 @@ Install, Configure and Use UglifyCSS
The usage of UglifyCSS works the same way as UglifyJS. First, make sure
the node package is installed:

.. code-block:: bash
.. code-block:: terminal
# global installation
$ npm install -g uglifycss
Expand Down
4 changes: 2 additions & 2 deletions best_practices/business-logic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ Data Fixtures
As fixtures support is not enabled by default in Symfony, you should execute
the following command to install the Doctrine fixtures bundle:

.. code-block:: bash
.. code-block:: terminal
$ composer require "doctrine/doctrine-fixtures-bundle"
Expand Down Expand Up @@ -316,7 +316,7 @@ Assuming you have at least one fixtures class and that the database access
is configured properly, you can load your fixtures by executing the following
command:

.. code-block:: bash
.. code-block:: terminal
$ php app/console doctrine:fixtures:load
Expand Down
4 changes: 2 additions & 2 deletions best_practices/creating-the-project.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Now that everything is correctly set up, you can create a new project based on
Symfony. In your command console, browse to a directory where you have permission
to create files and execute the following commands:

.. code-block:: bash
.. code-block:: terminal
# Linux, Mac OS X
$ cd projects/
Expand Down Expand Up @@ -145,7 +145,7 @@ that follows these best practices:
If your Symfony installation doesn't come with a pre-generated AppBundle,
you can generate it by hand executing this command:

.. code-block:: bash
.. code-block:: terminal
$ php app/console generate:bundle --namespace=AppBundle --dir=src --format=annotation --no-interaction
Expand Down
2 changes: 1 addition & 1 deletion best_practices/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ best practices in mind. This project, called the Symfony Demo application, can
be obtained through the Symfony Installer. First, `download and install`_ the
installer and then execute this command to download the demo application:

.. code-block:: bash
.. code-block:: terminal
# Linux and Mac OS X
$ symfony demo
Expand Down
2 changes: 1 addition & 1 deletion best_practices/templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ the Markdown contents of each post into HTML.
To do this, first, install the excellent `Parsedown`_ Markdown parser as
a new dependency of the project:

.. code-block:: bash
.. code-block:: terminal
$ composer require erusev/parsedown
Expand Down
2 changes: 1 addition & 1 deletion bundles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ And while it doesn't do anything yet, AcmeTestBundle is now ready to be used.
And as easy as this is, Symfony also provides a command-line interface for
generating a basic bundle skeleton:

.. code-block:: bash
.. code-block:: terminal
$ php app/console generate:bundle --namespace=Acme/TestBundle
Expand Down
4 changes: 2 additions & 2 deletions bundles/best_practices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ following standardized instructions in your ``README.md`` file.
Open a command console, enter your project directory and execute the
following command to download the latest stable version of this bundle:
```bash
```console
$ composer require <package-name> "~1"
```
Expand Down Expand Up @@ -254,7 +254,7 @@ following standardized instructions in your ``README.md`` file.
Open a command console, enter your project directory and execute the
following command to download the latest stable version of this bundle:
.. code-block:: bash
.. code-block:: terminal
$ composer require <package-name> "~1"
Expand Down
8 changes: 4 additions & 4 deletions bundles/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ the bundle on the `Packagist.org`_ site.

Now that you know the package name, you can install it via Composer:

.. code-block:: bash
.. code-block:: terminal
$ composer require friendsofsymfony/user-bundle
This will choose the best version for your project, add it to ``composer.json``
and download its code into the ``vendor/`` directory. If you need a specific
version, include it as the second argument of the `composer require`_ command:

.. code-block:: bash
.. code-block:: terminal
$ composer require friendsofsymfony/user-bundle "~2.0"
Expand Down Expand Up @@ -106,14 +106,14 @@ in ``app/config/config.yml``. The bundle's documentation will tell you about
the configuration, but you can also get a reference of the bundle's configuration
via the ``config:dump-reference`` command:

.. code-block:: bash
.. code-block:: terminal
$ app/console config:dump-reference AsseticBundle
Instead of the full bundle name, you can also pass the short name used as the root
of the bundle's configuration:

.. code-block:: bash
.. code-block:: terminal
$ app/console config:dump-reference assetic
Expand Down
2 changes: 1 addition & 1 deletion components/console/changing_default_command.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Executing the application and changing the default Command::

Test the new default console command by running the following:

.. code-block:: bash
.. code-block:: terminal
$ php application.php
Expand Down
28 changes: 14 additions & 14 deletions components/console/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@ Built-in Commands
There is a built-in command ``list`` which outputs all the standard options
and the registered commands:

.. code-block:: bash
.. code-block:: terminal
$ php application.php list
You can get the same output by not running any command as well

.. code-block:: bash
.. code-block:: terminal
$ php application.php
The help command lists the help information for the specified command. For
example, to get the help for the ``list`` command:

.. code-block:: bash
.. code-block:: terminal
$ php application.php help list
Running ``help`` without specifying a command will list the global options:

.. code-block:: bash
.. code-block:: terminal
$ php application.php help
Expand All @@ -57,29 +57,29 @@ Global Options
You can get help information for any command with the ``--help`` option. To
get help for the list command:

.. code-block:: bash
.. code-block:: terminal
$ php application.php list --help
$ php application.php list -h
You can suppress output with:

.. code-block:: bash
.. code-block:: terminal
$ php application.php list --quiet
$ php application.php list -q
You can get more verbose messages (if this is supported for a command)
with:

.. code-block:: bash
.. code-block:: terminal
$ php application.php list --verbose
$ php application.php list -v
To output even more verbose messages you can use these options:

.. code-block:: bash
.. code-block:: terminal
$ php application.php list -vv
$ php application.php list -vvv
Expand All @@ -90,7 +90,7 @@ If you set the optional arguments to give your application a name and version::

then you can use:

.. code-block:: bash
.. code-block:: terminal
$ php application.php list --version
$ php application.php list -V
Expand All @@ -109,19 +109,19 @@ If you do not provide both arguments then it will just output:
You can force turning on ANSI output coloring with:

.. code-block:: bash
.. code-block:: terminal
$ php application.php list --ansi
or turn it off with:

.. code-block:: bash
.. code-block:: terminal
$ php application.php list --no-ansi
You can suppress any interactive questions from the command you are running with:

.. code-block:: bash
.. code-block:: terminal
$ php application.php list --no-interaction
$ php application.php list -n
Expand All @@ -133,7 +133,7 @@ You do not have to type out the full command names. You can just type the
shortest unambiguous name to run a command. So if there are non-clashing
commands, then you can run ``help`` like this:

.. code-block:: bash
.. code-block:: terminal
$ php application.php h
Expand All @@ -142,7 +142,7 @@ to type the shortest unambiguous text for each part. If you have created the
``demo:greet`` as shown in :doc:`/components/console` then you
can run it with:

.. code-block:: bash
.. code-block:: terminal
$ php application.php d:g Fabien
Expand Down
Loading

0 comments on commit ecf5d16

Please sign in to comment.