Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python sphinx警告:自动摘要:找不到类的方法的存根文件。检查您的自动摘要生成设置_Python_Python Sphinx_Numpydoc_Sphinx Napoleon - Fatal编程技术网

Python sphinx警告:自动摘要:找不到类的方法的存根文件。检查您的自动摘要生成设置

Python sphinx警告:自动摘要:找不到类的方法的存根文件。检查您的自动摘要生成设置,python,python-sphinx,numpydoc,sphinx-napoleon,Python,Python Sphinx,Numpydoc,Sphinx Napoleon,我有一个开源软件包,其中有许多不同子模块上的类。所有类都有方法fit和transform,并从sklearn继承fit\u transform。所有类都有docstring,这些docstring跟在numpydoc后面,带有副标题参数、属性、注释、另请参见和方法,其中我列出了fit、transform和fit\u transform。我复制了一个类的示例: class DropFeatures(BaseEstimator, TransformerMixin): ""

我有一个开源软件包,其中有许多不同子模块上的类。所有类都有方法
fit
transform
,并从sklearn继承
fit\u transform
。所有类都有docstring,这些docstring跟在numpydoc后面,带有副标题参数、属性、注释、另请参见和方法,其中我列出了
fit
transform
fit\u transform
。我复制了一个类的示例:

class DropFeatures(BaseEstimator, TransformerMixin):
    """
    Some description.

    Parameters
    ----------
    features_to_drop : str or list, default=None
        Variable(s) to be dropped from the dataframe

    Methods
    -------
    fit
    transform
    fit_transform
    """

    def __init__(self, features_to_drop: List[Union[str, int]]):

        some init parameters

    def fit(self, X: pd.DataFrame, y: pd.Series = None):
        """
        This transformer does not learn any parameter.

        Verifies that the input X is a pandas dataframe, and that the variables to
        drop exist in the training dataframe.

        Parameters
        ----------
        X : pandas dataframe of shape = [n_samples, n_features]
            The input dataframe
        y : pandas Series, default = None
            y is not needed for this transformer. You can pass y or None.

        Returns
        -------
        self
        """
        some functionality

        return self

    def transform(self, X: pd.DataFrame):
        """
        Drop the variable or list of variables from the dataframe.

        Parameters
        ----------
        X : pandas dataframe
            The input dataframe from which features will be dropped

        Returns
        -------
        X_transformed : pandas dataframe,
            shape = [n_samples, n_features - len(features_to_drop)]
            The transformed dataframe with the remaining subset of variables.

        """

        some more functionality

        return X
在Sphinx的conf.py中,我包括:

extensions = [
    "sphinx.ext.autodoc",  # Core Sphinx library for auto html doc generation from docstrings
    "sphinx.ext.autosummary",  # Create neat summary tables for modules/classes/methods etc
    "sphinx.ext.intersphinx",  # Link to other project's documentation (see mapping below)
    "sphinx_autodoc_typehints",  # Automatically document param types (less noise in class signature)
    "numpydoc",
    "sphinx.ext.linkcode",
] 


numpydoc_show_class_members = False


# generate autosummary even if no references
autosummary_generate = True
autosummary_imported_members = True
当我使用
sphinx build-b html docs build
构建文档时,文档构建得非常好,但是我每个类收到3个警告,每个方法一个警告,即:

warning: autosummary: stub file not found for the methods of the class. check your autosummary_generate settings
我已经用尽了所有的搜索资源,我准备放弃。是否有人知道如何防止该警告或如何使斯芬克斯不打印到控制台

我附上一份错误副本,如果需要,我可以提供一个到回购的PR链接


好的,三天后,我把它钉好了。秘诀是在docstring中的标题“methods”之后添加一个简短的方法描述,而不是像我那样将它们留空

因此:


在我的情况下,以下添加到
doc
文件夹中的
setup.py
删除了警告:

numpydoc_show_class_members = False 

添加方法将方法限制为固定列表,这不是我想要的行为。

不是解释,但作为一个实验,您可以尝试使用Napoleon扩展而不是Numpydoc。再见,谢谢。事实上,我用的是拿破仑,换成了纽皮多克,因为我觉得它的显示效果更好。你喜欢拿破仑吗?我不知道我是不是更喜欢一个分机。关于审判拿破仑的建议是“在黑暗中开了一枪”。Napoleon也有同样的警告吗?我在fit和transform方法上得到了不同的警告:“警告:复制对象描述[…]模块/类中的其他实例use:noindex:用于其中一个”。它也会出错,因为我在init docstring中描述了fit方法的一个属性,numpydoc似乎可以使用,但napoleon没有。这确实非常有用,因为自动文档的一个目标是尽可能减少静态或硬编码特性
numpydoc_show_class_members = False