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

Skip to content

Commit 690aaf3

Browse files
authored
Merge pull request #27650 from story645/api-guidelines
DOC: Added call out to API guidelines to contribute + small API guidelines reorg
2 parents ed41aea + d0dcd9e commit 690aaf3

File tree

2 files changed

+87
-70
lines changed

2 files changed

+87
-70
lines changed

doc/devel/api_changes.rst

Lines changed: 83 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _api_changes:
22

3-
API changes
4-
===========
3+
API guidelines
4+
==============
55

66
API consistency and stability are of great value; Therefore, API changes
77
(e.g. signature changes, behavior changes, removals) will only be conducted
@@ -17,67 +17,45 @@ are backwards-incompatible API changes.
1717

1818
color_changes.rst
1919

20-
.. _api_whats_new:
21-
22-
Announce changes, deprecations, and new features
23-
------------------------------------------------
2420

25-
When adding or changing the API in a backward in-compatible way, please add the
26-
appropriate :ref:`versioning directive <versioning-directives>` and document it
27-
for the release notes and add the entry to the appropriate folder:
21+
Add new API and features
22+
------------------------
2823

29-
+-------------------+-----------------------------+----------------------------------------------+
30-
| addition | versioning directive | announcement folder |
31-
+===================+=============================+==============================================+
32-
| new feature | ``.. versionadded:: 3.N`` | :file:`doc/users/next_whats_new/` |
33-
+-------------------+-----------------------------+----------------------------------------------+
34-
| API change | ``.. versionchanged:: 3.N`` | :file:`doc/api/next_api_changes/[kind]` |
35-
+-------------------+-----------------------------+----------------------------------------------+
36-
37-
API deprecations are first introduced and then expired. During the introduction
38-
period, users are warned that the API *will* change in the future.
39-
During the expiration period, code is changed as described in the notice posted
40-
during the introductory period.
41-
42-
+-----------+--------------------------------------------------+----------------------------------------------+
43-
| stage | required changes | announcement folder |
44-
+===========+==================================================+==============================================+
45-
| introduce | :ref:`introduce deprecation <intro-deprecation>` | :file:`doc/api/next_api_changes/deprecation` |
46-
+-----------+--------------------------------------------------+----------------------------------------------+
47-
| expire | :ref:`expire deprecation <expire-deprecation>` | :file:`doc/api/next_api_changes/[kind]` |
48-
+-----------+--------------------------------------------------+----------------------------------------------+
49-
50-
For both change notes and what's new, please avoid using references in section
51-
titles, as it causes links to be confusing in the table of contents. Instead,
52-
ensure that a reference is included in the descriptive text.
53-
54-
API Change Notes
55-
^^^^^^^^^^^^^^^^
24+
Every new function, parameter and attribute that is not explicitly marked as
25+
private (i.e., starts with an underscore) becomes part of Matplotlib's public
26+
API. As discussed above, changing the existing API is cumbersome. Therefore,
27+
take particular care when adding new API:
5628

57-
.. include:: ../api/next_api_changes/README.rst
58-
:start-line: 5
59-
:end-line: 31
29+
- Mark helper functions and internal attributes as private by prefixing them
30+
with an underscore.
31+
- Carefully think about good names for your functions and variables.
32+
- Try to adopt patterns and naming conventions from existing parts of the
33+
Matplotlib API.
34+
- Consider making as many arguments keyword-only as possible. See also
35+
`API Evolution the Right Way -- Add Parameters Compatibly`__.
6036

61-
What's new
62-
^^^^^^^^^^
37+
__ https://emptysqua.re/blog/api-evolution-the-right-way/#adding-parameters
6338

64-
.. include:: ../users/next_whats_new/README.rst
65-
:start-line: 5
66-
:end-line: 24
6739

40+
.. _deprecation-guidelines:
6841

69-
Deprecation
70-
-----------
42+
Deprecate API
43+
-------------
7144

7245
API changes in Matplotlib have to be performed following the deprecation process
7346
below, except in very rare circumstances as deemed necessary by the development
74-
team. This ensures that users are notified before the change will take effect
75-
and thus prevents unexpected breaking of code.
47+
team. Generally API deprecation happens in two stages:
48+
49+
* **introduce:** warn users that the API *will* change
50+
* **expire:** API *is* changed as described in the introduction period
51+
52+
This ensures that users are notified before the change will take effect and thus
53+
prevents unexpected breaking of code.
7654

7755
Rules
7856
^^^^^
79-
- Deprecations are targeted at the next point.release (e.g. 3.x)
80-
- Deprecated API is generally removed two point-releases after introduction
57+
- Deprecations are targeted at the next :ref:`minor release <pr-milestones>` (e.g. 3.x)
58+
- Deprecated API is generally removed (expired) two point-releases after introduction
8159
of the deprecation. Longer deprecations can be imposed by core developers on
8260
a case-by-case basis to give more time for the transition
8361
- The old API must remain fully functional during the deprecation period
@@ -147,29 +125,44 @@ Expire deprecation
147125
instead. For removed items that were not in the stub file, only deleting from the
148126
allowlist is required.
149127

