How to generate Python documentation using Sphinx with zero configuration?

后端 未结 1 1326
旧时难觅i
旧时难觅i 2021-02-04 05:46

We don\'t want to be maintaining documentation as well as the source code, which is evolving rapidly at the moment, yet Sphinx seems to require a frustrating amount of setup and

1条回答
  •  我在风中等你
    2021-02-04 06:24

    The sphinx-apidoc tool will autogenerate stubs for your modules, which might be what you want.

    Instructions

    • Make sure the autodoc module was enabled during Sphinx configuration.

      extensions = ['sphinx.ext.autodoc']
      

      within Sphinx's conf.py should do the trick.

    • Make sure conf.py adjusts sys.path accordingly (see the comments at lines 16-19 in the file).

      sys.path.insert(0, os.path.abspath('/my/source/lives/here'))
      
    • Run sphinx-apidoc to generate skeletons.

      sphinx-apidoc -o /my/docs/live/here /my/source/lives/here
      
    • Rebuild the docs. If all goes well, you shouldn't get the following sort of warning:

      mymodule.rst:4: WARNING: autodoc can't import/find module 'mymodule'

    • Your module RSTs should now be populated.

    0 讨论(0)
提交回复
热议问题