Skip to content

Commit efea83f

Browse files
committed
Convert docs to Sphinx
1 parent 2a728ab commit efea83f

11 files changed

Lines changed: 516 additions & 247 deletions

File tree

.readthedocs.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
formats: all
3+
python:
4+
version: 3
5+
install:
6+
- requirements: docs/requirements.txt
7+
- method: pip
8+
path: .
9+
sphinx:
10+
configuration: docs/conf.py
11+
fail_on_warning: true

README.rst

Lines changed: 32 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
`GitHub <https://github.com/jwodder/pyversion-info>`_
2121
| `PyPI <https://pypi.org/project/pyversion-info/>`_
22+
| `Documentation <https://pyversion-info.readthedocs.io>`_
2223
| `Issues <https://github.com/jwodder/pyversion-info/issues>`_
2324
| `Changelog <https://github.com/jwodder/pyversion-info/blob/master/CHANGELOG.md>`_
2425
@@ -27,7 +28,8 @@
2728

2829
Ever needed to know what Python versions were currently supported, or how many
2930
subversions a given Python version had? Wondering how long until a given
30-
version came out or reached end-of-life? The answers to these and some other
31+
version came out or reached end-of-life? Need to know what CPython versions a
32+
given PyPy version corresponds to? The answers to these and some other
3133
questions can be found with this library.
3234

3335
``pyversion-info`` pulls its data every run from
@@ -36,6 +38,9 @@ on GitHub. Prerelease versions are not (currently) included. I promise
3638
24-hour turnaround times for keeping the database up-to-date until I am hit by
3739
a bus.
3840

41+
See `the documentation <https://pyversion-info.readthedocs.io>`_ for more
42+
information.
43+
3944

4045
Installation
4146
============
@@ -49,228 +54,48 @@ Installation
4954
Examples
5055
========
5156

52-
Start out by fetching the database:
53-
54-
>>> from pyversion_info import get_pyversion_info
55-
>>> pyvinfo = get_pyversion_info()
56-
57-
Get a list of all currently-supported Python series:
58-
59-
>>> pyvinfo.supported_series()
60-
['2.7', '3.5', '3.6', '3.7']
61-
62-
When does 3.8 come out?
63-
64-
>>> pyvinfo.release_date("3.8")
65-
datetime.date(2019, 10, 21)
66-
67-
When does 2.7 reach end-of-life?
68-
69-
>>> pyvinfo.eol_date("2.7")
70-
datetime.date(2020, 1, 1)
71-
72-
Just how many micro versions does 2.7 have, anyway?
73-
74-
>>> pyvinfo.subversions("2.7")
75-
['2.7.0', '2.7.1', '2.7.2', '2.7.3', '2.7.4', '2.7.5', '2.7.6', '2.7.7', '2.7.8', '2.7.9', '2.7.10', '2.7.11', '2.7.12', '2.7.13', '2.7.14', '2.7.15', '2.7.16']
76-
77-
How many versions of Python 3 have been released?
78-
79-
>>> pyvinfo.subversions("3")
80-
['3.0', '3.1', '3.2', '3.3', '3.4', '3.5', '3.6', '3.7']
81-
82-
83-
API
84-
===
85-
86-
Versions are passed to & returned from methods as strings in the form ``"X"``
87-
(a major version), ``"X.Y"`` (a minor version), or ``"X.Y.Z"`` (a micro
88-
version).
89-
90-
All dates are returned as ``datetime.date`` objects.
91-
92-
``PyVersionInfo``
93-
-----------------
94-
A class for querying Python versions and their release & EOL dates
95-
96-
``PyVersionInfo(data: dict)``
97-
Construct a new ``PyVersionInfo`` object from a `dict` containing version
98-
release dates and series EOL dates structured in accordance with `this
99-
JSON Schema`__
100-
101-
__ https://raw.githubusercontent.com/jwodder/pyversion-info-data/master/
102-
pyversion-info-data.v1.schema.json
103-
104-
``pyvinfo.eol_date(series: str) -> Optional[date]``
105-
Returns the end-of-life date of the given Python version series (i.e., a
106-
minor version like 3.5). The return value may be ``None``, indicating that,
107-
though the series is known to the database, its EOL date is not; use
108-
``is_eol()`` to determine whether such a version has reached end-of-life yet
109-
or not.
110-
111-
``pyvinfo.is_eol(series: str) -> bool``
112-
Returns whether the given version series has reached end-of-life yet
113-
114-
``pyvinfo.is_released(version: str) -> bool``
115-
Returns whether the given version has been released yet. For a major or
116-
minor version, this is the whether the first (in version order) micro
117-
version has been released.
118-
119-
``pyvinfo.is_supported(version: str) -> bool``
120-
Returns whether the given version is currently supported. For a micro
121-
version, this is whether it has been released and the corresponding minor
122-
version is not yet end-of-life. For a major or minor version, this is
123-
whether at least one subversion is supported.
124-
125-
``pyvinfo.major_versions() -> List[str]``
126-
Returns a list in version order of all known Python major versions (as
127-
strings).
128-
129-
``pyinfo.micro_versions() -> List[str]``
130-
Returns a list in version order of all Python micro versions. Versions in
131-
the form ``X.Y`` are included here as ``X.Y.0``.
132-
133-
``pyvinfo.minor_versions() -> List[str]``
134-
Returns a list in version order of all Python minor versions.
135-
136-
``pyvinfo.release_date(version: str) -> Optional[date]``
137-
Returns the release date of the given Python version. For a major or minor
138-
version, this is the release date of its first (in version order) micro
139-
version. The return value may be ``None``, indicating that, though the
140-
version is known to the database, its release date is not; use
141-
``is_released()`` to determine whether such a version has been released or
142-
not.
57+
(The given outputs are current as of 2021-11-04.)
14358

