Skip to content

Commit 99fa173

Browse files
committed
Use short code block syntax where possible
1 parent 962ffc5 commit 99fa173

File tree

5 files changed

+33
-96
lines changed

5 files changed

+33
-96
lines changed

doc/cache-invalidator.rst

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ Setup
99
-----
1010

1111
Create the cache invalidator by passing a proxy client as
12-
`adapter <http://en.wikipedia.org/wiki/Adapter_pattern>`_:
13-
14-
.. code-block:: php
12+
`adapter <http://en.wikipedia.org/wiki/Adapter_pattern>`_::
1513

1614
use FOS\HttpCache\CacheInvalidator;
1715
use FOS\HttpCache\ProxyClient;
@@ -34,19 +32,15 @@ Invalidating Paths and URLs
3432
Make sure to :doc:`configure your proxy <proxy-configuration>` for purging
3533
first.
3634

37-
Invalidate a path:
38-
39-
.. code-block:: php
35+
Invalidate a path::
4036

4137
$cacheInvalidator->invalidatePath('/users')
4238
->flush()
4339
;
4440

4541
See below for the :ref:`flush() <flush>` method.
4642

47-
Invalidate a URL:
48-
49-
.. code-block:: php
43+
Invalidate a URL::
5044

5145
$cacheInvalidator->invalidatePath('http://www.example.com/users')->flush();
5246

@@ -62,9 +56,7 @@ Refreshing Paths and URLs
6256
6357
$cacheInvalidator->refreshPath('/users')->flush();
6458
65-
Refresh a URL:
66-
67-
.. code-block:: php
59+
Refresh a URL::
6860

6961
$cacheInvalidator->refreshPath('http://www.example.com/users')->flush();
7062

@@ -86,15 +78,11 @@ You can invalidate all URLs matching a regular expression by using the
8678
with a regular expression for the content type and/or the application hostname.
8779

8880
For instance, to invalidate all .css files for all hostnames handled by this
89-
caching proxy:
90-
91-
.. code-block:: php
81+
caching proxy::
9282

9383
$cacheInvalidator->invalidateRegex('.*css$')->flush();
9484

95-
To invalidate all .png files on host example.com:
96-
97-
.. code-block:: php
85+
To invalidate all .png files on host example.com::
9886

9987
$cacheInvalidator
10088
->invalidateRegex('.*', 'image/png', array('example.com'))
@@ -114,9 +102,7 @@ You can also invalidate the cache based on any headers.
114102
Cache client implementations should fill up the headers to at least have the
115103
default headers always present to simplify the cache configuration rules.
116104

117-
To invalidate on a custom header ``X-My-Header``, you would do:
118-
119-
.. code-block:: php
105+
To invalidate on a custom header ``X-My-Header``, you would do::
120106

121107
$cacheInvalidator->invalidate(array('X-My-Header' => 'my-value'))->flush();
122108

@@ -148,9 +134,7 @@ Assume you sent four responses:
148134
| ``/four`` | ``tag-four, group-b`` |
149135
+------------+-------------------------+
150136

151-
You can now invalidate some URLs using tags:
152-
153-
.. code-block:: php
137+
You can now invalidate some URLs using tags::
154138

155139
$cacheInvalidator->invalidateTags(array('group-a', 'tag-four'))->flush();
156140

@@ -174,9 +158,7 @@ Flushing
174158
--------
175159

176160
The CacheInvalidator internally queues the invalidation requests and only sends
177-
them out to your HTTP proxy when you call ``flush()``:
178-
179-
.. code-block:: php
161+
them out to your HTTP proxy when you call ``flush()``::
180162

181163
$cacheInvalidator
182164
->invalidateRoute(...)
@@ -208,9 +190,7 @@ These exception are of two types:
208190
* ``\FOS\HttpCache\ProxyResponseException`` when the caching proxy returns an
209191
error response, such as 403 Forbidden.
210192

211-
So, to catch exceptions:
212-
213-
.. code-block:: php
193+
So, to catch exceptions::
214194

215195
use FOS\HttpCache\Exception\ExceptionCollection;
216196

@@ -233,27 +213,21 @@ Logging errors
233213
~~~~~~~~~~~~~~
234214

