<p>我有一个开源软件包,其中有许多不同子模块上的类。所有类都有方法<code>fit</code>和<code>transform</code>,并从sklearn继承<code>fit_transform</code>。所有类都有docstring,这些docstring跟在numpydoc后面,带有副标题参数、属性、注释、See和方法,其中我列出了<code>fit</code>、<code>transform</code>和<code>fit_transform</code>。我复制了一个类的示例:</p>
<pre><code>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
</code></pre>
<p>在Sphinx的conf.py中,我包括:</p>
<pre><code>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
</code></pre>
<p>当我使用<code>sphinx-build -b html docs build</code>构建文档时,文档构建得非常好,但是我每个类得到3个警告,每个方法一个警告,即:</p>
<pre><code>warning: autosummary: stub file not found for the methods of the class. check your autosummary_generate settings
</code></pre>
<p>我已经用尽了所有的搜索资源,我准备放弃。是否有人知道如何防止该警告或如何使斯芬克斯不打印到控制台</p>
<p>我附上一份错误副本,如果需要,我可以提供一个到回购的PR链接</p>
<p><img src="https://i.stack.imgur.com/YH7xl.png" alt="enter image description here"/></p>