144-
``pyvinfo.subversions(version: str) -> List[str]``
145-
Returns a list in version order of all subversions of the given version. If
146-
``version`` is a major version, this is all of its released minor versions.
147-
If ``version`` is a minor version, this is all of its released micro
148-
versions.
149-
150-
``pyvinfo.supported_series() -> List[str]``
151-
Returns a list in version order of all Python version series (i.e., minor
152-
versions like 3.5) that are currently supported (i.e., that have at least
153-
one release made and are not yet end-of-life)
154-
155-
156-
Utilities
157-
---------
158-
159-
``UnknownVersionError``
160-
Subclass of ``ValueError`` raised when ``PyVersionInfo`` is asked for
161-
information about a version that does not appear in its database.
162-
Operations that result in an ``UnknownVersionError`` may succeed later as
163-
more Python versions are announced & released.
164-
165-
The unknown version is stored in an ``UnknownVersionError`` instance's
166-
``version`` attribute.
167-
168-
``get_pyversion_info(url: str = pyversion_info.DATA_URL, cache_dir: Optional[str] = pyversion_info.CACHE_DIR) -> PyVersionInfo``
169-
Fetches the latest version release data from ``url`` and returns a new
170-
``PyVersionInfo`` object. The HTTP response is cached in ``cache_dir`` to
171-
speed up future requests (or ``cache_dir`` can be set to ``None`` to
172-
disable caching).
173-
174-
175-
Command
176-
=======
177-
178-
*New in version 0.4.0*
179-
180-
``pyversion-info`` also provides a command of the same name for querying
181-
information about Python versions from the command line::
182-
183-
pyversion-info [<global-options>] <command> [<args> ...]
184-
185-
Currently, ``pyversion-info`` has two subcommands, ``list`` and ``show``.
186-
187-
188-
Global Options
189-
--------------
190-
191-
-d DATABASE, --database DATABASE
192-
Use the given JSON file as the version
193-
information database instead of fetching data
194-
from the default URL. ``DATABASE`` can be
195-
either an HTTP or HTTPS URL or a path to a
196-
local file.
197-
198-
199-
``pyversion-info list``
200-
-----------------------
201-
202-
::
203-
204-
pyversion-info [<global-options>] list [<options>] {major|minor|micro}
205-
206-
List all major, minor, or micro Python versions, one per line.
207-
208-
209-
Options
210-
^^^^^^^
211-
212-
-a, --all List all known versions of the given level
213-
-n, --not-eol Only list versions that have not yet reached
214-
end-of-life (i.e., all supported versions plus
215-
all unreleased versions)
216-
-r, --released Only list released versions. This is the
217-
default.
218-
-s, --supported Only list currently-supported versions
219-
220-
221-
``pyversion-info show``
222-
-----------------------
59+
Start out by fetching the database:
22360

224-
::
61+
>>> from pyversion_info import VersionDatabase
62+
>>> vd = VersionDatabase.fetch()
22563

226-
pyversion-info [<global-options>] show [<options>] <version>
64+
Get a list of all currently-supported CPython series:
22765

228-
Show various information about a given Python version.
66+
>>> vd.cpython.supported_series()
67+
['3.6', '3.7', '3.8', '3.9', '3.10']
22968

230-
For a major version, the output is of the form::
69+
When does 3.11 come out?
23170

232-
Version: 3
233-
Level: major
234-
Release-date: 2008-12-03
235-
Is-released: yes
236-
Is-supported: yes
237-
Subversions: 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9
71+
>>> vd.cpython.release_date("3.11")
72+
datetime.date(2022, 10, 3)
23873

239-
For a minor version, the output is of the form::
74+
When does 3.6 reach end-of-life?
24075

241-
Version: 3.3
242-
Level: minor
243-
Release-date: 2012-09-29
244-
Is-released: yes
245-
Is-supported: no
246-
EOL-date: 2017-09-29
247-
Is-EOL: yes
248-
Subversions: 3.3.0, 3.3.1, 3.3.2, 3.3.3, 3.3.4, 3.3.5, 3.3.6, 3.3.7
76+
>>> vd.cpython.eol_date("3.6")
77+
datetime.date(2021, 12, 23)
24978

250-
For a micro version, the output is of the form::
79+
Just how many micro versions does 3.9 have, anyway?
25180

252-
Version: 3.9.5
253-
Level: micro
254-
Release-date: 2021-05-03
255-
Is-released: yes
256-
Is-supported: yes
81+
>>> vd.cpython.subversions("3.9")
82+
['3.9.0', '3.9.1', '3.9.2', '3.9.3', '3.9.4', '3.9.5', '3.9.6', '3.9.7', '3.9.8', '3.9.9', '3.9.10', '3.9.11']
25783

84+
What major versions of PyPy are there?
25885

259-
Options
260-
^^^^^^^
86+
>>> vd.pypy.major_versions()
87+
['1', '2', '4', '5', '6', '7']
26188

262-
-J, --json Output JSON
89+
What CPython series do PyPy 7.3.\* support?
26390

264-
-S, --subversions <all|not-eol|released|supported>
265-
Which subversions to list; the choices have the
266-
same meanings as the ``list`` options of the
267-
same name [default: released]
91+
>>> vd.pypy.supports_cpython_series("7.3")
92+
['2.7', '3.6', '3.7', '3.8']
26893

26994

27095
Caveats
27196
=======
27297

273-
The database is generally only updated when an edit is made to a release
274-
schedule PEP. Occasionally, a deadline listed in a PEP is missed, but the PEP
275-
is not updated for a couple days, and so for a brief period this library will
276-
falsely report the given version as released.
98+
The CPython database is generally only updated when an edit is made to a
99+
release schedule PEP. Occasionally, a deadline listed in a PEP is missed, but
100+
the PEP is not updated for a couple days, and so for a brief period this
101+
library will falsely report the given version as released.

