繁体   English   中英

Sphinx并未记录所有类

[英]Sphinx does not document all classes

我正在尝试将Sphinx用于我的文档。 令人惊讶的是,它与某些类和模块一起工作,而对某些类和模块则不工作。

在下面,您可以找到源文件和.rst文件,其中sphinx没有添加该类。

我使用Sphinx'sphinx.ext.autodoc'扩展名。

为什么Sphinx不将我的课程添加到文档中? 在这种情况下如何调试Sphinx?

我的Sphinx文件:my_project.analyzers.content_ascii.rst

my_project.analyzers.content_ascii package
==========================================

Submodules
----------

my_project.analyzers.content_ascii.wl_redo_detect_date module
--------------------------------------------------------------

.. automodule:: my_project.analyzers.content_ascii.wl_redo_detect_date
    :members:
    :undoc-members:
    :show-inheritance:


Module contents
---------------

.. automodule:: my_project.analyzers.content_ascii
    :members:
    :undoc-members:
    :show-inheritance:

代码文件:__init__.py

#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Created on Jan 24, 2014

@author: me
'''

from some_other_project.file_tools import execute_string    
from my_project.analyzers import Analyzer    
from other_project.handler.Handler import Handler

TARGET_ENCODING = 'utf-8'

class ExtractContentAscii(Analyzer):
    '''

    Further improvements: do this and that.
    '''

    def __init__(self):
        Analyzer.__init__(self)

# ...

我意识到Sphinx需要所有依赖项才能创建文档。 不仅是工作区中的所有其他项目。 甚至在celerydjango类的路径上也需要外部项目。

为了解决该问题:

1)将所有依赖项从您的工作区添加到您的路径,例如在您的Sphinx的config.py

import os
import sys

def add_to_path():

    partial_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../')
    workspace_path = os.path.abspath(partial_path)
    assert os.path.exists(workspace_path)

    projects = []

    for current, dirs, c in os.walk(str(workspace_path)):
        for dir in dirs:

            project_path = os.path.join(workspace_path, dir, 'src')

            if os.path.exists(project_path):
                projects.append(project_path)

    for project_str in projects:
        sys.path.append(project_str)

add_to_path()

2)检查系统上是否已安装所有必需的外部依赖项。 处理这些依赖关系的一种好方法是distutilssetup.py文件。

3)建立文件

> make clean; make html;

现在,所有文件都应由Sphinx正确记录。

添加这个元素对我来说至关重要:

:显示继承

没有这个,我有两个没有选择任何类的模块,还有其他三个似乎是随机类的模块。

暂无
暂无

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

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