我如何“将scipy.signal导入为信号”仍然使用python sphinx autodoc?

时间:2011-01-03 02:36:32

标签: python python-sphinx

我正在尝试使用Sphinx自动生成python项目的文档。其中一个模块需要scipy.signal包,我尝试使用以下方法导入:import scipy.signal as signal。虽然代码运行得很好,但使用Sphinx制作html会导致分段错误(下面的输出)。但是,我可以使用“import scipy as sp”,确保将scipy目录放在我的sys.path中,文档生成没有任何问题,但当然,我的代码中没有我的功能需要。

我做了一个非常简单的测试用例来演示这个问题,用一些docstrings创建一个测试类。我和我的.rst一起在下面提到它。在评论“将scipy.signal导入为信号”这一行时,一切都运行良好。

感谢您在导入scipy.signal时如何避免seg faulting的任何见解。 劳伦

狮身人面像输出:

sphinx-build -b html -d _build/doctrees   . _build/html
Running Sphinx v1.0.5
loading pickled environment... done
building [html]: targets for 1 source files that are out of date
updating environment: 0 added, 1 changed, 0 removed
make: *** [html] Segmentation faults 

pyexample.py

import scipy.signal as signal

class TestClass:
    """The TestClass class is used to lalala. I would like this docstring to be     documented by sphinx.
    """

    def __init__(self, A, B):
        self.A = A
        self.B = B

    # Style to use for printing
    def __str__(self):
        str =  "A = " + self.A.__str__() + "\n\n"
        str += "B = " + self.B.__str__() + "\n\n"
        return str

    def __add__(self):
        """Add A+B."""
        total = self.A+self.B
        return total

    def addx(self,x):
        """Add A+x."""
        total = self.A+x
        return total

index.rst

.. Test documentation master file, created by
   sphinx-quickstart on Sun Jan  2 20:34:04 2011.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

Welcome to Test's documentation!
================================

Contents:

.. toctree::

   docstrings

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

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

docstrings.rst

My Modules and Functions
************************************
Here are some modules.

The pyexample Module
======================
.. automodule:: pyexample

.. autoclass:: pyexample.TestClass
   :members:

0 个答案:

没有答案