nebius/SWE-bench-extra huggingface dataset:
Repository: sphinx-gallery/sphinx-gallery

Issue:
backreferences processing breaks if module accessed without attribute
The scikit-learn docs fail to build at https://circleci.com/gh/scikit-learn/scikit-learn/7314?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link due to https://github.com/sphinx-gallery/sphinx-gallery/blob/master/sphinx_gallery/backreferences.py#L106 where it is assumed that a module being referenced is always referenced with an attribute. It should be possible to reference a module without its attribute and hence for no `.` to be present.

Comments:

Patch:
diff --git a/sphinx_gallery/backreferences.py b/sphinx_gallery/backreferences.py
index 4fe579c..28cf10a 100644
--- a/sphinx_gallery/backreferences.py
+++ b/sphinx_gallery/backreferences.py
@@ -103,7 +103,13 @@ def identify_names(code):
     for name, full_name in finder.get_mapping():
         # name is as written in file (e.g. np.asarray)
         # full_name includes resolved import path (e.g. numpy.asarray)
-        module, attribute = full_name.rsplit('.', 1)
+        splitted = full_name.rsplit('.', 1)
+        if len(splitted) == 1:
+            # module without attribute. This is not useful for
+            # backreferences
+            continue
+
+        module, attribute = splitted
         # get shortened module name
         module_short = get_short_module_name(module, attribute)
         cobj = {'name': attribute, 'module': module,


Test patch:
diff --git a/sphinx_gallery/tests/test_backreferences.py b/sphinx_gallery/tests/test_backreferences.py
index d820378..1e9e6c9 100644
--- a/sphinx_gallery/tests/test_backreferences.py
+++ b/sphinx_gallery/tests/test_backreferences.py
@@ -60,3 +60,33 @@ def test_backref_thumbnail_div():
 """
 
     assert_equal(html_div, reference)
+
+
+def test_identify_names():
+    code_str = """
+import os
+os
+
+os.path.join
+
+import sphinx_gallery.back_references as br
+br.identify_names
+
+from sphinx_gallery.back_references import identify_names
+identify_names
+"""
+    res = sg.identify_names(code_str)
+    expected = {
+        'os.path.join':
+            {'name': 'join', 'module': 'os.path', 'module_short': 'os.path'},
+        'br.identify_names':
+            {'name': 'identify_names',
+             'module': 'sphinx_gallery.back_references',
+             'module_short': 'sphinx_gallery.back_references'},
+        'identify_names':
+            {'name': 'identify_names',
+             'module': 'sphinx_gallery.back_references',
+             'module_short': 'sphinx_gallery.back_references'}
+        }
+
+    assert_equal(expected, res)
Repository: sphinx-gallery/sphinx-gallery

Issue:
Small regression in 0.4.1: print(__doc__) creates empty output block 
Seen in https://github.com/scikit-learn/scikit-learn/pull/14507#issuecomment-516466110, `print(__doc__)` creates empty output box (yellowish box in the output below). 

![image](https://user-images.githubusercontent.com/1680079/62141734-5f74e380-b2ed-11e9-9796-4ff96ae33d63.png)

This was introduced by https://github.com/sphinx-gallery/sphinx-gallery/pull/475. A simple fix would be to not have an output box if `my_stdout.isspace()` and add a test similar to the one introduced in #475 to check that `print(__doc__)` does not create an output box.

Small reminder: many scikit-learn examples have `print(__doc__)` at the beginning, so inside sphinx-gallery we set `__doc__ = ''` (`__doc__` is already rendered at the top of the example HTML so you don't want it captured in stdout as well).

ping @lucyleeow who is interested to work on this.


Comments:

Patch:
diff --git a/sphinx_gallery/gen_rst.py b/sphinx_gallery/gen_rst.py
index 64c2047..ed04ba2 100644
--- a/sphinx_gallery/gen_rst.py
+++ b/sphinx_gallery/gen_rst.py
@@ -508,7 +508,7 @@ def execute_code_block(compiler, block, example_globals,
         os.chdir(cwd)
 
         captured_std = captured_std.getvalue().expandtabs()
-        if captured_std:
+        if captured_std and not captured_std.isspace():
             captured_std = CODE_OUTPUT.format(indent(captured_std, u' ' * 4))
         else:
             captured_std = ''


Test patch:
diff --git a/sphinx_gallery/tests/test_gen_rst.py b/sphinx_gallery/tests/test_gen_rst.py
index 82644ad..2442540 100644
--- a/sphinx_gallery/tests/test_gen_rst.py
+++ b/sphinx_gallery/tests/test_gen_rst.py
@@ -448,6 +448,27 @@ def test_output_indentation(gallery_conf):
     assert output_test_string == test_string.replace(r"\n", "\n")
 
 
+def test_empty_output_box(gallery_conf):
+    """Tests that `print(__doc__)` doesn't produce an empty output box."""
+    compiler = codeop.Compile()
+    
+    code_block = ("code", "print(__doc__)", 1)
+
+    script_vars = {
+        "execute_script": True,
+        "image_path_iterator": ImagePathIterator("temp.png"),
+        "src_file": __file__,
+        "memory_delta": [],
+    }
+
+    example_globals = {'__doc__': ''}
+
+    output = sg.execute_code_block(
+        compiler, code_block, example_globals, script_vars, gallery_conf
+    )
+    assert output.isspace() == True
+
+
 class TestLoggingTee:
     def setup(self):
         self.output_file = io.StringIO()
Repository: sphinx-gallery/sphinx-gallery

Issue:
Remove the note linking to the download section at the beginning of the example from latex/pdf output
For latex/pdf output, this note at the beginning of the example linking to the download section does not link to anything (since there are no download buttons). Would it be possible to disable it in that case? The straightforward way would be wrap it into a `.. only:: html` directive.

Comments:

Patch:
diff --git a/sphinx_gallery/gen_rst.py b/sphinx_gallery/gen_rst.py
index 5d632a5..4100482 100644
--- a/sphinx_gallery/gen_rst.py
+++ b/sphinx_gallery/gen_rst.py
@@ -857,12 +857,13 @@ def save_rst_example(example_rst, example_file, time_elapsed,
 
     binder_text = (" or to run this example in your browser via Binder"
                    if len(binder_conf) else "")
-    example_rst = (".. note::\n"
-                   "    :class: sphx-glr-download-link-note\n\n"
-                   "    Click :ref:`here <sphx_glr_download_{0}>` "
-                   "to download the full example code{1}\n"
-                   ".. rst-class:: sphx-glr-example-title\n\n"
-                   ".. _sphx_glr_{0}:\n\n"
+    example_rst = (".. only:: html\n\n"
+                   "    .. note::\n"
+                   "        :class: sphx-glr-download-link-note\n\n"
+                   "        Click :ref:`here <sphx_glr_download_{0}>` "
+                   "    to download the full example code{1}\n"
+                   "    .. rst-class:: sphx-glr-example-title\n\n"
+                   "    .. _sphx_glr_{0}:\n\n"
                    ).format(ref_fname, binder_text) + example_rst
 
     if time_elapsed >= gallery_conf["min_reported_time"]:


Test patch:
diff --git a/sphinx_gallery/tests/test_gen_rst.py b/sphinx_gallery/tests/test_gen_rst.py
index 911fc6c..d0d0602 100644
--- a/sphinx_gallery/tests/test_gen_rst.py
+++ b/sphinx_gallery/tests/test_gen_rst.py
@@ -417,6 +417,16 @@ def test_remove_config_comments(gallery_conf):
     assert '# sphinx_gallery_thumbnail_number = 1' not in rst
 
 
+def test_download_link_note_only_html(gallery_conf):
+    """Test html only directive for download_link."""
+    rst = _generate_rst(gallery_conf, 'test.py', CONTENT)
+    download_link_note = (".. only:: html\n\n"
+                          "    .. note::\n"
+                          "        :class: sphx-glr-download-link-note\n\n"
+                          )
+    assert download_link_note in rst
+
+
 @pytest.mark.parametrize('ext', ('.txt', '.rst', '.bad'))
 def test_gen_dir_rst(gallery_conf, fakesphinxapp, ext):
     """Test gen_dir_rst."""