html sphinx 创建的文件没有任何文档
html file created by sphinx does not have any documentation
我以前在这里看到过这个问题,例如here, or , or the most useful here。但我相信我的问题与他们的不同,或者我做错了什么。
我的 python 文件 hello_world
是:
import numpy as np
"""
This is the header
"""
def say_hi(name):
"""
This is just a test
:param param1: this is the name
:returns returns the name entered
"""
print(name)
return None
我在 运行 sphinx-quickstart
中创建了一个文件夹 docs
。我得到 conf.py
和 index.rst
,我将其更改为:
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
# -- Project information -----------------------------------------------------
project = 'project'
copyright = '2021, lol'
author = 'lol'
# The full version, including alpha/beta/rc tags
release = '0.0.1'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
所以,我告诉 sphinx 要寻找的路径。我按照 this 教程中的指示将行 modules
添加到 index.rst
。因此,该文件如下所示:
.. project documentation master file, created by
sphinx-quickstart on Mon Jul 19 21:46:14 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to project's documentation!
===================================
.. toctree::
:maxdepth: 2
:caption: Contents:
modules
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
然后,我运行sphinx-apidoc -o . ..
,最后make html
。
该进程生成一个 html 文件,但它没有任何文档 image
有谁知道如何解决这个问题?或者有人知道实际有效的教程吗?谢谢!
编辑*
Sphinx 在 运行ning make html
时输出警告:WARNING: Unknown directive type "automodule"
。我用谷歌搜索并找到了这个 https://cloud.tencent.com/developer/ask/111346 。将 extensions = ['sphinx.ext.autodoc']
包含到 index.rst 文件后,它输出:
image2
虽然我的格式似乎有问题,但那是另一个问题。
这种情况下的解决方案是将 extensions = ['sphinx.ext.autodoc']
添加到 conf.py
文件。
我以前在这里看到过这个问题,例如here, or
我的 python 文件 hello_world
是:
import numpy as np
"""
This is the header
"""
def say_hi(name):
"""
This is just a test
:param param1: this is the name
:returns returns the name entered
"""
print(name)
return None
我在 运行 sphinx-quickstart
中创建了一个文件夹 docs
。我得到 conf.py
和 index.rst
,我将其更改为:
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
# -- Project information -----------------------------------------------------
project = 'project'
copyright = '2021, lol'
author = 'lol'
# The full version, including alpha/beta/rc tags
release = '0.0.1'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
所以,我告诉 sphinx 要寻找的路径。我按照 this 教程中的指示将行 modules
添加到 index.rst
。因此,该文件如下所示:
.. project documentation master file, created by
sphinx-quickstart on Mon Jul 19 21:46:14 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to project's documentation!
===================================
.. toctree::
:maxdepth: 2
:caption: Contents:
modules
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
然后,我运行sphinx-apidoc -o . ..
,最后make html
。
该进程生成一个 html 文件,但它没有任何文档 image
有谁知道如何解决这个问题?或者有人知道实际有效的教程吗?谢谢!
编辑*
Sphinx 在 运行ning make html
时输出警告:WARNING: Unknown directive type "automodule"
。我用谷歌搜索并找到了这个 https://cloud.tencent.com/developer/ask/111346 。将 extensions = ['sphinx.ext.autodoc']
包含到 index.rst 文件后,它输出:
image2
虽然我的格式似乎有问题,但那是另一个问题。
这种情况下的解决方案是将 extensions = ['sphinx.ext.autodoc']
添加到 conf.py
文件。