Repository: spyder-ide/spyder

Issue:
Images are not rendered by the Help pane on Windows
Simple example:

```
class test(object):
    """
    diagram:

    .. image:: picture.png
    """
    pass
```

Save this code in a file like test.py. Save any small picture in as picture.png in the same folder.

Put the cursor in front of the class name "test" and press < ctrl >< i >.

The object inspector displays:

class test(object)

diagram

and an empty box instead of the picture.

This should be fixed. I like the object inspector, and I like to add diagrams to some of my methods and classes to explain how they work.



Discussion:
@blink1073 did you look at this at some point if I am not mistaken?

I think this is solved in master, and @blink1073 did it :-)

Does someone know the commit or the pull request? Perhaps I can apply that to my local spyder version.

@ufechner7, https://bitbucket.org/spyder-ide/spyderlib/pull-request/12/add-ability-to-re-trigger-docstring-while/diff.

If using absolute paths, they must must be URIs, in this case: file:///path/to/picture.png. See http://en.wikipedia.org/wiki/File_URI_scheme.

@ccordoba12 I tried the master branch, but images are still missing.
![image](https://cloud.githubusercontent.com/assets/12562760/8472275/648936c0-20d2-11e5-973c-d4028d3e56c5.png)

I can add that the problem is not with the path. When the image is found (left case), the bounding box is displayed without the content but with the file name in it, without extension. If it is not found (right case), a default placeholder appears.
Also, the star extension (".*") is not understood and is again the "not found" case.

![noimages](https://cloud.githubusercontent.com/assets/17322580/13281598/034b5eba-dae5-11e5-81a4-c87095b6bd99.png)

Known image size means the script can see an image when generating the html.
The problem with the images is hiding iside the Javascript called "fix_image_paths.js" (irony).
First, since I live in Windows world, all paths contain the backslash symbol, which is an escape character and causes errors if appears explicitly in your file. So I modified the **generate_context** in spyderlib/utils/inspector/sphinxify.py to replace the backslashes in the _img_path_ to forward ones before sending them to sphinx:

```
    context = \
    {
      'math_on': 'true' if math else '',
      'name': name,
      'argspec': argspec,
      'note': note,
      'collapse': collapse,
      #'img_path': img_path,
      'img_path': re.sub('\\\\', '/', img_path),
```

My second problem was in the way I set the relative path to the images in reST: "folder_name/image_name.png"

If you take a look inside"_fix_image_paths.js_", you will notice that the folder name is simply ignored:

```
$(document).ready(function () {
    $('img').attr('src', function(index, attr){
        var path = attr.split('/')
        var img_name = path.reverse()[0]
        return '{{img_path}}' + '/' + img_name
    });
});
```

So, I modified it slightly:

```
$(document).ready(function () {
    $('img').attr('src', function(index, attr){
        //var path = attr.split('/')
        //var img_name = path.reverse()[0]
        //return '{{img_path}}' + '/' + img_name
        return '{{img_path}}' + '/' + attr
    });
});
```

Now all my images are visible in the inspector.

I just checked on Linux, everything works for me: image with no path, relative path, absolute path.

I'm going to test this on Windows before closing ;-)


Resolving patch:
diff --git a/spyderlib/utils/help/sphinxify.py b/spyderlib/utils/help/sphinxify.py
--- a/spyderlib/utils/help/sphinxify.py
+++ b/spyderlib/utils/help/sphinxify.py
@@ -109,12 +109,17 @@ def generate_context(name='', argspec='', note='', math=False, collapse=False,
         plain text.
     collapse : bool
         Collapse sections
-    
+    img_path : str
+        Path for images relative to the file containing the docstring
+
     Returns
     -------
     A dict of strings to be used by Jinja to generate the webpage
     """
-    
+
+    if img_path and os.name == 'nt':
+        img_path = img_path.replace('\\', '/')
+
     context = \
     {
       # Arg dependent variables


Test patch: