From c617138445dacaf0fa9b7ed5a8c93b63a9749bc9 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 3 Jan 2024 03:20:01 +0000 Subject: [PATCH] Add ``Config.__repr__()`` --- sphinx/config.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sphinx/config.py b/sphinx/config.py index eb6fc250c..e831605c4 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -285,6 +285,16 @@ class Config: check_confval_types(None, self) + def __repr__(self): + values = [] + for opt_name in self._options: + try: + opt_value = getattr(self, opt_name) + except Exception: + opt_value = '' + values.append(f"{opt_name}={opt_value!r}") + return self.__class__.__qualname__ + '(' + ', '.join(values) + ')' + def __getattr__(self, name: str) -> Any: if name.startswith('_'): raise AttributeError(name)