From c853abca7a4a20e5419bb7d66fd5727916892e0f Mon Sep 17 00:00:00 2001
From: Douglas Raillard <douglas.raillard@arm.com>
Date: Wed, 7 Feb 2024 16:09:08 +0000
Subject: [PATCH] lisa._doc.helpers: Avoid "import conf"

This breaks in some cases, so just use function parameters instead.
---
 doc/conf.py          | 10 +++++++---
 lisa/_doc/helpers.py |  9 ++-------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/doc/conf.py b/doc/conf.py
index 5f5c68037..99df612dd 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -493,16 +493,20 @@ def setup(app):
 
     plot_conf_path = os.path.join(HOME, 'doc', 'plot_conf.yml')
     plot_conf = DocPlotConf.from_yaml_map(plot_conf_path)
-    autodoc_process_analysis_plots_handler = functools.partial(
+    _autodoc_process_analysis_plots_handler = functools.partial(
         autodoc_process_analysis_plots,
         plot_conf=plot_conf,
     )
+    _autodoc_skip_member_handler = functools.partial(
+        autodoc_skip_member_handler,
+        default_exclude_members=autodoc_default_options.get('exclude-members')
+    )
 
     app.connect('autodoc-process-docstring', autodoc_process_test_method)
     app.connect('autodoc-process-docstring', autodoc_process_analysis_events)
     app.connect('autodoc-process-docstring', autodoc_process_analysis_methods)
-    app.connect('autodoc-skip-member',       autodoc_skip_member_handler)
+    app.connect('autodoc-skip-member',       _autodoc_skip_member_handler)
     if int(os.environ.get('LISA_DOC_BUILD_PLOT', '1')):
-        app.connect('autodoc-process-docstring', autodoc_process_analysis_plots_handler)
+        app.connect('autodoc-process-docstring', _autodoc_process_analysis_plots_handler)
 
 # vim :set tabstop=4 shiftwidth=4 textwidth=80 expandtab:
diff --git a/lisa/_doc/helpers.py b/lisa/_doc/helpers.py
index 01023937b..64d084613 100644
--- a/lisa/_doc/helpers.py
+++ b/lisa/_doc/helpers.py
@@ -223,7 +223,7 @@ def autodoc_process_analysis_events(app, what, name, obj, options, lines):
         lines.extend(events_doc.splitlines())
 
 
-def autodoc_skip_member_handler(app, what, name, obj, skip, options):
+def autodoc_skip_member_handler(default_exclude_members, app, what, name, obj, skip, options):
     """
     Enforce the "exclude-members" option, even in cases where it seems to be
     ignored by Sphinx.
@@ -239,12 +239,7 @@ def autodoc_skip_member_handler(app, what, name, obj, skip, options):
         else:
             excluded = exclude_members_option(excluded)
 
-    # Import conf.py Sphinx configuration, since the "excluded-members" option
-    # can be overriden by the user in ReST directives.
-    import conf
-    default_excluded = exclude_members_option(
-        conf.autodoc_default_options.get('exclude-members', '')
-    )
+    default_excluded = exclude_members_option(default_exclude_members)
     excluded = excluded | default_excluded
 
     name = name.split('.')[-1]
-- 
GitLab