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

Skip to content

Commit 9b8c660

Browse files
committed
update api_changes and coding guide to make api more prominant and attempt redirect
1 parent cd8281b commit 9b8c660

File tree

2 files changed

+92
-86
lines changed

2 files changed

+92
-86
lines changed

doc/devel/api_changes.rst

Lines changed: 86 additions & 80 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,10 +17,12 @@ are backwards-incompatible API changes.
1717

1818
color_changes.rst
1919

20+
.. redirect-from:: /devel/coding_guide#new-features-and-api-changes
21+
2022
.. _api_whats_new:
2123

22-
Announce changes, deprecations, and new features
23-
------------------------------------------------
24+
Announce new features, API changes, and deprecations
25+
----------------------------------------------------
2426

2527
When adding or changing the API in a backward in-compatible way, please add the
2628
appropriate :ref:`versioning directive <versioning-directives>` and document it
@@ -34,10 +36,9 @@ for the release notes and add the entry to the appropriate folder:
3436
| API change | ``.. versionchanged:: 3.N`` | :file:`doc/api/next_api_changes/[kind]` |
3537
+-------------------+-----------------------------+----------------------------------------------+
3638

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.
39+
API deprecations are first introduced and then expired. During the introduction period,
40+
users are warned that the API *will* change in the future. During the expiration period,
41+
code *is* changed as described in the notice posted during the introductory period.
4142

4243
+-----------+--------------------------------------------------+----------------------------------------------+
4344
| stage | required changes | announcement folder |
@@ -47,27 +48,95 @@ during the introductory period.
4748
| expire | :ref:`expire deprecation <expire-deprecation>` | :file:`doc/api/next_api_changes/[kind]` |
4849
+-----------+--------------------------------------------------+----------------------------------------------+
4950

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.
51+
.. _versioning-directives:
52+
53+
Versioning directives
54+
^^^^^^^^^^^^^^^^^^^^^
55+
56+
When making a backward incompatible change, please add a versioning directive in
57+
the docstring. The directives should be placed at the end of a description block.
58+
For example::
59+
60+
class Foo:
61+
"""
62+
This is the summary.
63+
64+
Followed by a longer description block.
65+
66+
Consisting of multiple lines and paragraphs.
67+
68+
.. versionadded:: 3.5
69+
70+
Parameters
71+
----------
72+
a : int
73+
The first parameter.
74+
b: bool, default: False
75+
This was added later.
76+
77+
.. versionadded:: 3.6
78+
"""
79+
80+
def set_b(b):
81+
"""
82+
Set b.
83+
84+
.. versionadded:: 3.6
85+
86+
Parameters
87+
----------
88+
b: bool
89+
90+
For classes and functions, the directive should be placed before the
91+
*Parameters* section. For parameters, the directive should be placed at the
92+
end of the parameter description. The patch release version is omitted and
93+
the directive should not be added to entire modules.
94+
95+
Release notes
96+
^^^^^^^^^^^^^
5397

54-
API Change Notes
55-
^^^^^^^^^^^^^^^^
98+
For both change notes and what's new, please avoid using references in section titles,
99+
as it causes links to be confusing in the table of contents. Instead, ensure that a
100+
reference is included in the descriptive text.
101+
102+
API change notes
103+
""""""""""""""""
56104

57105
.. include:: ../api/next_api_changes/README.rst
58106
:start-line: 5
59107
:end-line: 31
60108

61-
What's new
62-
^^^^^^^^^^
109+
What's new notes
110+
""""""""""""""""
63111

64112
.. include:: ../users/next_whats_new/README.rst
65113
:start-line: 5
66114
:end-line: 24
67115

68116

69-
Deprecation
70-
-----------
117+
Add new API and features
118+
------------------------
119+
120+
Every new function, parameter and attribute that is not explicitly marked as
121+
private (i.e., starts with an underscore) becomes part of Matplotlib's public
122+
API. As discussed above, changing the existing API is cumbersome. Therefore,
123+
take particular care when adding new API:
124+
125+
- Mark helper functions and internal attributes as private by prefixing them
126+
with an underscore.
127+
- Carefully think about good names for your functions and variables.
128+
- Try to adopt patterns and naming conventions from existing parts of the
129+
Matplotlib API.
130+
- Consider making as many arguments keyword-only as possible. See also
131+
`API Evolution the Right Way -- Add Parameters Compatibly`__.
132+
133+
__ https://emptysqua.re/blog/api-evolution-the-right-way/#adding-parameters
134+
135+
136+
.. _deprecation-guidelines:
137+
138+
Deprecate API
139+
-------------
71140

72141
API changes in Matplotlib have to be performed following the deprecation process
73142
below, except in very rare circumstances as deemed necessary by the development
@@ -146,66 +215,3 @@ Expire deprecation
146215
items were never type hinted in the first place and were added to this file
147216
instead. For removed items that were not in the stub file, only deleting from the
148217
allowlist is required.
149-
150-
Adding new API and features
151-
---------------------------
152-
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:
157-
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`__.
165-
166-
__ https://emptysqua.re/blog/api-evolution-the-right-way/#adding-parameters
167-
168-
169-
.. _versioning-directives:
170-
171-
Versioning directives
172-
---------------------
173-
174-
When making a backward incompatible change, please add a versioning directive in
175-
the docstring. The directives should be placed at the end of a description block.
176-
For example::
177-
178-
class Foo:
179-
"""
180-
This is the summary.
181-
182-
Followed by a longer description block.
183-
184-
Consisting of multiple lines and paragraphs.
185-
186-
.. versionadded:: 3.5
187-
188-
Parameters
189-
----------
190-
a : int
191-
The first parameter.
192-
b: bool, default: False
193-
This was added later.
194-
195-
.. versionadded:: 3.6
196-
"""
197-
198-
def set_b(b):
199-
"""
200-
Set b.
201-
202-
.. versionadded:: 3.6
203-
204-
Parameters
205-
----------
206-
b: bool
207-
208-
For classes and functions, the directive should be placed before the
209-
*Parameters* section. For parameters, the directive should be placed at the
210-
end of the parameter description. The patch release version is omitted and
211-
the directive should not be added to entire modules.

doc/devel/coding_guide.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
Coding guidelines
55
*****************
66

7+
.. admonition:: API guidelines
8+
:class: seealso, sidebar
9+
10+
If adding new features or otherwise changing API, see :ref:`api_changes`
11+
12+
713
We appreciate these guidelines being followed because it improves the readability,
814
consistency, and maintainability of the code base.
915

10-
API changes
11-
===========
12-
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.
1616

1717
PEP8, as enforced by flake8
1818
===========================

0 commit comments

Comments
 (0)