简体   繁体   English

使用 Sphinx 的 sphinx-apidoc 实用程序从 python 代码自动生成文档

[英]using Sphinx's sphinx-apidoc utility to autogenerate documentation from python code

I am wondering what the commenting format is in order to have self-documenting code using Sphinx's sphinx-apidoc utility.我想知道注释格式是什么,以便使用 Sphinx 的 sphinx-apidoc 实用程序进行自记录代码。 I am able to get this utility to generate a set of reStructuredText files for each python file, but these files still need to be filled in. I am looking for a way to get this utility, or some other Sphinx utility to generate documentation from the python codes docstrings.我能够使用此实用程序为每个 python 文件生成一组 reStructuredText 文件,但仍需要填写这些文件。我正在寻找获取此实用程序或其他一些 Sphinx 实用程序以从python 代码文档字符串。 I understand this would require becoming familiar with a conventional commenting format, and I am hoping to be pointed to this reference material.我知道这需要熟悉传统的评论格式,我希望有人指出这个参考资料。 Thanks!谢谢!

mzjn, thanks for the comment. mzjn,感谢您的评论。 your second link provided some good insight on how to format docstrings .您的第二个链接提供了有关如何格式化docstrings 的一些很好的见解。

furthermore, i failed to mark the proper sphinx-quickstart prompt answers (as specified in the link, http://pythonhosted.org/an_example_pypi_project/sphinx.html#full-code-example ).此外,我未能标记正确的sphinx-quickstart提示答案(如链接中所述, http://pythonhosted.org/an_example_pypi_project/sphinx.html#full-code-example )。 particularly, answering yes to:特别是,回答

autodoc: automatically insert docstrings from modules (y/N) [n]: autodoc:从模块中自动插入文档字符串 (y/N) [n]:

also, as noted in the link, http://codeandchaos.wordpress.com/2012/07/30/sphinx-autodoc-tutorial-for-dummies/ , and the conf.py comments, i needed to append locations of modules to the system path.此外,如链接中所述, http: //codeandchaos.wordpress.com/2012/07/30/sphinx-autodoc-tutorial-for-dummies/conf.py注释,我需要将模块的位置附加到系统路径。 i should note that i ran into a problem appending filenames.我应该注意,我遇到了附加文件名的问题。 when i appended paths where modules could be found, everything worked perfectly.当我附加可以找到模块的路径时,一切都运行良好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM