Skip to content

Commit

Permalink
Pin the version in the stable install docs
Browse files Browse the repository at this point in the history
When building documentation for a tagged release in ReadTheDocs, pin the
version we suggest users to install to a version matching the
documentation they are reading.

For example, a ReadTheDocs build for the v1.9.0 tag would suggest users
to run "pip install cocotb =~ 1.9.0", which gives them a 1.9.x version
matching the documentation they are reading.

For all other Sphinx build types (local builds, PR builds, "latest" RTD
builds, etc.), the documentation stays as is: it gives instructions how
to install the latest stable release (whatever that might be currently),
and also shows how to install a development release.

(cherry picked from commit 61cb17b)
  • Loading branch information
imphil committed Jul 10, 2024
1 parent bbed0a6 commit 20daae2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
9 changes: 9 additions & 0 deletions documentation/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@
v_major, v_minor = LooseVersion(release).version[:2]
version = "{}.{}".format(v_major, v_minor)

# Is this documentation build a ReadTheDocs build for a git tag, i.e., a
# release? Set the 'is_release_build' tag then, which can be used by the
# '.. only::' directive.
# https://docs.readthedocs.io/en/stable/reference/environment-variables.html
is_rtd_tag = 'READTHEDOCS' in os.environ and os.environ.get('READTHEDOCS_VERSION_TYPE', 'unknown') == 'tag'

if is_rtd_tag:
tags.add('is_release_build')

autoclass_content = "both"

autodoc_typehints = "description" # show type hints in the list of parameters
Expand Down
17 changes: 14 additions & 3 deletions documentation/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,22 @@ The installation instructions vary depending on your operating system:
Installation of cocotb
======================

The **stable version** of cocotb can be installed by running
.. only:: is_release_build

.. code-block:: bash
You are reading the documentation for cocotb |version|.
To install this version, or any later compatible version, run

pip install cocotb
.. parsed-literal::
pip install cocotb =~ |version|
.. only:: not is_release_build

The latest **stable version** of cocotb can be installed by running

.. code-block:: bash
pip install cocotb
.. note::

Expand Down

0 comments on commit 20daae2

Please sign in to comment.