Thanks to visit codestin.com
Credit goes to github.com

Skip to content

No examples file generates for aliases #365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ImportanceOfBeingErnest opened this issue Apr 19, 2018 · 3 comments
Open

No examples file generates for aliases #365

ImportanceOfBeingErnest opened this issue Apr 19, 2018 · 3 comments

Comments

@ImportanceOfBeingErnest

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.

@ImportanceOfBeingErnest
Copy link
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.

@lesteve
Copy link
Member

lesteve commented Apr 20, 2018

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.

@ImportanceOfBeingErnest
Copy link
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
Projects
None yet
Development

No branches or pull requests

2 participants