Skip to content

Commit c6068b3

Browse files
committed
Improve external docs with intersphinx extension
* Downloads the inventories for Python and Pydantic * Use the correct :ref: syntax ("INVENTORY_NAME:OBJECT")
1 parent 9a98394 commit c6068b3

11 files changed

+39
-32
lines changed

changelog.d/432.trivial.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improve external doc links to Python and Pydantic.
2+

docs/advanced/combine-pydantic-and-semver.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ To work with Pydantic>2.0, use the following steps:
5858
ManifestVersion = Annotated[Version, _VersionPydanticAnnotation]
5959
6060
2. Create a new model (in this example :class:`MyModel`) and derive
61-
it from :class:`pydantic.BaseModel`:
61+
it from :py:class:`pydantic:pydantic.BaseModel`:
6262

6363
.. code-block:: python
6464
@@ -76,4 +76,4 @@ To work with Pydantic>2.0, use the following steps:
7676
The attribute :py:attr:`model.version` will be an instance of
7777
:class:`~semver.version.Version`.
7878
If the version is invalid, the construction will raise a
79-
:py:exc:`pydantic.ValidationError`.
79+
:py:class:`pydantic:pydantic_core.ValidationError`.

docs/changelog-semver3-devel.rst

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ Improved Documentation
132132
:class:`~semver.version.Version` class
133133
* Remove semver. prefix in doctests to make examples shorter
134134
* Correct some references to dunder methods like
135-
:func:`~.semver.version.Version.__getitem__`,
136-
:func:`~.semver.version.Version.__gt__` etc.
135+
:func:`~semver.version.Version.__getitem__`,
136+
:func:`~semver.version.Version.__gt__` etc.
137137
* Remove inconsistencies and mention module level function as
138138
deprecated and discouraged from using
139-
* Make empty :py:func:`super` call in :file:`semverwithvprefix.py` example
139+
* Make empty :py:class:`python:super` call in :file:`semverwithvprefix.py` example
140140

141141
* :gh:`315`: Improve release procedure text
142142

@@ -151,34 +151,32 @@ Trivial/Internal Changes
151151

152152
The following functions got renamed:
153153

154-
* function ``semver.version.comparator`` got renamed to
154+
* function :func:`semver.version.comparator` got renamed to
155155
:func:`semver.version._comparator` as it is only useful
156156
inside the :class:`~semver.version.Version` class.
157-
* function ``semver.version.cmp`` got renamed to
157+
* function :func:`semver.version.cmp` got renamed to
158158
:func:`semver.version._cmp` as it is only useful
159159
inside the :class:`~semver.version.Version` class.
160160

161161
The following functions got integrated into the
162162
:class:`~semver.version.Version` class:
163163

164-
* function ``semver.version._nat_cmd`` as a classmethod
165-
* function ``semver.version.ensure_str``
164+
* function :func:`semver.version._nat_cmd` as a classmethod
165+
* function :func:`semver.version.ensure_str`
166166

167167
* :gh:`313`: Correct :file:`tox.ini` for ``changelog`` entry to skip
168168
installation for semver. This should speed up the execution
169169
of towncrier.
170170

171171
* :gh:`316`: Comparisons of :class:`~semver.version.Version` class and other
172-
types return now a :py:const:`NotImplemented` constant instead
173-
of a :py:exc:`TypeError` exception.
172+
types return now a :py:data:`python:NotImplemented` constant instead
173+
of a :py:exc:`python:TypeError` exception.
174174

175-
The `NotImplemented`_ section of the Python documentation recommends
176-
returning this constant when comparing with ``__gt__``, ``__lt__``,
177-
and other comparison operators to "to indicate that the operation is
175+
In the Python documentation, :py:data:`python:NotImplemented` recommends
176+
returning this constant when comparing with :py:meth:`__gt__ <python:object.__gt__>`, :py:meth:`__lt__ <python:object.__lt__>`,
177+
and other comparison operators "to indicate that the operation is
178178
not implemented with respect to the other type".
179179

180-
.. _NotImplemented: https://docs.python.org/3/library/constants.html#NotImplemented
181-
182180
* :gh:`319`: Introduce stages in :file:`.travis.yml`
183181
The config file contains now two stages: check and test. If
184182
check fails, the test stage won't be executed. This could
@@ -206,7 +204,7 @@ Version 3.0.0-dev.2
206204
Deprecations
207205
------------
208206

209-
* :gh:`169`: Deprecate CLI functions not imported from ``semver.cli``.
207+
* :gh:`169`: Deprecate CLI functions not imported from :mod:`semver.cli`.
210208

211209

212210
.. _semver-3.0.0-dev.2-features:
@@ -222,10 +220,10 @@ Features
222220
* Create :file:`src/semver/_deprecated.py` for the ``deprecated`` decorator and other deprecated functions
223221
* Create :file:`src/semver/__main__.py` to allow calling the CLI using :command:`python -m semver`
224222
* Create :file:`src/semver/_types.py` to hold type aliases
225-
* Create :file:`src/semver/version.py` to hold the :class:`Version` class (old name :class:`VersionInfo`) and its utility functions
223+
* Create :file:`src/semver/version.py` to hold the :class:`~semver.version.Version` class (old name :class:`~semver.version.VersionInfo`) and its utility functions
226224
* Create :file:`src/semver/__about__.py` for all the metadata variables
227225

228-
* :gh:`305`: Rename :class:`VersionInfo` to :class:`Version` but keep an alias for compatibility
226+
* :gh:`305`: Rename :class:`~semver.version.VersionInfo` to :class:`~semver.version.Version` but keep an alias for compatibility
229227

230228