235215
You can log any exceptions in the following way. First construct a logger that
236-
implements ``\Psr\Log\LoggerInterface``. For instance, when using Monolog_:
237-
238-
.. code-block:: php
216+
implements ``\Psr\Log\LoggerInterface``. For instance, when using Monolog_::
239217

240218
use Monolog\Logger;
241219

242220
$monolog = new Logger(...);
243221
$monolog->pushHandler(...);
244222

245-
Then add the logger as a subscriber to the cache invalidator:
246-
247-
.. code-block:: php
223+
Then add the logger as a subscriber to the cache invalidator::
248224

249225
use FOS\HttpCache\EventListener\LogSubscriber;
250226

251227
$subscriber = new LogSubscriber($monolog);
252228
$cacheInvalidator->addSubscriber($subscriber);
253229

254-
Now, if you flush the invalidator, errors will be logged:
255-
256-
.. code-block:: php
230+
Now, if you flush the invalidator, errors will be logged::
257231

258232
use FOS\HttpCache\Exception\ExceptionCollection;
259233

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
lexers['php'] = PhpLexer(startinline=True, linenos=1)
1010
primary_domain = 'php'
11+
highlight_language = 'php'
1112

1213
# If extensions (or modules to document with autodoc) are in another directory,
1314
# add these directories to sys.path here. If the directory is relative to the

doc/proxy-clients.rst

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ Varnish Client
1515

1616
At minimum, supply an array containing IPs or hostnames of the Varnish servers
1717
that you want to send invalidation requests to. Make sure to include the port
18-
Varnish runs on if it is not port 80.
19-
20-
.. code-block:: php
18+
Varnish runs on if it is not port 80::
2119

2220
use FOS\HttpCache\ProxyClient\Varnish;
2321

@@ -26,9 +24,7 @@ Varnish runs on if it is not port 80.
2624

2725
This is sufficient for invalidating absolute URLs. If you also wish to
2826
invalidate relative paths, supply the hostname (or base URL) where your website
29-
is available as the second parameter:
30-
31-
.. code-block:: php
27+
is available as the second parameter::
3228

3329
$varnish = new Varnish($servers, 'my-cool-app.com');
3430

@@ -41,9 +37,7 @@ Nginx Client
4137

4238
At minimum, supply an array containing IPs or hostnames of the Nginx servers
4339
that you want to send invalidation requests to. Make sure to include the port
44-
Nginx runs on if it is not port 80.
45-
46-
.. code-block:: php
40+
Nginx runs on if it is not port 80::
4741

4842
use FOS\HttpCache\Invalidation\Nginx;
4943

@@ -52,16 +46,12 @@ Nginx runs on if it is not port 80.
5246

5347
This is sufficient for invalidating absolute URLs. If you also wish to
5448
invalidate relative paths, supply the hostname (or base URL) where your website
55-
is available as the second parameter:
56-
57-
.. code-block:: php
49+
is available as the second parameter::
5850

5951
$nginx = new Nginx($servers, 'my-cool-app.com');
6052

6153
If you have configured Nginx to support purge requests at a separate location,
62-
supply that location to the class as the third parameter:
63-
64-
.. code-block:: php
54+
supply that location to the class as the third parameter::
6555

6656
$nginx = new Nginx($servers, 'my-cool-app.com', '/purge');
6757

@@ -100,9 +90,7 @@ Purge
10090
If the caching proxy understands :term:`purge` requests,
10191
its client should implement ``PurgeInterface``. Use the ``purge($url)`` method to
10292
purge one specific URL. The URL can be either an absolute URL or a relative
103-
path:
104-
105-
.. code-block:: php
93+
path::
10694

10795
$client
10896
->purge('http://my-app.com/some/path')
@@ -115,9 +103,7 @@ Refresh
115103

116104
If the caching proxy understands :term:`refresh` requests,
117105
its client should implement ``RefreshInterface``. Use ``refresh()`` to refresh
118-
one specific URL. The URL can be either an absolute URL or a relative path:
119-
120-
.. code-block:: php
106+
one specific URL. The URL can be either an absolute URL or a relative path::
121107

122108
$client
123109
->refresh('http://my-app.com/some/path')
@@ -126,9 +112,7 @@ one specific URL. The URL can be either an absolute URL or a relative path:
126112
;
127113

