0

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

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Alexis Côté
  • 3,670
  • 2
  • 14
  • 30

1 Answers1

0

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.

Steve Piercy
  • 13,693
  • 1
  • 44
  • 57
  • The only PHP autodoc package that I found was outdated. For this reason, I decided to write the documentation manually. I found a temporary way of indexing my class and methods. I made a custom directly that define hidden headers. Those headers are hidden in the page but they are shows in the toc tree. – Alexis Côté Sep 09 '17 at 18:30