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` :py:meth:`.ImageDraw2.Draw.textsize` :py:meth:`.ImageDraw2.Draw.textbbox` and :py:meth:`.ImageDraw2.Draw.textlength`
=========================================================================== ============================================================================================================= =========================================================================== =============================================================================================================
Previous code: Previous code::
.. code-block:: python
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
@ -194,9 +192,7 @@ Previous code:
width, height = font.getsize_multiline("Hello\nworld") width, height = font.getsize_multiline("Hello\nworld")
width, height = draw.multiline_textsize("Hello\nworld") width, height = draw.multiline_textsize("Hello\nworld")
Use instead: Use instead::
.. code-block:: python
from PIL import Image, ImageDraw, ImageFont 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 Use a context manager or call ``Image.close()`` instead to close the file in a
deterministic way. deterministic way.
Previous method: Previous method::
.. code-block:: python
im = Image.open("hopper.png") im = Image.open("hopper.png")
im.save("out.jpg") im.save("out.jpg")
Use instead: Use instead::
.. code-block:: python
with Image.open("hopper.png") as im: with Image.open("hopper.png") as im:
im.save("out.jpg") im.save("out.jpg")

View File

@ -1393,9 +1393,7 @@ WMF, EMF
Pillow can identify WMF and EMF files. Pillow can identify WMF and EMF files.
On Windows, it can read WMF and EMF files. By default, it will load the image 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: at 72 dpi. To load it at another resolution::
.. code-block:: python
from PIL import Image 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 :py:func:`PIL.Image.register_open`. Although not required, it is also a good
idea to register any extensions used by this format. idea to register any extensions used by this format.
Once the plugin has been imported, it can be used: Once the plugin has been imported, it can be used::
.. code-block:: python
from PIL import Image from PIL import Image
import SpamImagePlugin import SpamImagePlugin
@ -169,9 +167,7 @@ The raw decoder
The ``raw`` decoder is used to read uncompressed data from an image file. It 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 can be used with most uncompressed file formats, such as PPM, BMP, uncompressed
TIFF, and many others. To use the raw decoder with the TIFF, and many others. To use the raw decoder with the
:py:func:`PIL.Image.frombytes` function, use the following syntax: :py:func:`PIL.Image.frombytes` function, use the following syntax::
.. code-block:: python
image = Image.frombytes( image = Image.frombytes(
mode, size, data, "raw", mode, size, data, "raw",
@ -281,9 +277,7 @@ decoder that can be used to read various packed formats into a floating point
image memory. image memory.
To use the bit decoder with the :py:func:`PIL.Image.frombytes` function, use To use the bit decoder with the :py:func:`PIL.Image.frombytes` function, use
the following syntax: the following syntax::
.. code-block:: python
image = Image.frombytes( image = Image.frombytes(
mode, size, data, "bit", 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 .. automethod:: PIL.Image.Image.convert
The following example converts an RGB image (linearly calibrated according to The following example converts an RGB image (linearly calibrated according to
ITU-R 709, using the D65 luminant) to the CIE XYZ color space: ITU-R 709, using the D65 luminant) to the CIE XYZ color space::
.. code-block:: python
rgb2xyz = ( rgb2xyz = (
0.412453, 0.357580, 0.180423, 0, 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.copy
.. automethod:: PIL.Image.Image.crop .. automethod:: PIL.Image.Image.crop
This crops the input image with the provided coordinates: This crops the input image with the provided coordinates::
.. code-block:: python
from PIL import Image 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.entropy
.. automethod:: PIL.Image.Image.filter .. automethod:: PIL.Image.Image.filter
This blurs the input image using a filter from the ``ImageFilter`` module: This blurs the input image using a filter from the ``ImageFilter`` module::
.. code-block:: python
from PIL import Image, ImageFilter 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.frombytes
.. automethod:: PIL.Image.Image.getbands .. automethod:: PIL.Image.Image.getbands
This helps to get the bands of the input image: This helps to get the bands of the input image::
.. code-block:: python
from PIL import Image from PIL import Image
@ -187,9 +179,7 @@ This helps to get the bands of the input image:
.. automethod:: PIL.Image.Image.getbbox .. automethod:: PIL.Image.Image.getbbox
This helps to get the bounding box coordinates of the input image: This helps to get the bounding box coordinates of the input image::
.. code-block:: python
from PIL import 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.remap_palette
.. automethod:: PIL.Image.Image.resize .. automethod:: PIL.Image.Image.resize
This resizes the given image from ``(width, height)`` to ``(width/2, height/2)``: This resizes the given image from ``(width, height)`` to ``(width/2, height/2)``::
.. code-block:: python
from PIL import Image 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 .. automethod:: PIL.Image.Image.rotate
This rotates the input image by ``theta`` degrees counter clockwise: This rotates the input image by ``theta`` degrees counter clockwise::
.. code-block:: python
from PIL import Image 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) .. py:method:: PIL.ImagePath.Path.transform(matrix)
Transforms the path in place, using an affine transform. The matrix is a 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: 6-tuple (a, b, c, d, e, f), and each point is mapped as follows::
.. code-block:: python
xOut = xIn * a + yIn * b + c xOut = xIn * a + yIn * b + c
yOut = xIn * d + yIn * e + f 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 ImageWin can be used with PythonWin and other user interface toolkits that
provide access to Windows device contexts or window handles. For example, provide access to Windows device contexts or window handles. For example,
Tkinter makes the window handle available via the winfo_id method: Tkinter makes the window handle available via the winfo_id method::
.. code-block:: python
from PIL import ImageWin from PIL import ImageWin

View File

@ -61,9 +61,7 @@ Image Lifecycle
* ``Image.Image.close()`` Closes the file and destroys the core image object. * ``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 Pillow context manager will also close the file, but will not destroy
the core image object. e.g.: the core image object. e.g.::
.. code-block:: python
with Image.open("test.jpg") as img: with Image.open("test.jpg") as img:
img.load() 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 Use a context manager or call ``Image.close()`` instead to close the file in a
deterministic way. deterministic way.
Deprecated: Deprecated::
.. code-block:: python
im = Image.open("hopper.png") im = Image.open("hopper.png")
im.save("out.jpg") im.save("out.jpg")
Use instead: Use instead::
.. code-block:: python
with Image.open("hopper.png") as im: with Image.open("hopper.png") as im:
im.save("out.jpg") 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 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 value from 0 (worst) to 100 (best) controls the image quality, similar to the JPEG
encoder. The default is 75. For example: encoder. The default is 75. For example::
.. code-block:: python
im.save("out.tif", compression="jpeg", quality=85) 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 On Windows, Pillow can read WMF files, with a default DPI of 72. An image can
now also be loaded at another resolution: now also be loaded at another resolution::
.. code-block:: python
from PIL import Image from PIL import Image
with Image.open("drawing.wmf") as im: 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 Use a context manager or call :py:meth:`~PIL.Image.Image.close` instead to close
the file in a deterministic way. the file in a deterministic way.
Previous method: Previous method::
.. code-block:: python
im = Image.open("hopper.png") im = Image.open("hopper.png")
im.save("out.jpg") im.save("out.jpg")
Use instead: Use instead::
.. code-block:: python
with Image.open("hopper.png") as im: with Image.open("hopper.png") as im:
im.save("out.jpg") im.save("out.jpg")

View File

@ -155,9 +155,7 @@ altered slightly with this change.
Added support for pickling TrueType fonts Added support for pickling TrueType fonts
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TrueType fonts may now be pickled and unpickled. For example: TrueType fonts may now be pickled and unpickled. For example::
.. code-block:: python
import pickle import pickle
from PIL import ImageFont 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` :py:meth:`.ImageDraw2.Draw.textsize` :py:meth:`.ImageDraw2.Draw.textbbox` and :py:meth:`.ImageDraw2.Draw.textlength`
=========================================================================== ============================================================================================================= =========================================================================== =============================================================================================================
Previous code: Previous code::
.. code-block:: python
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
@ -76,9 +74,7 @@ Previous code:
width, height = font.getsize_multiline("Hello\nworld") width, height = font.getsize_multiline("Hello\nworld")
width, height = draw.multiline_textsize("Hello\nworld") width, height = draw.multiline_textsize("Hello\nworld")
Use instead: Use instead::
.. code-block:: python
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont

View File

@ -96,9 +96,7 @@ directory.
Example Example
------- -------
The following is a simplified version of the script used on AppVeyor: The following is a simplified version of the script used on AppVeyor::
.. code-block::
set PYTHON=C:\Python38\bin set PYTHON=C:\Python38\bin
cd /D C:\Pillow\winbuild cd /D C:\Pillow\winbuild