sphinx-autogen always generates autodata

Jakub Wilk avatarJakub Wilk created an issue

It looks like in 1.0.7 sphinx-autogen always generates autodata directives, no matter what. E.g. for

.. currentmodule:: os

.. autosummary::
   :toctree: autogen/


it generated


.. currentmodule:: os

.. autodata:: dup

With Sphinx 1.0.6 everything was OK.

Comments (7)

  1. Chad Dombrova

    i was just having a look at this. i wish i had seen that it was ok in 1.0.6 because i would have saved myself a lot of time, but hey, now you get this handy patch.

    The problems are:

    • ModuleDocumenter.can_document_member() always returns false, so the autosummary/module.rst template is never used
    • all the Documenter classes that use the "parent" argument of can_document_member are expecting it to be either a Documenter instance or Documenter class, and yet generate.generate_autosummary_docs is passing it the parent of the python object being documented. this causes, for example, a function to get a MethodDocumenter instead of a FunctionDocumenter.
    • last but not least, the Sphinx class never gets instantiated when running sphinx-autogen, meaning that autodoc.setup() is never run so there aren't actually any registered Documenters. meaning it's pretty much useless.

    seriously, i love what sphinx does, but everytime i use it i cross my fingers. time to beef up those doctests.

    anyway, hope this patch helps. i couldn't fix the last part because it will require some serious hacking. i just used sphinx-build with the autosummary_generate option to get around it.

    the patch applies to 1.0.7

    oh, it has a change regarding metaclasses in it too, but i'm too lazy to split it at the moment. the key thing is to notice the following difference


    get_documenter(getattr(obj, name), obj).objtype == typ


    get_documenter(getattr(obj, name), doc).objtype == typ

    in the new one the documenter class is passed instead of the object being documented.

  2. Jakub Wilk

    Chad, regarding your patch: Why is it is_document_type(parent, ModuleDocumenter) in a few places, but issubclass(parent, ModuleDocumenter) in AttributeDocumenter?

  3. Jakub Wilk
    • changed status to new

    Am I correct the the underlying problems were fixed and the only thing that still does't work is the sphinx-autogen script itself? At least with Sphinx 1.1 _and_ my patch applied I seem to be getting correct results.

  4. Evgeny Prilepin

    I ran into the same problem.

    I want to use the function "generate_autosummary_docs" from sphinx.ext.autosummary.generate, but without initialize sphinx application.

    I just added the following code and it works:

    from sphinx.ext.autosummary import generate
    from sphinx.ext.autodoc import *
    # Add documenters to AutoDerective registry

    Please, fix this bug in sphinx sources.

  5. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.