Sphinx 文档 - 如何隐藏从父 class' 函数继承的函数参数?
Sphinx documentation - How can I hide function parameters inherited from the parent class' function?
我有以下 classes
import abc
class Parent(metaclass=abc.ABCMeta):
def __init__(
self,
username: str,
password: str,
log_file: Optional[str] = None,
secret: Optional[str] = None,
local_directory: Optional[str] = None,
folder_path: Optional[str] = None,
dataset: Optional[str] = None,
table: Optional[str] = None,
columns: Optional[list] = None
) -> None:
"""
:param username: The username or email address of the account used to login to the portal.
:param password: The password of the account used to login to the portal.
:param log_file: The log file that all log statements will be stored in. Defaults to stdout.
:param secret: The secret used to generate valid codes for the account.
:param local_directory: The working directory where files are saved during runtime.
:param folder_path: The folder that the reports will be stored in.
:param dataset: The dataset that will be used to upload the report data to.
:param table: The table inside ``dataset`` that will house the report data.
:param columns: The columns as seen in either the downloaded files (recommended) or ``table``.
"""
pass
class Child(Parent):
def __init__(
self,
username: str,
password: str,
section: str,
context_filter: str = None,
report_folders: list = None,
run_fixed_reports_only: bool = False,
**kwargs
) -> None:
pass
当我尝试为 Child
class 呈现 sphinx 文档时,我最终得到的所有 Parent
class' 参数仍然显示在__init__
.
.. autoclass:: Child
.. automethod:: __init__
除了手动写出 Child
的每个参数之外,是否有一种简单的方法可以从参数列表中省略 Parent
的参数?
编辑: 要包含我收到的最终结果的屏幕截图,其中显示继承字段显示在 Child
参数之前的参数列表下方.
现在我只觉得自己很傻。结果我所要做的就是在其文档字符串中明确指定 Child
的 __init__
参数,如下所示:
class Child(Parent):
def __init__(
self,
username: str,
password: str,
portal: str,
context_filter: str = None,
report_folders: list = None,
run_fixed_reports_only: bool = False,
**kwargs
) -> None:
"""
:param username:
:param password:
:param portal:
:param context_filter:
:param report_folders:
:param run_fixed_reports_only:
:param kwargs: Parameters to pass to the parent class :class:`Parent`.
"""
pass
我有以下 classes
import abc
class Parent(metaclass=abc.ABCMeta):
def __init__(
self,
username: str,
password: str,
log_file: Optional[str] = None,
secret: Optional[str] = None,
local_directory: Optional[str] = None,
folder_path: Optional[str] = None,
dataset: Optional[str] = None,
table: Optional[str] = None,
columns: Optional[list] = None
) -> None:
"""
:param username: The username or email address of the account used to login to the portal.
:param password: The password of the account used to login to the portal.
:param log_file: The log file that all log statements will be stored in. Defaults to stdout.
:param secret: The secret used to generate valid codes for the account.
:param local_directory: The working directory where files are saved during runtime.
:param folder_path: The folder that the reports will be stored in.
:param dataset: The dataset that will be used to upload the report data to.
:param table: The table inside ``dataset`` that will house the report data.
:param columns: The columns as seen in either the downloaded files (recommended) or ``table``.
"""
pass
class Child(Parent):
def __init__(
self,
username: str,
password: str,
section: str,
context_filter: str = None,
report_folders: list = None,
run_fixed_reports_only: bool = False,
**kwargs
) -> None:
pass
当我尝试为 Child
class 呈现 sphinx 文档时,我最终得到的所有 Parent
class' 参数仍然显示在__init__
.
.. autoclass:: Child
.. automethod:: __init__
除了手动写出 Child
的每个参数之外,是否有一种简单的方法可以从参数列表中省略 Parent
的参数?
编辑: 要包含我收到的最终结果的屏幕截图,其中显示继承字段显示在 Child
参数之前的参数列表下方.
现在我只觉得自己很傻。结果我所要做的就是在其文档字符串中明确指定 Child
的 __init__
参数,如下所示:
class Child(Parent):
def __init__(
self,
username: str,
password: str,
portal: str,
context_filter: str = None,
report_folders: list = None,
run_fixed_reports_only: bool = False,
**kwargs
) -> None:
"""
:param username:
:param password:
:param portal:
:param context_filter:
:param report_folders:
:param run_fixed_reports_only:
:param kwargs: Parameters to pass to the parent class :class:`Parent`.
"""
pass