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

Skip to content

Commit eb0bfb5

Browse files
hugovkAlexWaygood
andauthored
[3.12] Docs: add link roles with Sphinx extlinks (GH-117850) (#117910)
Co-authored-by: Alex Waygood <[email protected]>
1 parent 6dfb7e1 commit eb0bfb5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+134
-161
lines changed

Doc/c-api/init.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ Process-wide parameters
760760
It is recommended that applications embedding the Python interpreter
761761
for purposes other than executing a single script pass ``0`` as *updatepath*,
762762
and update :data:`sys.path` themselves if desired.
763-
See `CVE-2008-5983 <https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_.
763+
See :cve:`2008-5983`.
764764

765765
On versions before 3.1.3, you can achieve the same effect by manually
766766
popping the first :data:`sys.path` element after having called

Doc/conf.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
sys.path.append(os.path.abspath('tools/extensions'))
1313
sys.path.append(os.path.abspath('includes'))
1414

15+
from pyspecific import SOURCE_URI
16+
1517
# General configuration
1618
# ---------------------
1719

@@ -24,6 +26,7 @@
2426
'pyspecific',
2527
'sphinx.ext.coverage',
2628
'sphinx.ext.doctest',
29+
'sphinx.ext.extlinks',
2730
]
2831

2932
# Skip if downstream redistributors haven't installed it
@@ -499,6 +502,19 @@
499502
r'https://unix.org/version2/whatsnew/lp64_wp.html',
500503
]
501504

505+
# Options for sphinx.ext.extlinks
506+
# -------------------------------
507+
508+
# This config is a dictionary of external sites,
509+
# mapping unique short aliases to a base URL and a prefix.
510+
# https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
511+
extlinks = {
512+
"cve": ("https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s", "CVE-%s"),
513+
"cwe": ("https://cwe.mitre.org/data/definitions/%s.html", "CWE-%s"),
514+
"pypi": ("https://pypi.org/project/%s/", "%s"),
515+
"source": (SOURCE_URI, "%s"),
516+
}
517+
extlinks_detect_hardcoded_links = True
502518

503519
# Options for extensions
504520
# ----------------------

Doc/faq/library.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,16 +610,15 @@ use ``p.read(n)``.
610610
("ptys") instead of pipes. Or you can use a Python interface to Don Libes'
611611
"expect" library. A Python extension that interfaces to expect is called
612612
"expy" and available from https://expectpy.sourceforge.net. A pure Python
613-
solution that works like expect is `pexpect
614-
<https://pypi.org/project/pexpect/>`_.
613+
solution that works like expect is :pypi:`pexpect`.
615614
616615
617616
How do I access the serial (RS232) port?
618617
----------------------------------------
619618
620619
For Win32, OSX, Linux, BSD, Jython, IronPython:
621620
622-
https://pypi.org/project/pyserial/
621+
:pypi:`pyserial`
623622
624623
For Unix, see a Usenet post by Mitch Chapman:
625624

Doc/howto/curses.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ appearance---and the curses library will figure out what control codes
4343
need to be sent to the terminal to produce the right output. curses
4444
doesn't provide many user-interface concepts such as buttons, checkboxes,
4545
or dialogs; if you need such features, consider a user interface library such as
46-
`Urwid <https://pypi.org/project/urwid/>`_.
46+
:pypi:`Urwid`.
4747

4848
The curses library was originally written for BSD Unix; the later System V
4949
versions of Unix from AT&T added many enhancements and new functions. BSD curses
@@ -56,8 +56,7 @@ versions of curses carried by some proprietary Unixes may not support
5656
everything, though.
5757

5858
The Windows version of Python doesn't include the :mod:`curses`
59-
module. A ported version called `UniCurses
60-
<https://pypi.org/project/UniCurses>`_ is available.
59+
module. A ported version called :pypi:`UniCurses` is available.
6160

6261

6362
The Python curses module
@@ -429,8 +428,7 @@ User Input
429428

430429
The C curses library offers only very simple input mechanisms. Python's
431430
:mod:`curses` module adds a basic text-input widget. (Other libraries
432-
such as `Urwid <https://pypi.org/project/urwid/>`_ have more extensive
433-
collections of widgets.)
431+
such as :pypi:`Urwid` have more extensive collections of widgets.)
434432

435433
There are two methods for getting input from a window:
436434

Doc/howto/logging-cookbook.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,7 +1912,7 @@ Subclassing QueueHandler and QueueListener- a ``pynng`` example
19121912
---------------------------------------------------------------
19131913

