2

Sphinxを使用してPythonプロジェクトのドキュメントを自動的に生成しようとしています。モジュールの1つにscipy.signalパッケージが必要です。これは、次を使用してインポートしようとしています。scipy.signalをsignalとしてインポートします。コードは問題なく実行されますが、Sphinxでhtmlを作成すると、セグメンテーション違反が発生します(以下の出力)。ただし、「import scipy as sp」を使用して、sys.pathにscipyディレクトリを配置すると、ドキュメントが問題なく生成されますが、もちろん、コードにそのような機能はありません。必要。

問題を実証するために非常に単純なテストケースを作成し、いくつかのdocstringを使用してテストクラスを作成しました。私はそれを私の.rstと一緒に以下に含めています。「importscipy.signalassignal」という行をコメントアウトすると、すべてが非常にうまく機能します。

scipy.signalをインポートしながら、segの障害を回避する方法についての洞察に感謝します。ローレン

Sphinx出力:

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:
4

0 に答える 0