Skip to content

Commit 6af7522

Browse files
committed
repr() workaround for Sphinx docs
1 parent d970497 commit 6af7522

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

docs/conf.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@
3838
import reframe # noqa: F401, F403
3939
import reframe.utility.osext as osext # noqa: F401, F403
4040

41+
# Sphinx erroneously uses `repr()` to display values and not the
42+
# human-readable `str()`. For this reason we define the following variable in
43+
# the `reframe` module so that objects can redirect to their `str()` method
44+
# from `repr()` if they are invoked in the context of Sphinx when building the
45+
# documentation. See discussion and the related workaround here:
46+
#
47+
# https://github.com/sphinx-doc/sphinx/issues/3857
48+
49+
reframe.__build_docs__ = True
50+
4151
# -- General configuration ------------------------------------------------
4252

4353
# If your documentation needs a minimal Sphinx version, state it here.

reframe/core/variables.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ def __str__(self):
346346
return str(self._default_value)
347347

348348
def __repr__(self):
349+
import reframe
350+
if hasattr(reframe, '__build_docs__'):
351+
return str(self)
352+
349353
try:
350354
name = self.name
351355
except AttributeError:

0 commit comments

Comments
 (0)