Skip to content

Commit

Permalink
If following colon, replace Python code-blocks with double colons
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Feb 18, 2023
1 parent d48dca3 commit a55c2b4
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 84 deletions.
16 changes: 4 additions & 12 deletions docs/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ Deprecated Use
:py:meth:`.ImageDraw2.Draw.textsize` :py:meth:`.ImageDraw2.Draw.textbbox` and :py:meth:`.ImageDraw2.Draw.textlength`
=========================================================================== =============================================================================================================

Previous code:

.. code-block:: python
Previous code::

from PIL import Image, ImageDraw, ImageFont

Expand All @@ -194,9 +192,7 @@ Previous code:
width, height = font.getsize_multiline("Hello\nworld")
width, height = draw.multiline_textsize("Hello\nworld")

Use instead:

.. code-block:: python
Use instead::

from PIL import Image, ImageDraw, ImageFont

Expand Down Expand Up @@ -336,16 +332,12 @@ Implicitly closing the image's underlying file in ``Image.__del__`` has been rem
Use a context manager or call ``Image.close()`` instead to close the file in a
deterministic way.

Previous method:

.. code-block:: python
Previous method::

im = Image.open("hopper.png")
im.save("out.jpg")

Use instead:

.. code-block:: python
Use instead::

with Image.open("hopper.png") as im:
im.save("out.jpg")
Expand Down
4 changes: 1 addition & 3 deletions docs/handbook/image-file-formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1393,9 +1393,7 @@ WMF, EMF
Pillow can identify WMF and EMF files.

On Windows, it can read WMF and EMF files. By default, it will load the image
at 72 dpi. To load it at another resolution:

.. code-block:: python
at 72 dpi. To load it at another resolution::

from PIL import Image

Expand Down
12 changes: 3 additions & 9 deletions docs/handbook/writing-your-own-image-plugin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ Note that the image plugin must be explicitly registered using
:py:func:`PIL.Image.register_open`. Although not required, it is also a good
idea to register any extensions used by this format.

Once the plugin has been imported, it can be used:

.. code-block:: python
Once the plugin has been imported, it can be used::

from PIL import Image
import SpamImagePlugin
Expand Down Expand Up @@ -169,9 +167,7 @@ The raw decoder
The ``raw`` decoder is used to read uncompressed data from an image file. It
can be used with most uncompressed file formats, such as PPM, BMP, uncompressed
TIFF, and many others. To use the raw decoder with the
:py:func:`PIL.Image.frombytes` function, use the following syntax:

.. code-block:: python
:py:func:`PIL.Image.frombytes` function, use the following syntax::