19141914
In a similar way to the above section, we can implement a listener and handler
1915-
using `pynng <https://pypi.org/project/pynng/>`_, which is a Python binding to
1915+
using :pypi:`pynng`, which is a Python binding to
19161916
`NNG <https://nng.nanomsg.org/>`_, billed as a spiritual successor to ZeroMQ.
19171917
The following snippets illustrate -- you can test them in an environment which has
19181918
``pynng`` installed. Just for variety, we present the listener first.
@@ -3575,9 +3575,8 @@ A Qt GUI for logging
35753575

35763576
A question that comes up from time to time is about how to log to a GUI
35773577
application. The `Qt <https://www.qt.io/>`_ framework is a popular
3578-
cross-platform UI framework with Python bindings using `PySide2
3579-
<https://pypi.org/project/PySide2/>`_ or `PyQt5
3580-
<https://pypi.org/project/PyQt5/>`_ libraries.
3578+
cross-platform UI framework with Python bindings using :pypi:`PySide2`
3579+
or :pypi:`PyQt5` libraries.
35813580

35823581
The following example shows how to log to a Qt GUI. This introduces a simple
35833582
``QtHandler`` class which takes a callable, which should be a slot in the main

Doc/library/cgi.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
The :class:`FieldStorage` class can typically be replaced with
2323
:func:`urllib.parse.parse_qsl` for ``GET`` and ``HEAD`` requests,
2424
and the :mod:`email.message` module or
25-
`multipart <https://pypi.org/project/multipart/>`_ for ``POST`` and ``PUT``.
25+
:pypi:`multipart` for ``POST`` and ``PUT``.
2626
Most :ref:`utility functions <functions-in-cgi-module>` have replacements.
2727

2828
--------------
@@ -334,7 +334,7 @@ algorithms implemented in this module in other circumstances.
334334
It can be replaced with the functionality in the :mod:`email` package
335335
(e.g. :class:`email.message.EmailMessage`/:class:`email.message.Message`)
336336
which implements the same MIME RFCs, or with the
337-
`multipart <https://pypi.org/project/multipart/>`__ PyPI project.
337+
:pypi:`multipart` PyPI project.
338338

339339

340340
.. function:: parse_header(string)

Doc/library/codecs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ Internationalized Domain Names (IDN)). It builds upon the ``punycode`` encoding
14791479
and :mod:`stringprep`.
14801480

14811481
If you need the IDNA 2008 standard from :rfc:`5891` and :rfc:`5895`, use the
1482-
third-party `idna module <https://pypi.org/project/idna/>`_.
1482+
third-party :pypi:`idna` module.
14831483

14841484
These RFCs together define a protocol to support non-ASCII characters in domain
14851485
names. A domain name containing non-ASCII characters (such as

Doc/library/crypt.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
The :mod:`crypt` module is deprecated
2121
(see :pep:`PEP 594 <594#crypt>` for details and alternatives).
2222
The :mod:`hashlib` module is a potential replacement for certain use cases.
23-
The `passlib <https://pypi.org/project/passlib/>`_ package can replace all use cases of this module.
23+
The :pypi:`passlib` package can replace all use cases of this module.
2424

2525
--------------
2626

Doc/library/datetime.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ on efficient attribute extraction for output formatting and manipulation.
3737
Package `dateutil <https://dateutil.readthedocs.io/en/stable/>`_
3838
Third-party library with expanded time zone and parsing support.
3939

40-
Package `DateType <https://pypi.org/project/datetype/>`_
40+
Package :pypi:`DateType`
4141
Third-party library that introduces distinct static types to e.g. allow
4242
:term:`static type checkers <static type checker>`
4343
to differentiate between naive and aware datetimes.

Doc/library/importlib.metadata.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ this package can eliminate the need to use the older and less efficient
2626

2727
``importlib.metadata`` operates on third-party *distribution packages*
2828
installed into Python's ``site-packages`` directory via tools such as
29-
`pip <https://pypi.org/project/pip/>`_.
29+
:pypi:`pip`.
3030
Specifically, it works with distributions with discoverable
3131
``dist-info`` or ``egg-info`` directories,
3232
and metadata defined by the `Core metadata specifications <https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata>`_.
@@ -178,7 +178,7 @@ The "selectable" entry points were introduced in ``importlib_metadata``
178178
no parameters and always returned a dictionary of entry points, keyed
179179
by group. With ``importlib_metadata`` 5.0 and Python 3.12,
180180
``entry_points`` always returns an ``EntryPoints`` object. See
181-
`backports.entry_points_selectable <https://pypi.org/project/backports.entry-points-selectable>`_
181+
:pypi:`backports.entry_points_selectable`
182182
for compatibility options.
183183

184184

0 commit comments

Comments
 (0)