Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 78c898b

Browse files
committed
rstcheck config and precommit & fixed rst linting errors
1 parent 221f6c2 commit 78c898b

27 files changed

+198
-84
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ repos:
2626
- id: no-commit-to-branch #default is master and main
2727
- id: trailing-whitespace
2828
exclude_types: [svg]
29-
3029
- repo: https://github.com/pycqa/flake8
3130
rev: 6.0.0
3231
hooks:
@@ -44,10 +43,15 @@ repos:
4443
"--skip",
4544
"doc/users/project/credits.rst"
4645
]
47-
4846
- repo: https://github.com/pycqa/isort
4947
rev: 5.12.0
5048
hooks:
5149
- id: isort
5250
name: isort (python)
5351
files: ^galleries/tutorials/|^galleries/examples/|^galleries/plot_types/
52+
- repo: https://github.com/rstcheck/rstcheck
53+
rev: v6.2.0
54+
hooks:
55+
- id: rstcheck
56+
additional_dependencies:
57+
- sphinx>=1.8.1

doc/_templates/autofunctions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ Functions
1414
.. autosummary::
1515
:template: autosummary.rst
1616
:toctree:
17+
1718
{% for item in functions %}{% if item not in ['plotting', 'colormaps'] %}
1819
{{ item }}{% endif %}{% endfor %}
20+
1921
{% endif %}
2022
{% endblock %}

doc/_templates/automodule.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{{ fullname | escape | underline}}
22

33
{% if fullname in ['mpl_toolkits.axes_grid1.colorbar'] %}
4-
.. To prevent problems with the autosummary for the colorbar doc
5-
treat this separately (sphinx-doc/sphinx/issues/4874)
4+
5+
.. To prevent problems with the autosummary for the colorbar doc treat this
6+
separately (sphinx-doc/sphinx/issues/4874)
7+
68
.. automodule:: {{ fullname }}
79
:members:
810

@@ -21,8 +23,10 @@ Classes
2123
.. autosummary::
2224
:template: autosummary.rst
2325
:toctree:
26+
2427
{% for item in classes %}{% if item not in ['zip', 'map', 'reduce'] %}
2528
{{ item }}{% endif %}{% endfor %}
29+
2630
{% endif %}
2731
{% endblock %}
2832

@@ -38,6 +42,7 @@ Functions
3842

3943
{% for item in functions %}{% if item not in ['zip', 'map', 'reduce'] %}
4044
{{ item }}{% endif %}{% endfor %}
45+
4146
{% endif %}
4247
{% endblock %}
4348
{% endif %}

doc/_templates/autosummary.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
{% if objtype in ['class'] %}
8+
89
.. auto{{ objtype }}:: {{ objname }}
910
:show-inheritance:
1011
:special-members: __call__
@@ -16,11 +17,13 @@
1617

