11

I'm sure this is user error at one level or another but I'm going mad slowly here and would really appreciate some help.

I've gotten both sphinx-apidoc and the excellent third party sphinx-autoapi to work, but can't repeat the trick with sphinx.ext.autosummary. It's driving me mad... plus neither of these options give you the really neat package/module member summary tables that are (presumably) the main selling point of sphinx.ext.autosummary.

I have a really simple project:

|_ TEST
   |_ docs
      |_ conf.py
      |_ index.rst
   |_ myproject
      |_ __init__.py
      |_ mymodule.py

conf.py looks like this:

import os
import sys
sys.path.insert(0, os.path.abspath('../../myproject'))

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.autosummary'
]

autosummary_generate = True

index.rst looks like this:

.. autosummary::
   :toctree: _autosummary

   myproject.mymodule

mymodule.py looks like this:

"""
Module containing a class and a function.
"""

class TestClass:
    """
    A class representing a test.

    I wish I could get this to stuff to show up but I can't and I don't know why.

    Why isn't this documentation visible?!? :-(
    """
    def __init__(self):
        """
        Instantiate.
        """
        pass

    def Func_in_test_class(self):
        """
        Cool function that does stuff.

        :return: Some new stuff.
        """
        pass

def GlobalFunc():
    """
    Utility function.

    Does some good stuff.
    """
    pass

Running make html from the docs directory makes this lovely Readthedocs-style HTML:

(see picture)

What I want to do is click on the TestClass function in the summary table and visit a new page that shows the API documentation for this class in full. How can I achieve that?

(Or am I missing the point, and I have to combine sphinx.ext.autosummary with sphinx-apidoc to get what I need..?)

bad_coder
  • 11,289
  • 20
  • 44
  • 72
James Leedham
  • 2,064
  • 1
  • 10
  • 11
  • 1
    If your project really is that simple, I wonder if it wouldn't be easier to just create the needed RST markup "by hand" instead of using sphinx-apidoc. Maybe this is what you want: https://stackoverflow.com/a/14621772/407651 – mzjn May 03 '20 at 15:25

1 Answers1

4

From Sphinx version 3.1 (June 2020), sphinx.ext.autosummary finally has recursion!

I've answered my own question here: https://stackoverflow.com/a/62613202/12014259

James Leedham
  • 2,064
  • 1
  • 10
  • 11
  • It seems as though python 2.7 is only supported up to Sphinx 1.8.6, which means it does not support recursion. – Tjaart Jul 02 '20 at 15:28