150-
Adding new API and features
151-
---------------------------
152128

153-
Every new function, parameter and attribute that is not explicitly marked as
154-
private (i.e., starts with an underscore) becomes part of Matplotlib's public
155-
API. As discussed above, changing the existing API is cumbersome. Therefore,
156-
take particular care when adding new API:
129+
.. redirect-from:: /devel/coding_guide#new-features-and-api-changes
157130

158-
- Mark helper functions and internal attributes as private by prefixing them
159-
with an underscore.
160-
- Carefully think about good names for your functions and variables.
161-
- Try to adopt patterns and naming conventions from existing parts of the
162-
Matplotlib API.
163-
- Consider making as many arguments keyword-only as possible. See also
164-
`API Evolution the Right Way -- Add Parameters Compatibly`__.
131+
.. _api_whats_new:
165132

166-
__ https://emptysqua.re/blog/api-evolution-the-right-way/#adding-parameters
133+
Announce new and deprecated API
134+
-------------------------------
135+
136+
When adding or changing the API in a backward in-compatible way, please add the
137+
appropriate :ref:`versioning directive <versioning-directives>` and document it
138+
for the release notes and add the entry to the appropriate folder:
139+
140+
+-------------------+-----------------------------+----------------------------------------------+
141+
| | versioning directive | announcement folder |
142+
+===================+=============================+==============================================+
143+
| new feature | ``.. versionadded:: 3.N`` | :file:`doc/users/next_whats_new/` |
144+
+-------------------+-----------------------------+----------------------------------------------+
145+
| API change | ``.. versionchanged:: 3.N`` | :file:`doc/api/next_api_changes/[kind]` |
146+
+-------------------+-----------------------------+----------------------------------------------+
147+
148+
When deprecating API, please add a notice as described in the
149+
:ref:`deprecation guidelines <deprecation-guidelines>` and summarized here:
167150

151+
+--------------------------------------------------+----------------------------------------------+
152+
| stage | announcement folder |
153+
+===========+======================================+==============================================+
154+
| :ref:`introduce deprecation <intro-deprecation>` | :file:`doc/api/next_api_changes/deprecation` |
155+
+-----------+--------------------------------------+----------------------------------------------+
156+
| :ref:`expire deprecation <expire-deprecation>` | :file:`doc/api/next_api_changes/[kind]` |
157+
+-----------+--------------------------------------+----------------------------------------------+
158+
159+
Generally the introduction notices can be repurposed for the expiration notice as they
160+
are expected to be describing the same API changes and removals.
168161

169162
.. _versioning-directives:
170163

171164
Versioning directives
172-
---------------------
165+
^^^^^^^^^^^^^^^^^^^^^
173166

174167
When making a backward incompatible change, please add a versioning directive in
175168
the docstring. The directives should be placed at the end of a description block.
@@ -209,3 +202,28 @@ For classes and functions, the directive should be placed before the
209202
*Parameters* section. For parameters, the directive should be placed at the
210203
end of the parameter description. The patch release version is omitted and
211204
the directive should not be added to entire modules.
205+
206+
Release notes
207+
^^^^^^^^^^^^^
208+
209+
For both change notes and what's new, please avoid using cross-references in section
210+
titles as it causes links to be confusing in the table of contents. Instead, ensure that
211+
a cross-reference is included in the descriptive text.
212+
213+
.. _api-change-notes:
214+
215+
API change notes
216+
""""""""""""""""
217+
218+
.. include:: ../api/next_api_changes/README.rst
219+
:start-line: 5
220+
:end-line: 31
221+
222+
.. _whats-new-notes:
223+
224+
What's new notes
225+
""""""""""""""""
226+
227+
.. include:: ../users/next_whats_new/README.rst
228+
:start-line: 5
229+
:end-line: 24

doc/devel/coding_guide.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ Coding guidelines
77
We appreciate these guidelines being followed because it improves the readability,
88
consistency, and maintainability of the code base.
99

10-
API changes
11-
===========
10+
.. admonition:: API guidelines
11+
:class: seealso
1212

13-
If you are adding new features, changing behavior or function signatures, or
14-
removing classes, functions, methods, or properties, please see the :ref:`api_changes`
15-
guide.
13+
If adding new features, changing behavior or function signatures, or removing
14+
public interfaces, please consult the :ref:`api_changes`.
1615

1716
PEP8, as enforced by flake8
1817
===========================

0 commit comments

Comments
 (0)