Skip to content

Commit 46b14eb

Browse files
committed
split deprecation guide into two file according to diataxis principles
1 parent 09173ee commit 46b14eb

File tree

5 files changed

+106
-81
lines changed

5 files changed

+106
-81
lines changed

docs/backend/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ behaviors
2222
configuration-registry
2323
content-types/index
2424
control-panels
25-
deprecation
2625
fields
2726
global-utils
2827
indexing
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
myst:
3+
html_meta:
4+
"description": "Understanding deprecation in Plone - rationales, philosophy, and use cases."
5+
"property=og:description": "Understanding deprecation in Plone - rationales, philosophy, and use cases."
6+
"property=og:title": "Deprecation"
7+
"keywords": "deprecation, Plone, Python, philosophy"
8+
---
9+
10+
(conceptual-deprecation-label)=
11+
12+
# Deprecation
13+
14+
This chapter describes rationales and philosophy of deprecations in Plone, Zope, and Python.
15+
It is meant as a guide on how to think about deprecations in Plone core packages.
16+
17+
```{seealso}
18+
For implementation details and code examples, see {doc}`/developer-guide/deprecation`.
19+
```
20+
21+
22+
## Why deprecation
23+
24+
At some point we:
25+
26+
- need to get rid of old code,
27+
- want to unify API style (consistent API),
28+
- fix typos in namings,
29+
- move code or templates around (inside package or to another package).
30+
31+
While refactoring code, moving modules, functions, classes and methods is often needed.
32+
To not break third party code imports from the old place or usage of old functions/ methods must work for while.
33+
Deprecated methods are usually removed with the next major release of Plone.
34+
35+
Following the [semantic versioning guideline](https://semver.org) is recommended.
36+
37+
38+
## Help programmers, no annoyance
39+
40+
The developers should use code deprecations to support the consumers of the code.
41+
From their point of view, Plone core code is an API to them.
42+
Any change is annoying to them anyway, but they feel better if deprecation warnings are telling them what to do.
43+
44+
Deprecations must always log at level *warning* and have to answers the question:
45+
46+
**"Why is the code gone from the old place? What to do instead?"**
47+
48+
A short message is enough., i.e.:
49+
50+
- "Replaced by new API xyz, found at abc.cde".,
51+
- "Moved to xyz, because of abc.",
52+
- "Name had a typo, new name is "xyz".
53+
54+
All logging has to be done once, i.e. on first usage or first import.
55+
It must not flood the logs.
56+
57+
58+
## Use cases
59+
60+
Renaming
61+
62+
: We may want to rename classes, methods, functions or global or class variables in order to get a more consistent API or because of a typo, etc.
63+
We never just rename, we always provide a deprecated version logging a verbose deprecation warning with information where to
64+
import from in future.
65+
66+
Moving a module, class, function, etc to another place
67+
68+
: For some reason, i.e. merging packages, consistent API or resolving cirular import problems, we need to move code around.
69+
When imported from the old place it logs a verbose deprecation warning with information where to import from in future.
70+
71+
Deprecation of a whole package
72+
73+
: A whole [package](https://docs.python.org/3/tutorial/modules.html#packages)
74+
75+
- all imports still working, logging deprecation warnings on first import
76+
- ZCML still exists, but is empty (or includes the zcml from the new place if theres no auto import (i.e. for meta.zcml).
77+
78+
Deprecation of a whole released/ installable package.
79+
80+
: We will provide a last major release with no 'real' code, only backward compatible (bbb) imports of public API are provided.
81+
This will be done the way described above for a whole package.
82+
The README clearly states why it was moved and where to find the code now.
83+
84+
Deprecation of a GenericSetup profile
85+
86+
: They may got renamed for consistency or are superfluos after an update.
87+
Code does not need to break to support this.

docs/conceptual-guides/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ This part of the documentation provides explanation of concepts to deepen and br
1616
:maxdepth: 2
1717
1818
choose-user-interface
19-
compare-buildout-pip
2019
distributions
20+
compare-buildout-pip
21+
deprecation
2122
package-management
2223
package-dependencies
2324
make-backend-build

docs/backend/deprecation.md renamed to docs/developer-guide/deprecation.md

Lines changed: 16 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,24 @@
11
---
22
myst:
33
html_meta:
4-
"description": "A guide how to do deprecations, including Python, ZCML and templates in Plone."
5-
"property=og:description": "A guide how to do deprecations, including Python, ZCML and templates in Plone."
6-
"property=og:title": "Deprecation"
7-
"keywords": "deprecation, zcml, template, jbot"
4+
"description": "How to implement deprecations in Plone, including Python, ZCML and templates."
5+
"property=og:description": "How to implement deprecations in Plone, including Python, ZCML and templates."
6+
"property=og:title": "Implement deprecations"
7+
"keywords": "deprecation, zcml, template, jbot, Plone, Python"
88
---
99

10-
(backend-deprecation-label)=
11-
# Deprecation
10+
(developer-deprecation-label)=
1211

13-
## Introduction
12+
# Implement deprecations
1413

15-
This document describes rationales, configuration and best practices of deprecations in Plone, Zope and Python.
16-
It is meant as a styleguide on how to apply deprecations in Plone core packages.
17-
It also has a value as a general overview on how to deprecate in Python.
14+
This chapter describes how to enable deprecation warnings and best practices for implementing deprecations in Plone, Zope, and Python.
1815

16+
```{seealso}
17+
For background on deprecation philosophy and use cases, see {doc}`/conceptual-guides/deprecation`.
18+
```
1919

20-
### Why Deprecation
21-
22-
At some point we:
23-
24-
- need to get rid of old code,
25-
- want to unify API style (consistent API),
26-
- fix typos in namings,
27-
- move code or templates around (inside package or to another package).
28-
29-
While refactoring code, moving modules, functions, classes and methods is often needed.
30-
To not break third party code imports from the old place or usage of old functions/ methods must work for while.
31-
Deprecated methods are usually removed with the next major release of Plone.
32-
33-
Following the [semantic versioning guideline](https://semver.org) is recommended.
34-
35-
### Help Programmers, No annoyance
36-
37-
The developers should use code deprecations to support the consumers of the code.
38-
From their point of view, Plone core code is an API to them.
39-
Any change is annoying to them anyway, but they feel better if deprecation warnings are telling them what to do.
40-
41-
Deprecations must always log at level *warning* and have to answers the question:
42-
43-
**"Why is the code gone from the old place? What to do instead?"**
44-
45-
A short message is enough., i.e.:
46-
47-
- "Replaced by new API xyz, found at abc.cde".,
48-
- "Moved to xyz, because of abc.",
49-
- "Name had a typo, new name is "xyz".
50-
51-
All logging has to be done once, i.e. on first usage or first import.
52-
It must not flood the logs.
53-
54-
### Use Cases
55-
56-
Renaming
57-
58-
: We may want to rename classes, methods, functions or global or class variables in order to get a more consistent API or because of a typo, etc.
59-
We never just rename, we always provide a deprecated version logging a verbose deprecation warning with information where to
60-
import from in future.
61-
62-
Moving a module, class, function, etc to another place
63-
64-
: For some reason, i.e. merging packages, consistent API or resolving cirular import problems, we need to move code around.
65-
When imported from the old place it logs a verbose deprecation warning with information where to import from in future.
66-
67-
Deprecation of a whole package
68-
69-
: A whole [package](https://docs.python.org/3/tutorial/modules.html#packages)
70-
71-
- all imports still working, logging deprecation warnings on first import
72-
- ZCML still exists, but is empty (or includes the zcml from the new place if theres no auto import (i.e. for meta.zcml).
73-
74-
Deprecation of a whole released/ installable package.
75-
76-
: We will provide a last major release with no 'real' code, only backward compatible (bbb) imports of public API are provided.
77-
This will be done the way described above for a whole package.
78-
The README clearly states why it was moved and where to find the code now.
79-
80-
Deprecation of a GenericSetup profile
81-
82-
: They may got renamed for consistency or are superfluos after an update.
83-
Code does not need to break to support this.
8420

85-
## Enable Deprecation Warnings
21+
## Enable deprecation warnings
8622

8723
### Zope
8824

@@ -158,9 +94,10 @@ the call looks like so:
15894
./bin/python -W module ./bin/test
15995
```
16096

161-
## Deprecation Best Practice
16297

163-
### Vanilla Deprecation Messages
98+
## Deprecation best practice
99+
100+
### Vanilla deprecation messages
164101

165102
Python offers a built-in `DeprecationWarning` which can be issued using standard libraries `warnings` module.
166103

@@ -173,7 +110,7 @@ import warnings
173110
warnings.warn('deprecated', DeprecationWarning)
174111
```
175112

176-
### Moving Whole Modules
113+
### Moving whole modules
177114

178115
Given a package `old.pkg` with a module `foo.py` need to be moved to a package `new.pkg` as `bar.py`.
179116

@@ -192,7 +129,7 @@ Now you can still import the namespace from `bar` at the old place, but get a de
192129
> DeprecationWarning: old.pkg.foo has moved to new.pkg.bar.
193130
> Import of old.pkg.foo will become unsupported in Version 2.0
194131
195-
### Moving Whole Packages
132+
### Moving whole packages
196133

197134
This is the same as moving a module, just create for each module a file.
198135

docs/developer-guide/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ develop-volto-add-ons-index
2525
create-a-distribution
2626
standardize-python-project-configuration
2727
native-namespace
28+
deprecation
2829
```

0 commit comments

Comments
 (0)