My codebase's docstrings are set up like this:
"""_summary_
Args:
dbconn (SQLConnection): _description_
data_model (DataModel): _description_
pc_num (int): _description_
numeric_features (List[str]): _description_
granularity_levels (List[str]): _description_
if_exists (PandasTableExistsActionType, optional): _description_. Defaults to PandasTableExistsActionType.FAIL.
Raises:
UserError: _description_
UserError: _description_
EDAException: _description_
EDAException: _description_
e: _description_
UserError: _description_
e: _description_
UserError: _description_
EDAException: _description_
Returns:
Tuple[Dict, Dict]: _description_
"""
I want to have my autodoc generate everything but the "Raises section."
type_library = ['List', 'Dict', 'Tuple', 'Optional', 'Union', 'str', 'int', 'bool', 'float']
def remove_default_value(app, what, name, obj, options, signature, return_annotation):
if signature:
# Remove type hints from the signature
signature = re.sub(r":\s*(?:Optional\[.*?\]\s*)?(?P<param_name>[^=,)]+)", "", signature)
return (signature, None)
def skip_raises_section(app, what, name, obj, skip, options):
if what == "method" and name == "__init__":
# Check if the method has a "raises" section in its docstring
if obj.__doc__ and "Raises:" in obj.__doc__:
return True # Skip the member (i.e., the __init__ method)
return None # Use the default behavior for other members
def setup(app):
app.connect("autodoc-process-signature", remove_default_value)
app.connect("autodoc-skip-member", skip_raises_section)
return app
This is my current code inside the conf.py file. I am aiming to remove type hints from the function definition and not generate the raises portion of the docstring. Currently, the removing of type hints works but the skip raises doesn't do anything. I'm pretty new to sphinx and might be missing something. Is this the correct way to go about this issue, or is there something easier/more intuitive?