1718
{% if objtype in ['class', 'method', 'function'] %}
1819
{% if objname in ['AxesGrid', 'Scalable', 'HostAxes', 'FloatingAxes',
19-
'ParasiteAxesAuxTrans', 'ParasiteAxes'] %}
20+
'ParasiteAxesAuxTrans', 'ParasiteAxes'] %}
21+
2022
.. Filter out the above aliases to other classes, as sphinx gallery
2123
creates no example file for those (sphinx-gallery/sphinx-gallery#365)
2224
2325
{% else %}
26+
2427
.. minigallery:: {{module}}.{{objname}}
2528
:add-heading:
2629

doc/_templates/autosummary_class_only.rst

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

66

77
{% if objtype in ['class'] %}
8+
89
.. auto{{ objtype }}:: {{ objname }}
910
:no-members:
1011

doc/api/next_api_changes/behavior/25775-HZ.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Default antialiasing behavior changes for ``Text`` and ``Annotation``
44
``matplotlib.pyplot.annotate()`` and ``matplotlib.pyplot.text()`` now support parameter *antialiased* when initializing.
55
Examples:
66

7-
.. code-block::
7+
.. code-block:: python
88
99
mpl.text.Text(.5, .5, "foo\nbar", antialiased=True)
1010
plt.text(0.5, 0.5, '6 inches x 2 inches', antialiased=True)

doc/api/prev_api_changes/api_changes_2.1.2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ didn't handle linewidths or linestyles etc.
1313

1414
This logic did not exist in `.axes.Axes.legend`. It was included (erroneously)
1515
in Matplotlib 2.1.1 when the legend argument parsing was unified
16-
[#9324](https://github.com/matplotlib/matplotlib/pull/9324). This change
16+
`#9324 <https://github.com/matplotlib/matplotlib/pull/9324>`_. This change
1717
removes that check in `.axes.Axes.legend` again to restore the old behavior.
1818

1919
This logic has also been dropped from `.Figure.legend`, where it

doc/api/prev_api_changes/api_changes_3.5.0/behaviour.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ consistently exposes all the attributes and methods related to the line marker
132132
(:ghissue:`11358`). This makes it easy to change the marker features after
133133
instantiating a legend.
134134

135-
.. code::
135+
.. code-block:: python
136136
137137
import matplotlib.pyplot as plt
138138
@@ -147,7 +147,7 @@ instantiating a legend.
147147
The former legend handler for Line2D objects has been renamed
148148
`.HandlerLine2DCompound`. To revert to the previous behaviour, one can use
149149

150-
.. code::
150+
.. code-block:: python
151151
152152
import matplotlib.legend as mlegend
153153
from matplotlib.legend_handler import HandlerLine2DCompound

doc/api/prev_api_changes/api_changes_3.7.0/behaviour.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Now, the halfrange remains fixed when vcenter is changed, and **vmin** and
5151

5252
For example, this is what the values were when changing vcenter previously.
5353

54-
.. code-block::
54+
.. code-block:: python
5555
5656
norm = CenteredNorm(vcenter=0, halfrange=1)
5757
# Move vcenter up by one
@@ -61,7 +61,7 @@ For example, this is what the values were when changing vcenter previously.
6161
6262
and now, with that same example
6363

64-
.. code-block::
64+
.. code-block:: python
6565
6666
norm = CenteredNorm(vcenter=0, halfrange=1)
6767
norm.vcenter = 1

doc/devel/MEP/MEP23.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ most use cases.
3535

3636
Sometimes when there are too many figures open at the same time, it is
3737
desirable to be able to group these under the same window
38-
[see](https://github.com/matplotlib/matplotlib/issues/2194).
38+
`see <https://github.com/matplotlib/matplotlib/issues/2194>`_.
3939

4040
The proposed solution modifies `.FigureManagerBase` to contain and manage more
4141
than one ``Canvas``. The settings parameter :rc:`backend.multifigure` control
@@ -44,7 +44,7 @@ when the **MultiFigure** behaviour is desired.
4444
**Note**
4545

4646
It is important to note, that the proposed solution, assumes that the
47-
[MEP22](https://github.com/matplotlib/matplotlib/wiki/Mep22) is
47+
`MEP22 <https://github.com/matplotlib/matplotlib/wiki/Mep22>`_. is
4848
already in place. This is simply because the actual implementation of
4949
the ``Toolbar`` makes it pretty hard to switch between canvases.
5050

doc/devel/MEP/MEP28.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ value of ``statfxn`` would be ``cbook.boxplot_stats``, but users could
264264
pass their own function. Then ``transform_in`` and ``transform_out`` would
265265
then be passed as elements of the ``statfxn_args`` parameter.
266266

267-
.. code:: python
267+
.. code:: none
268268
269269
def boxplot_stats(data, ..., transform_in=None, transform_out=None):
270270
if transform_in is None:

doc/devel/contribute.rst

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,18 @@ also welcome to post feature requests or pull requests.
170170

171171
If you are reporting a bug, please do your best to include the following:
172172

173-
1. A short, top-level summary of the bug. In most cases, this should be 1-2
173+
#. A short, top-level summary of the bug. In most cases, this should be 1-2
174174
sentences.
175175

176-
2. A short, self-contained code snippet to reproduce the bug, ideally allowing
176+
#. A short, self-contained code snippet to reproduce the bug, ideally allowing
177177
a simple copy and paste to reproduce. Please do your best to reduce the code
178178
snippet to the minimum required.
179179

180-
3. The actual outcome of the code snippet.
180+
#. The actual outcome of the code snippet.
181181

182-
4. The expected outcome of the code snippet.
182+
#. The expected outcome of the code snippet.
183183

184-
5. The Matplotlib version, Python version and platform that you are using. You
184+
#. The Matplotlib version, Python version and platform that you are using. You
185185
can grab the version with the following commands::
186186

187187
>>> import matplotlib
@@ -229,52 +229,52 @@ contribute to Matplotlib.
229229

230230
A brief overview of the workflow is as follows.
231231

232-
1. `Create an account <https://github.com/join>`_ on GitHub if you do not
232+
#. `Create an account <https://github.com/join>`_ on GitHub if you do not
233233
already have one.
234234

235-
2. Fork the `project repository <https://github.com/matplotlib/matplotlib>`_:
235+
#. Fork the `project repository <https://github.com/matplotlib/matplotlib>`_:
236236
click on the 'Fork' button near the top of the page. This creates a copy of
237237
the code under your account on the GitHub server.
238238

239+
#. Set up a development environment:
240+
239241
.. tab-set::
240242

241243
.. tab-item:: Local development
242244

243-
3. Clone this copy to your local disk::
245+
Clone this copy to your local disk::
244246

245-
git clone https://github.com/<YOUR GITHUB USERNAME>/matplotlib.git
247+
git clone https://github.com/<YOUR GITHUB USERNAME>/matplotlib.git
246248

247249
.. tab-item:: Using GitHub Codespaces
248250

249-
3. Check out the Matplotlib repository and activate your development
250-
environment:
251-
252-
* Open codespaces on your fork by clicking on the green "Code" button
253-
on the GitHub web interface and selecting the "Codespaces" tab.
254-
* Next, click on "Open codespaces on <your branch name>". You will be
255-
able to change branches later, so you can select the default
256-
``main`` branch.
257-
* After the codespace is created, you will be taken to a new browser
258-
tab where you can use the terminal to activate a pre-defined conda
259-
environment called ``mpl-dev``::
260-
261-
conda activate mpl-dev
251+
Check out the Matplotlib repository and activate your development
252+
environment:
262253

254+
* Open codespaces on your fork by clicking on the green "Code" button
255+
on the GitHub web interface and selecting the "Codespaces" tab.
256+
* Next, click on "Open codespaces on <your branch name>". You will be
257+
able to change branches later, so you can select the default
258+
``main`` branch.
259+
* After the codespace is created, you will be taken to a new browser
260+
tab where you can use the terminal to activate a pre-defined conda
261+
environment called ``mpl-dev``::
263262

263+
conda activate mpl-dev
264264

265-
4. Install the local version of Matplotlib with::
265+
#. Install the local version of Matplotlib with::
266266

267267
python -m pip install -e .
268268

269269
See :ref:`installing_for_devs` for detailed instructions.
270270

271-
5. Create a branch to hold your changes::
271+
#. Create a branch to hold your changes::
272272

273273
git checkout -b my-feature origin/main
274274

275275
and start making changes. Never work in the ``main`` branch!
276276

277-
6. Work on this task using Git to do the version control. Codespaces persist for
277+
#. Work on this task using Git to do the version control. Codespaces persist for
278278
some time (check the `documentation for details
279279
<https://docs.github.com/codespaces/getting-started/the-codespace-lifecycle>`_)
280280
and can be managed on https://github.com/codespaces. When you're done editing
@@ -301,11 +301,11 @@ GitHub Codespaces workflows
301301
<https://github.com/devcontainers/features/tree/main/src/desktop-lite>`_.
302302
You can use it by connecting to this desktop via your web browser. To do this:
303303

304-
1. Press ``F1`` or ``Ctrl/Cmd+Shift+P`` and select
304+
#. Press ``F1`` or ``Ctrl/Cmd+Shift+P`` and select
305305
``Ports: Focus on Ports View`` in the VSCode session to bring it into
306306
focus. Open the ports view in your tool, select the ``noVNC`` port, and
307307
click the Globe icon.
308-
2. In the browser that appears, click the Connect button and enter the desktop
308+
#. In the browser that appears, click the Connect button and enter the desktop
309309
password (``vscode`` by default).
310310

311311
Check the `GitHub instructions
@@ -391,10 +391,11 @@ Rules
391391
Introducing
392392
~~~~~~~~~~~
393393

394-
1. Announce the deprecation in a new file
394+
#. Announce the deprecation in a new file
395395
:file:`doc/api/next_api_changes/deprecations/99999-ABC.rst` where ``99999``
396396
is the pull request number and ``ABC`` are the contributor's initials.
397-
2. If possible, issue a `~matplotlib.MatplotlibDeprecationWarning` when the
397+
398+
#. If possible, issue a `~matplotlib.MatplotlibDeprecationWarning` when the
398399
deprecated API is used. There are a number of helper tools for this:
399400

400401
- Use ``_api.warn_deprecated()`` for general deprecation warnings
@@ -411,7 +412,7 @@ Introducing
411412

412413
You can use standard rst cross references in *alternative*.
413414

414-
3. Make appropriate changes to the type hints in the associated ``.pyi`` file.
415+
#. Make appropriate changes to the type hints in the associated ``.pyi`` file.
415416
The general guideline is to match runtime reported behavior.
416417

417418
- Items marked with ``@_api.deprecated`` or ``@_api.deprecate_privatize_attribute``
@@ -431,15 +432,17 @@ Introducing
431432
Expiring
432433
~~~~~~~~
433434

434-
1. Announce the API changes in a new file
435+
#. Announce the API changes in a new file
435436
:file:`doc/api/next_api_changes/[kind]/99999-ABC.rst` where ``99999``
436437
is the pull request number and ``ABC`` are the contributor's initials, and
437438
``[kind]`` is one of the folders :file:`behavior`, :file:`development`,
438439
:file:`removals`. See :file:`doc/api/next_api_changes/README.rst` for more
439440
information. For the content, you can usually copy the deprecation notice
440441
and adapt it slightly.
441-
2. Change the code functionality and remove any related deprecation warnings.
442-
3. Make appropriate changes to the type hints in the associated ``.pyi`` file.
442+
443+
#. Change the code functionality and remove any related deprecation warnings.
444+
445+
#. Make appropriate changes to the type hints in the associated ``.pyi`` file.
443446

444447
- Items marked with ``@_api.deprecated`` or ``@_api.deprecate_privatize_attribute``
445448
are to be removed on expiry.

doc/devel/document.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ in that case, they can be documented as an ``.. ACCEPTS:`` block, e.g. for
668668

669669
.. code-block:: python
670670
671-
def set_xlim(self, ...):
671+
def set_xlim(self, left, right):
672672
"""
673673
Set the x-axis view limits.
674674

doc/users/next_whats_new/antialiasing_text_annotation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ When *antialiased* is set to ``False``, antialiasing will not be applied to the
66
When *antialiased* is not specified, antialiasing will be set by :rc:`text.antialiased` at the creation time of ``Text`` and ``Annotation`` object.
77
Examples:
88

9-
.. code-block::
9+
.. code-block:: python
1010
1111
mpl.text.Text(.5, .5, "foo\nbar", antialiased=True)
1212
plt.text(0.5, 0.5, '6 inches x 2 inches', antialiased=True)
@@ -15,7 +15,7 @@ Examples:
1515
If the text contains math expression, *antialiased* applies to the whole text.
1616
Examples:
1717

18-
.. code-block::
18+
.. code-block:: python
1919
2020
# no part will be antialiased for the text below
2121
plt.text(0.5, 0.25, r"$I'm \sqrt{x}$", antialiased=False)

doc/users/next_whats_new/boldsym_mathtext.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Supports using the ``\boldsymbol{}`` command in mathtext:
66
To change symbols to bold enclose the text in a font command as
77
shown:
88

9-
.. code-block::
9+
.. code-block:: none
1010
1111
r'$\boldsymbol{a+2+\alpha}$'
1212

doc/users/next_whats_new/mathtext_features.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
To use it to enclose the math in a substack command as shown:
77

8-
.. code-block::
8+
.. code-block:: none
99
1010
r'$\sum_{\substack{1\leq i\leq 3\\ 1\leq j\leq 5}}$'
1111
@@ -23,7 +23,7 @@ The ``\middle`` delimiter has been added, and can now be used with the
2323
To use the middle command enclose it in between the ``\left`` and
2424
``\right`` delimiter command as shown:
2525

26-
.. code-block::
26+
.. code-block:: none
2727
2828
r'$\left( \frac{a}{b} \middle| q \right)$'
2929

doc/users/next_whats_new/updated_mathtext.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Supports use of bold-italic font style in mathtext using the ``\mathbfit{}`` com
66
To change font to bold and italic enclose the text in a font command as
77
shown:
88

9-
.. code-block::
9+
.. code-block:: none
1010
11-
r'$\mathbfit{\eta \leq C(\delta(\eta))}$
11+
r'$\mathbfit{\eta \leq C(\delta(\eta))}$'
1212
1313
.. math::
1414
\mathbfit{\eta \leq C(\delta(\eta))}

0 commit comments

Comments
 (0)