Sphinx: autosummary document imported functions

Created on 3 Jan 2015  路  15Comments  路  Source: sphinx-doc/sphinx

Hello,

I'm looking for a way to exclude imported modules and functions.

The attached examples list isfile in functions of my module.


autodoc enhancement low

Most helpful comment

Maybe I'm missing something but I believe that this is still an issue, at least for my configuration. I'm using sphinx 1.4.1 and autosummary_generate = True. Here are the links to my conf.py, top level autosummary, the template that includes additional autosummary calls, and a sample page with the unwanted imported documentation (the sind, cosd, and Location are all imported).

The change suggested by this SO answer worked for me.

Thanks in advance, and apologies if I am in fact missing something.

All 15 comments

_From Takayuki Shimizukawa on 2013-01-20 02:12:50+00:00_

I can not reproduce autodocing for imported modules and functions.

Please let me know about your 'autodoc' relative directive using in rst file.

_From Tiago Coutinho on 2013-10-10 09:15:55+00:00_

Hello,
I am using sphinx 1.1.3 to document my python project. I can confirm the bug.

I was preparing a bug report when I saw this one. I post my original report with the hope that it can help solve the bug:

I am using autosummary with autosummary_generate = True in the conf.py

The autosummary is generating documentation for functions/classes which are imported from another module.
Example:

#!python

# --- module1.py ----
def foo():
    """foo documentation"""
    pass

# --- module2.py ---
from module1 import foo
def bar():
    """bar documentation"""
    foo()

and the following RST:

#!rst

.. doc.rst

Documentation
============

.. autosummary::
   :toctree:

   module2

will generate a RST like:

#!rst

module2
=======

.. automodule:: module2

   .. rubric:: Functions

   .. autosummary::

      foo
      bar

Please don't hesitate to ask for more info if needed.
Thanks,
Tiago

_From samuele_c on 2014-03-05 00:02:35+00:00_

I'm having the exact same issue in Debian stable and Debian testing. Calling

.. autosummary:: 
   :toctree: _autosummary

includes functions imported from other modules in the summary table

_From mzjn on 2014-08-23 17:44:07+00:00_

A patch has been suggested at Stack Overflow: http://stackoverflow.com/a/25460763

_From Takayuki Shimizukawa on 2014-08-29 01:53:58+00:00_

We need a :imported: True option for autosummary (I think False is better for default).

It's a new feature and a incompatible change.

_From Takayuki Shimizukawa on 2014-12-19 03:41:29+00:00_

Issue #1654 was marked as a duplicate of this issue.

_From Luc Saffre on 2014-12-19 04:10:55+00:00_

Yes, they are the same issues.

Unfortunately the fix for this issue in 3313276 broke some things for us in Astropy, because now the call to documenter.check_module() is used indiscriminately, whereas we _want_ to document imported objects (because we want to document objects in the top-level namespace they're imported to, and not in the submodules they are defined in, in many cases.

This should at least be optional. I like the suggestion @shimizukawa made of an :imported: True option.

from what I understood, this change was a backward-incompatible commit preventing imported modules to be included in the toctree.

It seems this problem is still not fixed?

PR #1663 closes this issue. @birkenfeld please take a look if you have chance.

It looks like 1.3.2 already restored the desired behavior.

Maybe I'm missing something but I believe that this is still an issue, at least for my configuration. I'm using sphinx 1.4.1 and autosummary_generate = True. Here are the links to my conf.py, top level autosummary, the template that includes additional autosummary calls, and a sample page with the unwanted imported documentation (the sind, cosd, and Location are all imported).

The change suggested by this SO answer worked for me.

Thanks in advance, and apologies if I am in fact missing something.

Reopen to investigation

Fixed by #3235.

Was this page helpful?
0 / 5 - 0 ratings