Is it possible to generate a TOC tree from my PHP domain?

229 views Asked by At

So I am writing a PHP documentation for my library. I am using the "sphinxcontrib.phpdomain" extension in order to support the PHP domain.

Let's say I have defined the following document:

.. toctree::
    :numbered:
    :maxdepth: 3
    :caption: Couch

.. php:class:: Couch

    This is the low-level class that handles communications with CouchDB.

    .. php:method:: dsn()

        :returns: The dsn of the current Couch instance

Is it possible to generate a TOC tree from this? For example, I would like to index in the tree the class names and the classes members.

For the moment, only custom titles are indexed in the toctree

1

There are 1 answers

1
Steve Piercy On

Split your reStructuredText example into two files. The toctree directive should be in the index.rst file of your documentation, and the php:class directive should be in a separate file. It would be wise to name such a file according to the name of the class, e.g., couch.rst. That will at least give you the top level TOC.

I don't know whether sphinxcontrib.phpdomain supports TOC entries other than simple reStructuredText file names and headings within the files. Assuming sphinxcontrib.phpdomain does not provide the TOC depth you desire, you can try inserting arbitrary headings.

In Python, we have autodoc which automatically documents Python code, but I have no clue whether it works with PHP code. Otherwise there may be some package for PHP as autodoc is for Python.