Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize module name for Sphinx

I am a newbie as far as Sphinx is concern. My project structure is as follow:

  • argparse_actions/
    • argparse_actions/
      • __init__.py
      • folder_actions.py
      • ip_actions.py
    • doc/
      • _build/
      • index.rst ==> This is the starting point, home page, or root doc.
      • and more...

__init__.py looks like this:

from folder_actions import *
from ip_actions import *

folder_actions.py looks like this:

'''
Folder Actions
==============

This module implements some reusable custom actions.

.. autoclass:: FolderExistsAction
.. autoclass:: FolderCreateAction
   :members:

'''

# The rest of the code

The generate HTML document looks fine except for this part:

class folder_actions.FolderCreateAction( ... )

I know that the folder_actions module prefix is correct, but I want to change it to use the package name instead, like this:

class argparse_actions.FolderCreateAction( ... )

Is there a way for me to achieve this?

Update

  • The root document is in doc/index.rst
  • If I move the docstring from folder_actions.py to __init__.py, then the doc will look like this:

    class __init__.FolderCreateAction( ... )
    
  • FYI, my project is now on BitBucket

Update 2

I don't know why my changes are not pushed to BitBucket, but that irrelevant. please take a look at the same project, pushed to GitHub. I appreciate your help, mzjn.

like image 984
Hai Vu Avatar asked Jun 13 '13 02:06

Hai Vu


1 Answers

After a few months of hiatus, I finally figured out the solution: by adding the following line to the docstring of folder_actions.py and ip_action.py modules:

.. module:: argparse_actions

Preferably, this line should be the first line of the module docstring.

like image 150
Hai Vu Avatar answered Oct 30 '22 06:10

Hai Vu