image = Image.frombytes(
mode, size, data, "raw",
Expand Down Expand Up @@ -281,9 +277,7 @@ decoder that can be used to read various packed formats into a floating point
image memory.

To use the bit decoder with the :py:func:`PIL.Image.frombytes` function, use
the following syntax:

.. code-block:: python
the following syntax::

image = Image.frombytes(
mode, size, data, "bit",
Expand Down
28 changes: 7 additions & 21 deletions docs/reference/Image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ methods. Unless otherwise stated, all methods return a new instance of the
.. automethod:: PIL.Image.Image.convert

The following example converts an RGB image (linearly calibrated according to
ITU-R 709, using the D65 luminant) to the CIE XYZ color space:

.. code-block:: python
ITU-R 709, using the D65 luminant) to the CIE XYZ color space::

rgb2xyz = (
0.412453, 0.357580, 0.180423, 0,
Expand All @@ -140,9 +138,7 @@ ITU-R 709, using the D65 luminant) to the CIE XYZ color space:
.. automethod:: PIL.Image.Image.copy
.. automethod:: PIL.Image.Image.crop

This crops the input image with the provided coordinates:

.. code-block:: python
This crops the input image with the provided coordinates::

from PIL import Image

Expand All @@ -162,9 +158,7 @@ This crops the input image with the provided coordinates:
.. automethod:: PIL.Image.Image.entropy
.. automethod:: PIL.Image.Image.filter

This blurs the input image using a filter from the ``ImageFilter`` module:

.. code-block:: python
This blurs the input image using a filter from the ``ImageFilter`` module::

from PIL import Image, ImageFilter

Expand All @@ -176,9 +170,7 @@ This blurs the input image using a filter from the ``ImageFilter`` module:
.. automethod:: PIL.Image.Image.frombytes
.. automethod:: PIL.Image.Image.getbands

This helps to get the bands of the input image:

.. code-block:: python
This helps to get the bands of the input image::

from PIL import Image

Expand All @@ -187,9 +179,7 @@ This helps to get the bands of the input image:

.. automethod:: PIL.Image.Image.getbbox

This helps to get the bounding box coordinates of the input image:

.. code-block:: python
This helps to get the bounding box coordinates of the input image::

from PIL import Image

Expand Down Expand Up @@ -217,9 +207,7 @@ This helps to get the bounding box coordinates of the input image:
.. automethod:: PIL.Image.Image.remap_palette
.. automethod:: PIL.Image.Image.resize

This resizes the given image from ``(width, height)`` to ``(width/2, height/2)``:

.. code-block:: python
This resizes the given image from ``(width, height)`` to ``(width/2, height/2)``::

from PIL import Image

Expand All @@ -231,9 +219,7 @@ This resizes the given image from ``(width, height)`` to ``(width/2, height/2)``

.. automethod:: PIL.Image.Image.rotate

This rotates the input image by ``theta`` degrees counter clockwise:

.. code-block:: python
This rotates the input image by ``theta`` degrees counter clockwise::

from PIL import Image

Expand Down
4 changes: 1 addition & 3 deletions docs/reference/ImagePath.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ vector data. Path objects can be passed to the methods on the
.. py:method:: PIL.ImagePath.Path.transform(matrix)
Transforms the path in place, using an affine transform. The matrix is a
6-tuple (a, b, c, d, e, f), and each point is mapped as follows:

.. code-block:: python
6-tuple (a, b, c, d, e, f), and each point is mapped as follows::

xOut = xIn * a + yIn * b + c
yOut = xIn * d + yIn * e + f
4 changes: 1 addition & 3 deletions docs/reference/ImageWin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ Windows.

ImageWin can be used with PythonWin and other user interface toolkits that
provide access to Windows device contexts or window handles. For example,
Tkinter makes the window handle available via the winfo_id method:

.. code-block:: python
Tkinter makes the window handle available via the winfo_id method::

from PIL import ImageWin

Expand Down
4 changes: 1 addition & 3 deletions docs/reference/open_files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ Image Lifecycle
* ``Image.Image.close()`` Closes the file and destroys the core image object.

The Pillow context manager will also close the file, but will not destroy
the core image object. e.g.:

.. code-block:: python
the core image object. e.g.::

with Image.open("test.jpg") as img:
img.load()
Expand Down
12 changes: 3 additions & 9 deletions docs/releasenotes/6.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@ Implicitly closing the image's underlying file in ``Image.__del__`` has been dep
Use a context manager or call ``Image.close()`` instead to close the file in a
deterministic way.

Deprecated:

.. code-block:: python
Deprecated::

im = Image.open("hopper.png")
im.save("out.jpg")

Use instead:

.. code-block:: python
Use instead::

with Image.open("hopper.png") as im:
im.save("out.jpg")
Expand Down Expand Up @@ -79,9 +75,7 @@ Image quality for JPEG compressed TIFF

The TIFF encoder accepts a ``quality`` parameter for ``jpeg`` compressed TIFF files. A
value from 0 (worst) to 100 (best) controls the image quality, similar to the JPEG
encoder. The default is 75. For example:

.. code-block:: python
encoder. The default is 75. For example::

im.save("out.tif", compression="jpeg", quality=85)

Expand Down
12 changes: 3 additions & 9 deletions docs/releasenotes/7.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ Loading WMF images at a given DPI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

On Windows, Pillow can read WMF files, with a default DPI of 72. An image can
now also be loaded at another resolution:

.. code-block:: python
now also be loaded at another resolution::

from PIL import Image
with Image.open("drawing.wmf") as im:
Expand All @@ -136,16 +134,12 @@ Implicitly closing the image's underlying file in ``Image.__del__`` has been rem
Use a context manager or call :py:meth:`~PIL.Image.Image.close` instead to close
the file in a deterministic way.

Previous method:

.. code-block:: python
Previous method::

im = Image.open("hopper.png")
im.save("out.jpg")

Use instead:

.. code-block:: python
Use instead::

with Image.open("hopper.png") as im:
im.save("out.jpg")
Expand Down
4 changes: 1 addition & 3 deletions docs/releasenotes/9.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ altered slightly with this change.
Added support for pickling TrueType fonts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

TrueType fonts may now be pickled and unpickled. For example:

.. code-block:: python
TrueType fonts may now be pickled and unpickled. For example::

import pickle
from PIL import ImageFont
Expand Down
8 changes: 2 additions & 6 deletions docs/releasenotes/9.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ Deprecated Use
:py:meth:`.ImageDraw2.Draw.textsize` :py:meth:`.ImageDraw2.Draw.textbbox` and :py:meth:`.ImageDraw2.Draw.textlength`
=========================================================================== =============================================================================================================

Previous code:

.. code-block:: python
Previous code::

from PIL import Image, ImageDraw, ImageFont

Expand All @@ -76,9 +74,7 @@ Previous code:
width, height = font.getsize_multiline("Hello\nworld")
width, height = draw.multiline_textsize("Hello\nworld")

Use instead:

.. code-block:: python
Use instead::

from PIL import Image, ImageDraw, ImageFont

Expand Down
4 changes: 1 addition & 3 deletions winbuild/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ directory.
Example
-------

The following is a simplified version of the script used on AppVeyor:

.. code-block::
The following is a simplified version of the script used on AppVeyor::

set PYTHON=C:\Python38\bin
cd /D C:\Pillow\winbuild
Expand Down

0 comments on commit a55c2b4

Please sign in to comment.