128114
You can specify HTTP headers as the second argument to ``refresh()``. For
129-
instance, to only refresh the JSON representation of an URL:
130-
131-
.. code-block:: php
115+
instance, to only refresh the JSON representation of an URL::
132116

133117
$client
134118
->refresh('/some/path', array('Accept' => 'application/json')
@@ -146,31 +130,23 @@ You can invalidate all URLs matching a regular expression by using the
146130
for the path to invalidate and an optional content type regular expression and
147131
list of application hostnames.
148132

149-
For instance, to ban all .png files on all application hosts:
150-
151-
.. code-block:: php
133+
For instance, to ban all .png files on all application hosts::
152134

153135
$client->banPath('.*png$');
154136

155-
To ban all HTML URLs that begin with ``/articles/``:
156-
157-
.. code-block:: php
137+
To ban all HTML URLs that begin with ``/articles/``::
158138

159139
$client->banPath('/articles/.*', 'text/html');
160140

161141
By default, URLs will be banned on all application hosts. You can limit this by
162-
specifying a host header:
163-
164-
.. code-block:: php
142+
specifying a host header::
165143

166144
$client->banPath('*.png$', null, '^www.example.com$');
167145

168146
If you want to go beyond banning combinations of path, content type and hostname,
169147
use the ``ban(array $headers)`` method. This method allows you to specify any
170148
combination of headers that should be banned. For instance, when using the
171-
Varnish client:
172-
173-
.. code-block:: php
149+
Varnish client::
174150

175151
use FOS\HttpCache\ProxyClient\Varnish;
176152

doc/testing-your-application.rst

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ Compare this library’s configuration to see how the constants are set:
5555
Overriding Getters
5656
~~~~~~~~~~~~~~~~~~
5757

58-
You can override getters in your test class in the following way.
59-
60-
.. code-block:: php
58+
You can override getters in your test class in the following way::
6159

6260
use FOS\HttpCache\Tests\VarnishTestCase;
6361

@@ -80,9 +78,7 @@ Usage
8078
-----
8179

8280
This example shows how you can test whether the caching headers your
83-
application sets influence Varnish as you expect them to.
84-
85-
.. code-block:: php
81+
application sets influence Varnish as you expect them to::
8682

8783
use FOS\HttpCache\Tests\VarnishTestCase;
8884

@@ -109,9 +105,7 @@ application sets influence Varnish as you expect them to.
109105
}
110106

111107
This example shows how you can test whether your application purges content
112-
correctly:
113-
114-
.. code-block:: php
108+
correctly::
115109

116110
public function testCachePurge()
117111
{

doc/user-context.rst

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ Calculating the User Context Hash
5151

5252
The user context hash calculation (step 3 above) is managed by the HashGenerator.
5353
Because the calculation itself will be different per application, you need to
54-
implement at least one ContextProvider and register that with the HashGenerator.
55-
56-
.. code-block:: php
54+
implement at least one ContextProvider and register that with the HashGenerator::
5755

5856
use FOS\HttpCache\UserContext\HashGenerator;
5957

@@ -71,9 +69,7 @@ Context Providers
7169
Each provider is passed the `UserContext <../../../src/UserContext/UserContext.php>`_
7270
and updates that with parameters which influence the varied response.
7371

74-
A provider that looks at whether the user is authenticated could look like this:
75-
76-
.. code-block:: php
72+
A provider that looks at whether the user is authenticated could look like this::
7773

7874
use FOS\HttpCache\UserContext\ContextProviderInterface;
7975
use FOS\HttpCache\UserContext\UserContext;
@@ -99,9 +95,7 @@ Returning the User Context Hash
9995
-------------------------------
10096

10197
It is up to you to return the user context hash in response to the hash request
102-
(``/auth.php`` in step 3 above):
103-
104-
.. code-block:: php
98+
(``/auth.php`` in step 3 above)::
10599

106100
$hash = $hashGenerator->generateHash();
107101

@@ -147,9 +141,7 @@ The Original Request
147141

148142
After following the steps above, the following code renders a homepage
149143
differently depending on whether the user is logged in or not, using the
150-
*credentials of the particular user*:
151-
152-
.. code-block:: php
144+
*credentials of the particular user*::
153145

154146
// /index.php file
155147
header('Cache-Control: max-age=3600');

0 commit comments

Comments
 (0)