This is an automated email from the ASF dual-hosted git repository.

amoghrajesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 74d1a3b0bb3 Stop docs builds from importing example Dags to highlight 
them (#73604)
74d1a3b0bb3 is described below

commit 74d1a3b0bb386a15191c3a83ba4f83598621fe7c
Author: Amogh Desai <[email protected]>
AuthorDate: Thu Sep 24 06:33:43 2026 +0530

    Stop docs builds from importing example Dags to highlight them (#73604)
---
 devel-common/src/sphinx_exts/exampleinclude.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/devel-common/src/sphinx_exts/exampleinclude.py 
b/devel-common/src/sphinx_exts/exampleinclude.py
index 220fb7eb62f..7bde12bc1ee 100644
--- a/devel-common/src/sphinx_exts/exampleinclude.py
+++ b/devel-common/src/sphinx_exts/exampleinclude.py
@@ -127,13 +127,14 @@ class ExampleInclude(SphinxDirective):
             return [document.reporter.warning(str(exc), line=self.lineno)]
 
 
-def register_source(app, env, modname):
+def register_source(app, env, modname, filepath):
     """
     Registers source code.
 
     :param app: application
     :param env: environment of the plugin
-    :param modname: name of the module to load
+    :param modname: name of the module the file corresponds to
+    :param filepath: path of the file holding the source code
     :return: True if the code is registered successfully, False otherwise
     """
     if modname is None:
@@ -147,10 +148,11 @@ def register_source(app, env, modname):
 
     if code_tags is None:
         try:
-            analyzer = ModuleAnalyzer.for_module(modname)
+            # for_file() over for_module(): the latter imports the module; 
these are not importable
+            analyzer = ModuleAnalyzer.for_file(filepath, modname)
         except Exception as ex:
             logger.info(
-                'Module "%s" could not be loaded. Full source will not be 
available. "%s"', modname, ex
+                'Module "%s" could not be parsed. Full source will not be 
available. "%s"', modname, ex
             )
             # We cannot use regular warnings or exception methods because 
those warnings are interpreted
             # by running python process and converted into "real" warnings, so 
we need to print the
@@ -254,7 +256,7 @@ def doctree_read(app, doctree):
         else:
             modname = None
             module_path = filepath.resolve()
-        show_button = register_source(app, env, modname)
+        show_button = register_source(app, env, modname, filepath)
         onlynode = create_node(env, module_path.as_posix(), show_button)
 
         objnode.replace_self(onlynode)

Reply via email to