If following colon, replace Python code-blocks with double colons

This commit is contained in:
Andrew Murray 2023-02-18 20:34:52 +11:00
parent d48dca3dc4
commit a55c2b42b9
12 changed files with 28 additions and 84 deletions

View File

@ -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
@ -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
@ -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")

View File

@ -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

View File

@ -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
@ -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",
@ -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",

View File

@ -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,
@ -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
@ -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
@ -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
@ -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
@ -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
@ -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

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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")
@ -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)

View File

@ -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:
@ -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")

View File

@ -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

View File

@ -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
@ -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

View File

@ -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