Skip to content

Commit

Permalink
Replace Python code-blocks with double colons
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Feb 23, 2023
1 parent a55c2b4 commit 742aff3
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 112 deletions.
4 changes: 1 addition & 3 deletions docs/handbook/image-file-formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1402,9 +1402,7 @@ at 72 dpi. To load it at another resolution::

To add other read or write support, use
:py:func:`PIL.WmfImagePlugin.register_handler` to register a WMF and EMF
handler.

.. code-block:: python
handler. ::

from PIL import Image
from PIL import WmfImagePlugin
Expand Down
2 changes: 1 addition & 1 deletion docs/handbook/text-anchors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ For example, in the following image, the text is ``ms`` (middle-baseline) aligne
:alt: ms (middle-baseline) aligned text.
:align: left

.. code-block:: python
::

from PIL import Image, ImageDraw, ImageFont

Expand Down
12 changes: 3 additions & 9 deletions docs/reference/Image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ Open, rotate, and display an image (using the default viewer)

The following script loads an image, rotates it 45 degrees, and displays it
using an external viewer (usually xv on Unix, and the Paint program on
Windows).

.. code-block:: python
Windows). ::

from PIL import Image
with Image.open("hopper.jpg") as im:
Expand All @@ -29,9 +27,7 @@ Create thumbnails
^^^^^^^^^^^^^^^^^

The following script creates nice thumbnails of all JPEG images in the
current directory preserving aspect ratios with 128x128 max resolution.

.. code-block:: python
current directory preserving aspect ratios with 128x128 max resolution. ::

from PIL import Image
import glob, os
Expand Down Expand Up @@ -242,9 +238,7 @@ This rotates the input image by ``theta`` degrees counter clockwise::
.. automethod:: PIL.Image.Image.transpose

This flips the input image by using the :data:`Transpose.FLIP_LEFT_RIGHT`
method.

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

from PIL import Image

Expand Down
18 changes: 6 additions & 12 deletions docs/reference/ImageDraw.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ For a more advanced drawing library for PIL, see the `aggdraw module`_.
Example: Draw a gray cross over an image
----------------------------------------

.. code-block:: python
::

import sys
from PIL import Image, ImageDraw
Expand Down Expand Up @@ -78,7 +78,7 @@ libraries, and may not available in all PIL builds.
Example: Draw Partial Opacity Text
----------------------------------

.. code-block:: python
::

from PIL import Image, ImageDraw, ImageFont

Expand All @@ -105,7 +105,7 @@ Example: Draw Partial Opacity Text
Example: Draw Multiline Text
----------------------------

.. code-block:: python
::

from PIL import Image, ImageDraw, ImageFont

Expand Down Expand Up @@ -597,18 +597,14 @@ Methods
string due to kerning. If you need to adjust for kerning, include the following
character and subtract its length.

For example, instead of

.. code-block:: python
For example, instead of ::

hello = draw.textlength("Hello", font)
world = draw.textlength("World", font)
hello_world = hello + world # not adjusted for kerning
assert hello_world == draw.textlength("HelloWorld", font) # may fail

use

.. code-block:: python
use ::

