Skip to content

No examples file generates for aliases #365

Open

Description

It seems sphinx-gallery has a problem with aliases and does not produce any example file for them?

class Foo(object):
    """
    Foo is used for fooing and provides fooing methods
    """

AliasOfFoo = Foo

This would result in an example file Foo.examples being created. But no AliasOfFoo.examples.
However, since Sphinx generates an automodule rst page for both classes the AliasOfFoo.rst tries to include AliasOfFoo.examples via .. include:: AliasOfFoo.examples.
Finally this results in an error

Problems with "include" directive path: 
InputError: No such file or directory: .../AliasOfFoo.examples

This problem occurs in the case of the matplotlib documentation (matplotlib/matplotlib#11079), e.g. mpl_toolkits/axes_grid1/axes_grid.py#L770.

Activity

  1. ImportanceOfBeingErnest commented on Apr 19, 2018

    @ImportanceOfBeingErnest
    Author

    I suppose one can work around by not creating any gallery for those Aliases at all,

    {% if objname not in ['AliasOfFoo', 'OtherAlias', 'NextAlias'] %}
    
    .. include:: {{module}}.{{objname}}.examples
    
    .. raw:: html
    
        <div class="clearer"></div>
    
    {% endif %}
    

    but that is for sure not ideal, because (1) we loose the galleries, (2) we clutter the autosummary template with content specific stuff.

  2. lesteve commented on Apr 20, 2018

    @lesteve
    Member

    Sounds like a bug indeed and I am afraid I don't have any suggestions off the top of my head as how to solve or work around it. A PR fixing this would be welcome!

    I am going to be frank: this is unlikely to be a priority until 0.14 is released.

    If you had time to set-up a reproducible example outside of matplotlib, it would greatly help anyone to work on trying to fix this.

  3. ImportanceOfBeingErnest commented on Apr 20, 2018

    @ImportanceOfBeingErnest
    Author

    I created an example showing the issue. This can be found here: https://github.com/ImportanceOfBeingErnest/sphinx-mwe

    There are two folders, one works just fine, the other contains a line creating an Alias class

    MyClassAlias = MyClass
    

    This will lead to the error being raised

    D:\xyz\abc\dev\sphinx-mwe\sphinx-mwe-bug\doc\source\_as_gen\module.MyClassAlias.rst:12: 
    WARNING: Problems with "include" directive path:
    InputError: [Errno 2] No such file or directory: 'source/_as_gen/module.MyClassAlias.examples'.
    

    I found out that when creating an example which actually uses the MyClassAlias class, this error does not occur. But of course we do not have examples for all those aliases around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions