Including source in Sphinx documentation
I am trying to use Sphinx to document a Python project of mine, but I am struggl开发者_StackOverflow中文版ing with the differences between this tool and the usual tools like JavaDoc which are meant to document an API. Of course I see that Sphinx has many more uses than documenting an API, but it seems to be lacking in the simpler task.
I have managed to find out how to let Sphinx know about your package structure, so that you do not have to manually replicate it into ReST files. My next problem is:
Is it possible to include a link to the source for all classes with Sphinx?
Of course the source should be nicely formatted, but since Sphinx uses pygments I don't think that is a problem.
Take a look at sphinx.ext.viewcode.
Include a extension in conf.py.
extensions = ['sphinx.ext.viewcode']
精彩评论