hello = draw.textlength("HelloW", font) - draw.textlength(
"W", font
Expand All @@ -617,9 +613,7 @@ Methods
hello_world = hello + world # adjusted for kerning
assert hello_world == draw.textlength("HelloWorld", font) # True

or disable kerning with (requires libraqm)

.. code-block:: python
or disable kerning with (requires libraqm) ::

hello = draw.textlength("Hello", font, features=["-kern"])
world = draw.textlength("World", font, features=["-kern"])
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ImageEnhance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ for image enhancement.
Example: Vary the sharpness of an image
---------------------------------------

.. code-block:: python
::

from PIL import ImageEnhance

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ImageFile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ and **xmllib** modules.
Example: Parse an image
-----------------------

.. code-block:: python
::

from PIL import ImageFile

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ImageFilter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ filters, which can be be used with the :py:meth:`Image.filter()
Example: Filter an image
------------------------

.. code-block:: python
::

from PIL import ImageFilter

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ImageFont.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ the imToolkit package.
Example
-------

.. code-block:: python
::

from PIL import ImageFont, ImageDraw

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ImageMath.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ an expression string and one or more images.
Example: Using the :py:mod:`~PIL.ImageMath` module
--------------------------------------------------

.. code-block:: python
::

from PIL import Image, ImageMath

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/ImageSequence.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ iterate over the frames of an image sequence.
Extracting frames from an animation
-----------------------------------

.. code-block:: python
::

from PIL import Image, ImageSequence

Expand Down
8 changes: 2 additions & 6 deletions docs/reference/PixelAccess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ Example
-------

The following script loads an image, accesses one pixel from it, then
changes it.

.. code-block:: python
changes it. ::

from PIL import Image

Expand All @@ -35,9 +33,7 @@ Results in the following::
(23, 24, 68)
(0, 0, 0)

Access using negative indexes is also possible.

.. code-block:: python
Access using negative indexes is also possible. ::

px[-1, -1] = (0, 0, 0)
print(px[-1, -1])
Expand Down
8 changes: 2 additions & 6 deletions docs/reference/PyAccess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ The :py:mod:`~PIL.PyAccess` module provides a CFFI/Python implementation of the
Example
-------

The following script loads an image, accesses one pixel from it, then changes it.

.. code-block:: python
The following script loads an image, accesses one pixel from it, then changes it. ::

from PIL import Image

Expand All @@ -34,9 +32,7 @@ Results in the following::
(23, 24, 68)
(0, 0, 0)

Access using negative indexes is also possible.

.. code-block:: python
Access using negative indexes is also possible. ::

px[-1, -1] = (0, 0, 0)
print(px[-1, -1])
Expand Down
8 changes: 2 additions & 6 deletions docs/releasenotes/6.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ Text stroking
``stroke_width`` and ``stroke_fill`` arguments have been added to text drawing
operations. They allow text to be outlined, setting the width of the stroke and
and the color respectively. If not provided, ``stroke_fill`` will default to
the ``fill`` parameter.

.. code-block:: python
the ``fill`` parameter. ::

from PIL import Image, ImageDraw, ImageFont

Expand All @@ -28,9 +26,7 @@ the ``fill`` parameter.
draw.multiline_text((10, 10), "A\nB", "#f00", font,
stroke_width=2, stroke_fill="#0f0")

For example,

.. code-block:: python
For example, ::

from PIL import Image, ImageDraw, ImageFont

Expand Down
4 changes: 1 addition & 3 deletions docs/releasenotes/7.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ Allow saving of zero quality JPEG images
If no quality was specified when saving a JPEG, Pillow internally used a value
of zero to indicate that the default quality should be used. However, this
removed the ability to actually save a JPEG with zero quality. This has now
been resolved.

.. code-block:: python
been resolved. ::

from PIL import Image
im = Image.open("hopper.jpg")
Expand Down
4 changes: 1 addition & 3 deletions docs/releasenotes/8.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ ImageDraw.rounded_rectangle
Added :py:meth:`~PIL.ImageDraw.ImageDraw.rounded_rectangle`. It works the same as
:py:meth:`~PIL.ImageDraw.ImageDraw.rectangle`, except with an additional ``radius``
argument. ``radius`` is limited to half of the width or the height, so that users can
create a circle, but not any other ellipse.

.. code-block:: python
create a circle, but not any other ellipse. ::

from PIL import Image, ImageDraw
im = Image.new("RGB", (200, 200))
Expand Down
4 changes: 1 addition & 3 deletions docs/releasenotes/8.4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ Added "transparency" argument for loading EPS images

This new argument switches the Ghostscript device from "ppmraw" to "pngalpha",
generating an RGBA image with a transparent background instead of an RGB image with a
white background.

.. code-block:: python
white background. ::

with Image.open("sample.eps") as im:
im.load(transparency=True)
Expand Down
8 changes: 2 additions & 6 deletions docs/releasenotes/9.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,13 @@ GifImagePlugin loading strategy

Pillow 9.0.0 introduced the conversion of subsequent GIF frames to ``RGB`` or ``RGBA``. This
behaviour can now be changed so that the first ``P`` frame is converted to ``RGB`` as
well.

.. code-block:: python
well. ::

from PIL import GifImagePlugin
GifImagePlugin.LOADING_STRATEGY = GifImagePlugin.LoadingStrategy.RGB_ALWAYS

Or subsequent frames can be kept in ``P`` mode as long as there is only a single
palette.

.. code-block:: python
palette. ::

from PIL import GifImagePlugin
GifImagePlugin.LOADING_STRATEGY = GifImagePlugin.LoadingStrategy.RGB_AFTER_DIFFERENT_PALETTE_ONLY
Expand Down
Loading

0 comments on commit 742aff3

Please sign in to comment.