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

Skip to content

Commit cbd0408

Browse files
hoeflingjaraco
authored andcommitted
links in importlib.metadata.rst replaced with sphinx references (GH-17730)
The importlib.metadata documentation uses hardcoded links to internal pages. This results in minor rendering issues. This change replaces the hardcoded links with suitable Sphinx roles. Signed-off-by: Oleg Höfling <[email protected]>
1 parent 6c7bb38 commit cbd0408

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

Doc/library/importlib.metadata.rst

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.. _using:
22

3-
==========================
4-
Using importlib.metadata
5-
==========================
3+
=================================
4+
Using :mod:`!importlib.metadata`
5+
=================================
66

77
.. note::
88
This functionality is provisional and may deviate from the usual
@@ -12,18 +12,18 @@
1212
package metadata. Built in part on Python's import system, this library
1313
intends to replace similar functionality in the `entry point
1414
API`_ and `metadata API`_ of ``pkg_resources``. Along with
15-
``importlib.resources`` in `Python 3.7
16-
and newer`_ (backported as `importlib_resources`_ for older versions of
15+
:mod:`importlib.resources` in Python 3.7
16+
and newer (backported as `importlib_resources`_ for older versions of
1717
Python), this can eliminate the need to use the older and less efficient
1818
``pkg_resources`` package.
1919

2020
By "installed package" we generally mean a third-party package installed into
2121
Python's ``site-packages`` directory via tools such as `pip
2222
<https://pypi.org/project/pip/>`_. Specifically,
2323
it means a package with either a discoverable ``dist-info`` or ``egg-info``
24-
directory, and metadata defined by `PEP 566`_ or its older specifications.
24+
directory, and metadata defined by :pep:`566` or its older specifications.
2525
By default, package metadata can live on the file system or in zip archives on
26-
``sys.path``. Through an extension mechanism, the metadata can live almost
26+
:data:`sys.path`. Through an extension mechanism, the metadata can live almost
2727
anywhere.
2828

2929

@@ -134,7 +134,7 @@ Distribution files
134134
You can also get the full set of files contained within a distribution. The
135135
``files()`` function takes a distribution package name and returns all of the
136136
files installed by this distribution. Each file object returned is a
137-
``PackagePath``, a `pathlib.Path`_ derived object with additional ``dist``,
137+
``PackagePath``, a :class:`pathlib.Path` derived object with additional ``dist``,
138138
``size``, and ``hash`` properties as indicated by the metadata. For example::
139139

140140
>>> util = [p for p in files('wheel') if 'util.py' in str(p)][0] # doctest: +SKIP
@@ -203,18 +203,18 @@ instance::
203203
>>> d.metadata['License'] # doctest: +SKIP
204204
'MIT'
205205

206-
The full set of available metadata is not described here. See `PEP 566
207-
<https://www.python.org/dev/peps/pep-0566/>`_ for additional details.
206+
The full set of available metadata is not described here. See :pep:`566`
207+
for additional details.
208208

209209

210210
Extending the search algorithm
211211
==============================
212212

213-
Because package metadata is not available through ``sys.path`` searches, or
213+
Because package metadata is not available through :data:`sys.path` searches, or
214214
package loaders directly, the metadata for a package is found through import
215-
system `finders`_. To find a distribution package's metadata,
216-
``importlib.metadata`` queries the list of `meta path finders`_ on
217-
`sys.meta_path`_.
215+
system :ref:`finders <finders-and-loaders>`. To find a distribution package's metadata,
216+
``importlib.metadata`` queries the list of :term:`meta path finders <meta path finder>` on
217+
:data:`sys.meta_path`.
218218

219219
The default ``PathFinder`` for Python includes a hook that calls into
220220
``importlib.metadata.MetadataPathFinder`` for finding distributions
@@ -224,7 +224,7 @@ The abstract class :py:class:`importlib.abc.MetaPathFinder` defines the
224224
interface expected of finders by Python's import system.
225225
``importlib.metadata`` extends this protocol by looking for an optional
226226
``find_distributions`` callable on the finders from
227-
``sys.meta_path`` and presents this extended interface as the
227+
:data:`sys.meta_path` and presents this extended interface as the
228228
``DistributionFinder`` abstract base class, which defines this abstract
229229
method::
230230

@@ -247,20 +247,13 @@ a custom finder, return instances of this derived ``Distribution`` in the
247247

248248
.. _`entry point API`: https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points
249249
.. _`metadata API`: https://setuptools.readthedocs.io/en/latest/pkg_resources.html#metadata-api
250-
.. _`Python 3.7 and newer`: https://docs.python.org/3/library/importlib.html#module-importlib.resources
251250
.. _`importlib_resources`: https://importlib-resources.readthedocs.io/en/latest/index.html
252-
.. _`PEP 566`: https://www.python.org/dev/peps/pep-0566/
253-
.. _`finders`: https://docs.python.org/3/reference/import.html#finders-and-loaders
254-
.. _`meta path finders`: https://docs.python.org/3/glossary.html#term-meta-path-finder
255-
.. _`sys.meta_path`: https://docs.python.org/3/library/sys.html#sys.meta_path
256-
.. _`pathlib.Path`: https://docs.python.org/3/library/pathlib.html#pathlib.Path
257251

258252

259253
.. rubric:: Footnotes
260254

261255
.. [#f1] Technically, the returned distribution metadata object is an
262-
`email.message.Message
263-
<https://docs.python.org/3/library/email.message.html#email.message.EmailMessage>`_
256+
:class:`email.message.EmailMessage`
264257
instance, but this is an implementation detail, and not part of the
265258
stable API. You should only use dictionary-like methods and syntax
266259
to access the metadata contents.

Doc/reference/import.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ named module, the two module objects will *not* be the same. By contrast,
202202
reinitialise the module contents by rerunning the module's code.
203203

204204

205+
.. _finders-and-loaders:
206+
205207
Finders and loaders
206208
-------------------
207209

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ Ludwig Hähne
751751
Gerhard Häring
752752
Fredrik Håård
753753
Florian Höch
754+
Oleg Höfling
754755
Robert Hölzl
755756
Catalin Iacob
756757
Mihai Ibanescu

0 commit comments

Comments
 (0)