警告:autodoc:无法导入模块' upload_data_to_server'来自模块'手册';

发布于 2025-01-28 10:29:22 字数 1734 浏览 1 评论 0原文

我正在尝试使用Sphinx的AutoDoc扩展名来记录Django项目。我有两个主要问题:

  1. 它记录了一些模块中的多余问题(我不想从django导入文档),
  2. 它根本没有记录其中一个软件包。

这是我的django树:

|main_app
|   core
|      migrations
|      static
|      templates
|      consumers.py
|      forms.py
|      models.py
|      routing.py
|      serializers.py
|      urls.py
|      views.py
|   main_app
|      asgi.py
|      settings.py
|      urls.py
|      wsgi.py
|   manual
|      upload_data_to_server.py
|   manage.py
|   docs
|      _build
|      _static
|      _templates
|      conf.py
|      index.rst
|      make.bat
|      Makefile

DOCS文件是我创建的文件,该文件是为了托管sphinx-QuickStart创建的文件。然后,我更改了conf.py添加此行的文件:

import os
import sys
import django
sys.path.insert(0, os.path.abspath('..'))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main_app.settings")
django.setup()


extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon']

然后我更改了index.rst添加模块

Welcome to yourProject's documentation!
====================================

.. toctree::
   :maxdepth: 2
   :caption: Contents:

   modules


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

我执行了sphinx-- apidoc -o。 .../进行HTML。我得到的是类似于我想要的东西,但是正如我之前所说的,我对Django文件有太多评论,而对手册软件包根本没有评论。 我正在将此手册包用于Django之外的内容,例如将某些数据从某些Excel上传到服务器上的数据库。因此,它不会遵循Django设置。但是如何将其指定为狮身人面像?当./做html

WARNING: autodoc: failed to import module 'upload_data_to_server' from module 'manual';

我是否需要在conf.py中添加一些新路径?

另一方面,如何手动“清洁”或编辑由AutoDoc创建的评论?

I'm trying to document a Django project using Sphinx's autodoc extension. I have two main problems:

  1. It's documenting excessivelly in some modules (importing documentation that I don't want from django)
  2. It's not documenting one of the packages at all.

Here is my django tree:

|main_app
|   core
|      migrations
|      static
|      templates
|      consumers.py
|      forms.py
|      models.py
|      routing.py
|      serializers.py
|      urls.py
|      views.py
|   main_app
|      asgi.py
|      settings.py
|      urls.py
|      wsgi.py
|   manual
|      upload_data_to_server.py
|   manage.py
|   docs
|      _build
|      _static
|      _templates
|      conf.py
|      index.rst
|      make.bat
|      Makefile

The docs file is the one I created to host the files created by sphinx-quickstart. Then, I changed the conf.py file adding this lines:

import os
import sys
import django
sys.path.insert(0, os.path.abspath('..'))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main_app.settings")
django.setup()


extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon']

And I changed index.rst adding modules:

Welcome to yourProject's documentation!
====================================

.. toctree::
   :maxdepth: 2
   :caption: Contents:

   modules


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

I executed sphinx-apidoc -o . .. and ./make html. I get something similar to what I want, but as I said before, I get too many comments for django files, and no comments at all for the manual package.
I'm using this manual package for things outside of django, like uploading some data from some excel to a database on a server. So it does not follow django settings. But how can I specify this to sphinx? I get this error when ./make html:

WARNING: autodoc: failed to import module 'upload_data_to_server' from module 'manual';

Do I need to add some new path into conf.py?

In the other hand, how can I 'clean' or edit the comments created by autodoc manually?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文