我有一个 git 存储库,其中包含多个遵循命名空间的包(即PEP 420。
我正在尝试使用 Sphinx 创建 ReadTheDocs 文档。
git 存储库看起来像这个 repo:https ://github.com/pypa/sample-namespace-packages
为了在我的本地机器上进行测试,我使用了 Sphinx 的 docker image sphinxdoc/sphinx
。
我尝试使用不同的方法为我的所有包生成文档,但每种方法最终都会遇到不同的问题。
狮身人面像-apidoc
docker run -it -v
密码:/repo --rm rtd bash -c 'make clean && rm -rf /repo/docs/_source/* && sphinx-apidoc -F -o /repo/docs/_source /repo && make html'
这样做的问题是它会生成错误的包,因为sphinx-apidoc
它使用子文件夹来生成包,这是错误的。这最终会pkg_resourcespkg_a.example_pkg.a
是不存在的,实际上应该是example_pkg.a
autoapi.extension
# conf.py
def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package, "--no-deps"])
rootfolder=os.path.abspath('../')
add_module_names = False
autoapi_dirs = []
pathlist = Path(rootfolder).glob('repo-*/repo/*/')
for path in pathlist:
path_in_str = str(path)
autoapi_dirs.append(path_in_str)
print(path_in_str)
...
...
extensions = [
'sphinx.ext.napoleon',
'sphinx.ext.autosummary',
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.coverage',
'autoapi.extension',
'sphinx_rtd_theme',
]
autoapi_type = 'python'
autodoc_mock_imports = [
'tensorflow',
'flask',
'numpy',
'plotly',
'tqdm',
'StringIO',
'lime',
'vis',
'efficientnet_pytorch',
'pycocotools',
'repo.trainer.self_trainer_model',
'theano',
'sklearn',
'torch',
'telegram',
'msvcrt',
'bs4',
'livereload',
'repo.common.config',
'plotting_server',
'experiments',
'cropper',
"anytree",
"skimage"
]
我也试过这个,但不幸的是,这最终没有在 HTML 中显示任何关于我的包的信息,同时还抛出以下警告:
/repo/docs/autoapi/repo/data/characteristics/detection/kmeanboxes/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repo/data/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repo/data_structure/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repo/detection/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repo/generators/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repo/inference/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repo/mine/repo_eye_naveyaar/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repo/mine/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repo/mine/miner_vieweryoungweedscropped/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repo/trainer/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repo/utils/dataset_specific/repoeyeweedsbackgrounds/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repo/utils/dataset_specific/repoeyeweedslabdetection/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repo/utils/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repocommon/repo/common/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repodatasets/repo/data_sets/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repometrics/repo/metrics/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repomodels/repo/models/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/repooptimizers/repo/optimizers/index.rst: WARNING: document isn't included in any toctree
/repo/docs/autoapi/index.rst: WARNING: document isn't included in any toctree
所以,我的问题是是否可以使用 sphinx-apidoc 在同一个 git 存储库中为多个包创建文档?