Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a46325c
Fix: Improving the doc strings one dot at a time
Poolitzer May 7, 2026
96fd8a4
Merge branch 'master' into doc-fixes
harshil21 May 20, 2026
db5d839
Sequence -> tuple doc fix
harshil21 May 20, 2026
5e78628
Rename file without leading underscore
harshil21 May 20, 2026
a4cad41
Add chango fragment for PR #5240
harshil21 May 20, 2026
a6b1e32
Fix other imports
harshil21 May 20, 2026
f58ec82
Autogen Raises: block, fix kwargs and admonition insertion bug
harshil21 May 20, 2026
bae37b0
WIP: Start rewriting the doc autogenerator
harshil21 May 25, 2026
f862757
First pass on autogeneration of attrs
harshil21 May 26, 2026
3047777
Remove Attributes from docstrings wherever applicable
harshil21 May 26, 2026
2fa5119
raise error instead of a warning for unresolvable attrs
harshil21 May 26, 2026
a171534
Review: keyword args doc for do_api_request
harshil21 May 26, 2026
70d074e
Review: Update changelog
harshil21 May 26, 2026
d329049
Merge branch 'auto-doc-raises' into auto-doc-attr
harshil21 May 26, 2026
5388a66
Add missing poll option to toctree
harshil21 May 26, 2026
5dd9054
Merge branch 'doc-fixes' into auto-doc-raises
harshil21 May 26, 2026
5215441
Merge branch 'auto-doc-raises' into auto-doc-attr
harshil21 May 26, 2026
2a7e0b3
Fix missing Attributes, update changelog
harshil21 May 26, 2026
8cd9a8a
Update test workflow for docs
harshil21 May 26, 2026
0c7053c
Auto insert raises block, fix `Bot` kwargs insertion regression (#5241)
harshil21 May 26, 2026
19f1d4b
fix typo
harshil21 May 26, 2026
3c1c084
Merge doc-fixes and fix conflicts
harshil21 May 26, 2026
8b76d05
Merge doc-fixes and fix conflicts
harshil21 Jun 16, 2026
1daa65d
Review: minor optimization, clarify a few things
harshil21 Jun 16, 2026
b004cef
Add chango fragment for PR #5246
harshil21 Jun 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
raise error instead of a warning for unresolvable attrs
  • Loading branch information
harshil21 committed May 26, 2026
commit 2fa51195955b7686cf52cbb936a7332a6c74da6f
4 changes: 1 addition & 3 deletions docs/auxil/attribute_inserter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2026
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
Expand Down Expand Up @@ -232,10 +231,9 @@ def insert_attributes(self, obj: type, lines: list[str]) -> None:
and slot not in args_names
and slot not in properties_on_class
):
warnings.warn(
raise RuntimeError(
f"Class {obj.__qualname__!r}: public slot {slot!r} has no documentation "
f"source. Please add it to the 'Attributes:' section manually.",
stacklevel=2,
)

new_attr_lines: list[str] = []
Expand Down
3 changes: 1 addition & 2 deletions docs/auxil/sphinx_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def autodoc_process_docstring(

# 1) Insert the Keyword Args and "Shortcuts" admonitions for the Bot methods
method_name = name.rsplit(".", maxsplit=1)[-1]
# object_signature = inspect.signature(obj) if callable(obj) else None
if (
name.startswith("telegram.Bot.")
and what == "method"
Expand Down Expand Up @@ -154,7 +153,7 @@ def autodoc_process_docstring(

# 2-4) Insert "Returned in", "Available in", "Use in" admonitions into classes
# (where applicable)
if what == "class":
if what in ("class", "exception"):
# Auto-generate Attributes section entries from Args before admonitions are inserted
ATTRIBUTE_INSERTER.insert_attributes(
obj=typing.cast("type", obj),
Expand Down
12 changes: 6 additions & 6 deletions tests/docs/attribute_inserter.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,8 @@ def value(self) -> int:
# No Attributes section should be created because 'value' is a property.
assert "Attributes:" not in lines

def test_undocumented_public_slot_warns(self, inserter):
"""A public own slot with no Args entry and no Attributes entry raises a warning."""
def test_undocumented_public_slot_raises(self, inserter):
"""A public own slot with no Args entry and no Attributes entry raises an error."""

class _MyClass:
__slots__ = ("computed",)
Expand All @@ -498,7 +498,7 @@ class _MyClass:
"Args:",
" name (:obj:`str`): The name.",
]
with pytest.warns(UserWarning, match="public slot 'computed'"):
with pytest.raises(RuntimeError, match="public slot 'computed'"):
inserter.insert_attributes(_MyClass, lines)

def test_rst_substitution_after_attributes_not_swallowed(self, inserter):
Expand Down Expand Up @@ -555,14 +555,14 @@ def test_sequence_classargs_substitution_optional(self, inserter):
assert "|tupleclassattrs|" not in "\n".join(attrs_block)
assert "|alwaystuple|" not in "\n".join(attrs_block)

def test_no_args_section_slot_warns(self, inserter):
"""No Args section but class has undocumented public slot -> warning."""
def test_no_args_section_slot_raises(self, inserter):
"""No Args section but class has undocumented public slot -> raises."""

class _MyClass:
__slots__ = ("computed",)

lines = ["Just a description."]
with pytest.warns(UserWarning, match="public slot 'computed'"):
with pytest.raises(RuntimeError, match="public slot 'computed'"):
inserter.insert_attributes(_MyClass, lines)
# Lines unchanged (no args to generate from)
assert "Attributes:" not in lines
Expand Down