docs/api.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.. currentmodule:: pyversion_info
2+
3+
API
4+
===
5+
6+
Versions are passed to & returned from methods as strings in the form ``"X"``
7+
(a major version), ``"X.Y"`` (a minor version), or ``"X.Y.Z"`` (a micro
8+
version).
9+
10+
All dates are returned as `datetime.date` objects.
11+
12+
.. autoclass:: VersionDatabase()
13+
:exclude-members: fetch
14+
15+
.. automethod:: fetch(url: str = DATA_URL, cache_dir: Union[str, pathlib.Path, None] = CACHE_DIR) -> pyversion_info.VersionDatabase
16+
:noindex:
17+
18+
.. autoclass:: VersionInfo()
19+
20+
.. autoclass:: CPythonVersionInfo()
21+
:show-inheritance:
22+
23+
.. autoclass:: PyPyVersionInfo()
24+
:show-inheritance:
25+
26+
.. autoexception:: UnknownVersionError
27+
:show-inheritance:
28+
29+
.. autodata:: DATA_URL
30+
:annotation:
31+
32+
.. autodata:: CACHE_DIR
33+
:annotation:

docs/changelog.rst

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
.. currentmodule:: pyversion_info
2+
3+
Changelog
4+
=========
5+
6+
v1.0.0 (in development)
7+
-----------------------
8+
- Support Python 3.10
9+
- Drop support for Python 3.6
10+
- Support for fetching information on PyPy versions has been added. With it
11+
come the following changes:
12+
13+
- The schema used by the database (and thus the URL for the default database)
14+
has been modified
15+
- ``PyVersionInfo`` has been renamed to `CPythonVersionInfo`
16+
- A new `PyPyVersionInfo` class has been added
17+
- A new `VersionDatabase` class has been added, containing a
18+
`CPythonVersionInfo` instance and a `PyPyVersionInfo` instance
19+
- ``get_pyversion_info()`` is now `VersionDatabase.fetch()`
20+
- The command-line interface now takes a ``--pypy`` option for showing
21+
details about PyPy versions
22+
23+
- The ``unreleased`` argument to `~VersionInfo.major_versions()`,
24+
`~VersionInfo.minor_versions()`, `~VersionInfo.micro_versions()`, and
25+
`~VersionInfo.subversions()` has been removed; the methods now return all
26+
known versions, released & unreleased
27+
- `~VersionInfo.release_date()` now returns `None` for any known version whose
28+
release date is unknown, whether it's been released yet or not. Use
29+
`~VersionInfo.is_released()` to determine whether such a version has been
30+
released.
31+
- `~CPythonVersionInfo.eol_date()` now returns `None` for any known version
32+
whose EOL date is unknown, whether it's EOL yet or not. Use
33+
`~CPythonVersionInfo.is_eol()` to determine whether such a version has
34+
reached end-of-life.
35+
36+
37+
v0.4.0 (2021-10-03)
38+
-------------------
39+
- `~VersionInfo.major_versions()`, `~VersionInfo.minor_versions()`,
40+
`~VersionInfo.micro_versions()`, and `~VersionInfo.subversions()` now take
41+
optional ``unreleased`` arguments for including unreleased versions
42+
- `~CPythonVersionInfo.is_supported()` now accepts major and micro versions
43+
- `UnknownVersionError` now inherits `ValueError`
44+
- Added a command-line interface
45+
46+
47+
v0.3.0 (2021-10-01)
48+
-------------------
49+
- Add type annotations
50+
- Switch from appdirs to platformdirs
51+
52+
53+
v0.2.0 (2020-12-13)
54+
-------------------
55+
- Support Python 3.8 and 3.9
56+
- Add a note to the README about the possibility of release deadlines being
57+
missed
58+
- Drop support for Python 2.7, 3.4, and 3.5
59+
- Properly close the ``requests`` session after downloading the database
60+
61+
62+
v0.1.0 (2019-04-23)
63+
-------------------
64+
Initial release

0 commit comments

Comments
 (0)