Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate html documents from docstring

I have a Python project, and wrote many docstring in functions,

how to convert those docstring into html documentation in one or two steps,

I just want the Sphinx can act as doxygen, just convert all my comments or doctring into html documentation.

I run the sphinx-quickstart under the docs folder

then

> autodoc: automatically insert docstrings from modules (y/n) [n]: y

then modified the conf.py long_term_streaming_monitor/docs/source/conf.py

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

Because all of my source code are put under long_term_streaming_monitor/src

The generated code is here download

I followed the tutorial, but when I opened the index.html I got nothing, no module and methods listed on the html file link

.
├── docs
│   ├── _build
│   │   ├── doctrees
│   │   └── html
│   │       ├── _sources
│   │       └── _static
│   ├── _static
│   ├── _templates
│   └── html
└── src
    ├── long_term_streaming_monitor
    │   ├── log
    │   ├── scripts
    │   └── tests
    │       └── log
    └── long_term_streaming_monitor_.egg-info
like image 845
newBike Avatar asked Mar 24 '14 04:03

newBike


1 Answers

As mentioned in one of the comments you can use sphinx.ext.autodoc

More steps on quickstart here.
Check a example configuration file here
Bonus - you can also integrate Travis with sphinx using travis-sphinx to autogenerate your github pages each time you push a code with new docstrings.

like image 178
markroxor Avatar answered Oct 03 '22 09:10

markroxor