231229
.. _semver-3.0.0-dev.2-docs:
@@ -239,7 +237,7 @@ Improved Documentation
239237
* Add migration chapter from semver2 to semver3.
240238
* Distinguish between changlog for version 2 and 3
241239

242-
* :gh:`305`: Add note about :class:`Version` rename.
240+
* :gh:`305`: Add note about :class:`~semver.version.Version` rename.
243241

244242

245243
.. _semver-3.0.0-dev.2-trivial:
@@ -314,8 +312,8 @@ Features
314312
* Split test suite into separate files under :file:`tests/`
315313
directory
316314
* Adjust and update :file:`setup.py`. Requires Python >=3.6.*
317-
Extract metadata directly from source (affects all the ``__version__``,
318-
``__author__`` etc. variables)
315+
Extract metadata directly from source (affects all the :data:`~semver.__about__.__version__`,
316+
:data:`~semver.__about__.__author__` etc. variables)
319317

320318
* :gh:`270`: Configure Towncrier (:pr:`273`:)
321319

@@ -331,7 +329,7 @@ Features
331329
* Update documentation and add include a new section
332330
"Changelog" included from :file:`changelog.d/README.rst`.
333331

334-
* :gh:`276`: Document how to create a sublass from :class:`VersionInfo` class
332+
* :gh:`276`: Document how to create a sublass from :class:`~semver.version.VersionInfo` class
335333

336334
* :gh:`213`: Add typing information
337335

docs/conf.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,13 @@ def find_version(*file_paths):
126126
# See https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html
127127
intersphinx_mapping = {
128128
# Download it from the root with:
129-
# wget -O docs/python-objects.inv https://docs.python.org/3/objects.inv
129+
# wget -O docs/inventories/python-objects.inv https://docs.python.org/3/objects.inv
130130
"python": ("https://docs.python.org/3", (None, "inventories/python-objects.inv")),
131+
# wget -O docs/inventories/pydantic.inv https://docs.pydantic.dev/latest/objects.inv
132+
"pydantic": (
133+
"https://docs.pydantic.dev/latest/",
134+
(None, "inventories/pydantic.inv"),
135+
),
131136
}
132137
# Avoid side-effects (namely that documentations local references can
133138
# suddenly resolve to an external location.)

docs/inventories/pydantic.inv

3.98 KB
Binary file not shown.

docs/inventories/python-objects.inv

3.96 KB
Binary file not shown.

docs/usage/access-parts-of-a-version.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ parts of a version:
2121
'build.4'
2222
2323
However, the attributes are read-only. You cannot change any of the above attributes.
24-
If you do, you get an :py:exc:`AttributeError`::
24+
If you do, you get an :py:exc:`python:AttributeError`::
2525

2626
>>> v.minor = 5
2727
Traceback (most recent call last):

docs/usage/access-parts-through-index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Or, as an alternative, you can pass a :func:`slice` object:
3333
>>> ver[sl]
3434
(10, 3, 2)
3535
36-
Negative numbers or undefined parts raise an :py:exc:`IndexError` exception:
36+
Negative numbers or undefined parts raise an :py:exc:`python:IndexError` exception:
3737

3838
.. code-block:: python
3939

docs/usage/compare-versions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ To compare two versions depends on your type:
6262
>>> "3.5.0" > v
6363
True
6464

65-
However, if you compare incomplete strings, you get a :py:exc:`ValueError` exception::
65+
However, if you compare incomplete strings, you get a :py:exc:`python:ValueError` exception::
6666

6767
>>> v > "1.0"
6868
Traceback (most recent call last):
@@ -82,7 +82,7 @@ To compare two versions depends on your type:
8282
>>> dict(major=1) < v
8383
True
8484

85-
If the dictionary contains unknown keys, you get a :py:exc:`TypeError` exception::
85+
If the dictionary contains unknown keys, you get a :py:exc:`python:TypeError` exception::
8686

8787
>>> v > dict(major=1, unknown=42)
8888
Traceback (most recent call last):

docs/usage/create-a-version.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ A :class:`~semver.version.Version` instance can be created in different ways:
4141
Version(major=3, minor=4, patch=5, prerelease='pre.2', build='build.4')
4242

4343
Keep in mind, the ``major``, ``minor``, ``patch`` parts has to
44-
be positive integers or strings:
44+
be positive integers or strings, otherwise a :py:exc:`python:ValueError` is raised:
4545

4646
>>> d = {'major': -3, 'minor': 4, 'patch': 5, 'prerelease': 'pre.2', 'build': 'build.4'}
4747
>>> Version(**d)
@@ -50,7 +50,7 @@ A :class:`~semver.version.Version` instance can be created in different ways:
5050
ValueError: 'major' is negative. A version can only be positive.
5151

5252
As a minimum requirement, your dictionary needs at least the ``major``
53-
key, others can be omitted. You get a ``TypeError`` if your
53+
key, others can be omitted. You get a :py:exc:`python:TypeError` if your
5454
dictionary contains invalid keys.
5555
Only the keys ``major``, ``minor``, ``patch``, ``prerelease``, and ``build``
5656
are allowed.
@@ -92,7 +92,7 @@ Depending on your use case, the following methods are available:
9292
>>> semver.parse("3.4.5-pre.2+build.4")
9393
{'major': 3, 'minor': 4, 'patch': 5, 'prerelease': 'pre.2', 'build': 'build.4'}
9494

95-
If you pass an invalid version string you will get a :py:exc:`ValueError`::
95+
If you pass an invalid version string you will get a :py:exc:`python:ValueError`::
9696

9797
>>> semver.parse("1.2")
9898
Traceback (most recent call last):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy