Skip to content

Commit 0b91fc8

Browse files
woodruffwAA-Turner
andauthored
PEP 753: Add suggested human-readable labels (#3974)
Signed-off-by: William Woodruff <[email protected]> Co-authored-by: Adam Turner <[email protected]>
1 parent c1310b7 commit 0b91fc8

File tree

1 file changed

+68
-39
lines changed

1 file changed

+68
-39
lines changed

peps/pep-0753.rst

Lines changed: 68 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -153,85 +153,114 @@ informal relationship between ``Home-page``, ``Download-URL``, and their
153153

154154
This formalization has two parts:
155155

156-
1. A set of rules for canonicalizing ``Project-URL`` labels;
157-
2. A set of "well-known" canonical label values that indices may specialize
156+
1. A set of rules for normalizing ``Project-URL`` labels;
157+
2. A set of "well-known" normalized label values that indices may specialize
158158
URL presentation for.
159159

160-
Label canonicalization
161-
----------------------
160+
Label normalization
161+
-------------------
162162

163163
The core metadata specification stipulates that ``Project-URL`` labels are
164164
free text, limited to 32 characters.
165165

166-
This PEP proposes adding the concept of a "canonicalized" label to the core
167-
metadata specification. Label canonicalization is defined via the following
166+
This PEP proposes adding the concept of a "normalized" label to the core
167+
metadata specification. Label normalization is defined via the following
168168
Python function:
169169

170170
.. code-block:: python
171171
172172
import string
173-
def canonicalize_label(label: str) -> str:
173+
def normalize_label(label: str) -> str:
174174
chars_to_remove = string.punctuation + string.whitespace
175175
removal_map = str.maketrans("", "", chars_to_remove)
176176
return label.translate(removal_map).lower()
177177
178-
In plain language: a label is *canonicalized* by deleting all ASCII punctuation and
178+
In plain language: a label is *normalized* by deleting all ASCII punctuation and
179179
whitespace, and then converting the result to lowercase.
180180

181181
The following table shows examples of labels before (raw) and after
182-
canonicalization:
182+
normalization:
183183

184184
.. csv-table::
185-
:header: "Raw", "Canonicalized"
185+
:header: "Raw", "Normalized"
186186

187187
"``Homepage``", "``homepage``"
188188
"``Home-page``", "``homepage``"
189189
"``Home page``", "``homepage``"
190190
"``Change_Log``", "``changelog``"
191191
"``What's New?``", "``whatsnew``"
192192

193-
Metadata producers **SHOULD** emit the canonicalized form of a user
194-
specified label, but **MAY** choose to emit the un-canonicalized form so
193+
Metadata producers **SHOULD** emit the normalized form of a user
194+
specified label, but **MAY** choose to emit the un-normalized form so
195195
long as it adheres to the existing 32 character constraint.
196196

197-
Package indices **SHOULD NOT** use the canonicalized labels belonging to the set
197+
Package indices **SHOULD NOT** use the normalized labels belonging to the set
198198
of well-known labels directly as UI elements (instead replacing them with
199199
appropriately capitalized text labels). Labels not belonging to the well-known
200200
set **MAY** be used directly as UI elements.
201201

202202
Well-known labels
203203
-----------------
204204

205-
In addition to the canonicalization rules above, this PEP proposes a
205+
In addition to the normalization rules above, this PEP proposes a
206206
fixed (but extensible) set of "well-known" ``Project-URL`` labels,
207-
as well as equivalent aliases.
208-
209-
The following table lists these labels, in canonical form:
210-
211-
.. csv-table::
212-
:header: "Label", "Description", "Aliases"
213-
:widths: 20, 50, 30
214-
215-
"``homepage``", "The project's home page", "*(none)*"
216-
"``download``", "A download URL for the current distribution, equivalent to ``Download-URL``", "*(none)*"
217-
"``changelog``", "The project's changelog", "``changes``, ``releasenotes``, ``whatsnew``, ``history``"
218-
"``documentation``", "The project's online documentation", "``docs``"
219-
"``issues``", "The project's bug tracker", "``bugs``, ``issue``, ``bug``, ``tracker``, ``report``"
220-
"``sponsor``", "Sponsoring information", "``funding``, ``donate``, ``donation``"
207+
as well as aliases and human-readable equivalents.
208+
209+
The following table lists these labels, in normalized form:
210+
211+
.. list-table::
212+
:header-rows: 1
213+
214+
* - Label (Human-readable equivalent)
215+
- Description
216+
- Aliases
217+
* - ``homepage`` (Homepage)
218+
- The project's home page
219+
- *(none)*
220+
* - ``source`` (Source Code)
221+
- The project's hosted source code or repository
222+
- ``repository``, ``sourcecode``, ``github``
223+
* - ``download`` (Download)
224+
- A download URL for the current distribution, equivalent to ``Download-URL``
225+
- *(none)*
226+
* - ``changelog`` (Changelog)
227+
- The project's comprehensive changelog
228+
- ``changes``, ``whatsnew``, ``history``
229+
* - ``releasenotes`` (Release Notes)
230+
- The project's curated release notes
231+
- *(none)*
232+
* - ``documentation`` (Documentation)
233+
- The project's online documentation
234+
- ``docs``
235+
* - ``issues`` (Issue Tracker)
236+
- The project's bug tracker
237+
- ``bugs``, ``issue``, ``tracker``, ``issuetracker``, ``bugtracker``
238+
* - ``funding`` (Funding)
239+
- Funding Information
240+
- ``sponsor``, ``donate``, ``donation``
241+
242+
Indices **MAY** choose to use the human-readable equivalents suggested above
243+
in their UI elements, if appropriate. Alternatively, indices **MAY** choose
244+
their own appropriate human-readable equivalents for UI elements.
221245

222246
Packagers and metadata producers **MAY** choose to use these well-known
223-
labels to communicate specific URL intents to package indices and downstreams.
247+
labels or their aliases to communicate specific URL intents to package indices
248+
and downstreams.
224249

225-
Packagers and metadata producers **SHOULD** produce the canonicalized version
226-
of the well-known labels in package metadata.
250+
Packagers and metadata producers **SHOULD** produce the normalized version
251+
of the well-known labels or their aliases in package metadata. Packaging tools
252+
**MUST NOT** transform between equivalent aliases, i.e.. **SHOULD**
253+
normalize ``GitHub`` to ``github`` but **MUST NOT** transform
254+
``github`` to ``source``.
227255

228256
Similarly, indices **MAY** choose to specialize their rendering or presentation
229257
of URLs with these labels, e.g. by presenting an appropriate icon or tooltip
230258
for each label.
231259

232-
Indices **MAY** also specialize the rendering or presentation of additional labels or URLs,
233-
including (but not limited to), labels that start with a well-known label, and URLs that refer
234-
to a known service provider domain (e.g. for documentation hosting or issue tracking).
260+
Indices **MAY** also specialize the rendering or presentation of additional
261+
labels or URLs, including (but not limited to), labels that start with a
262+
well-known label, and URLs that refer to a known service provider domain (e.g.
263+
for documentation hosting or issue tracking).
235264

236265
This PEP recognizes that the list of well-known labels is unlikely to remain
237266
static, and that subsequent additions to it should not require the overhead
@@ -275,11 +304,11 @@ the core metadata standards:
275304
next major core metadata version. If removed, package indices and consumers
276305
**MUST** reject metadata containing these fields when said metadata is of
277306
the new major version.
278-
* Enforcement of label canonicalization. If enforced, package producers
279-
**MUST** emit only canonicalized ``Project-URL`` labels when generating
307+
* Enforcement of label normalization. If enforced, package producers
308+
**MUST** emit only normalized ``Project-URL`` labels when generating
280309
distribution metadata, and package indices and consumers **MUST** reject
281-
distributions containing non-canonicalized labels. Note: requiring
282-
canonicalization merely restricts labels to lowercase text, and excludes
310+
distributions containing non-normalized labels. Note: requiring
311+
normalization merely restricts labels to lowercase text, and excludes
283312
whitespace and punctuation. It does NOT restrict project URLs solely to
284313
the use of "well-known" labels.
285314

@@ -292,7 +321,7 @@ Security Implications
292321

293322
This PEP does not identify any positive or negative security implications
294323
associated with deprecating ``Home-page`` and ``Download-URL`` or with
295-
label canonicalization.
324+
label normalization.
296325

297326
How To Teach This
298327
=================

0 commit comments

Comments
 (0)