From 66008ab85415357f2a36e8269f20431d61804054 Mon Sep 17 00:00:00 2001 From: aelkheir <90580077+aelkheir@users.noreply.github.com> Date: Tue, 1 Jul 2025 15:09:30 +0300 Subject: [PATCH 1/4] Fix source linking (closes #4838). --- docs/auxil/sphinx_hooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/auxil/sphinx_hooks.py b/docs/auxil/sphinx_hooks.py index 47fd9c9281c..899b49aef6b 100644 --- a/docs/auxil/sphinx_hooks.py +++ b/docs/auxil/sphinx_hooks.py @@ -55,7 +55,7 @@ } -FILE_ROOT = Path(inspect.getsourcefile(telegram)).parent.parent.resolve() +FILE_ROOT = Path(inspect.getsourcefile(telegram)).parent.parent.parent.resolve() def autodoc_skip_member(app, what, name, obj, skip, options): From 3d049bea9f7aa1833194804a729ca062b54f9475 Mon Sep 17 00:00:00 2001 From: aelkheir <90580077+aelkheir@users.noreply.github.com> Date: Tue, 1 Jul 2025 12:14:18 +0000 Subject: [PATCH 2/4] Add chango fragment for PR #4839 --- changes/unreleased/4839.gExNhF7C6kR5VrBg6cBaar.toml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changes/unreleased/4839.gExNhF7C6kR5VrBg6cBaar.toml diff --git a/changes/unreleased/4839.gExNhF7C6kR5VrBg6cBaar.toml b/changes/unreleased/4839.gExNhF7C6kR5VrBg6cBaar.toml new file mode 100644 index 00000000000..74272eb6724 --- /dev/null +++ b/changes/unreleased/4839.gExNhF7C6kR5VrBg6cBaar.toml @@ -0,0 +1,5 @@ +documentation = "Documentation improvements." +[[pull_requests]] +uid = "4839" +author_uid = "aelkheir" +closes_threads = ["4838"] From d77ea7c59bd7b5b5fdb2e90285d3cb3086513da4 Mon Sep 17 00:00:00 2001 From: aelkheir <90580077+aelkheir@users.noreply.github.com> Date: Tue, 1 Jul 2025 15:19:08 +0300 Subject: [PATCH 3/4] Elaborate on chango fragment for PR. --- changes/unreleased/4839.gExNhF7C6kR5VrBg6cBaar.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/changes/unreleased/4839.gExNhF7C6kR5VrBg6cBaar.toml b/changes/unreleased/4839.gExNhF7C6kR5VrBg6cBaar.toml index 74272eb6724..cb93ea41ab9 100644 --- a/changes/unreleased/4839.gExNhF7C6kR5VrBg6cBaar.toml +++ b/changes/unreleased/4839.gExNhF7C6kR5VrBg6cBaar.toml @@ -1,4 +1,7 @@ -documentation = "Documentation improvements." +documentation = """Documentation improvements. + +* Fix [source] linking. +""" [[pull_requests]] uid = "4839" author_uid = "aelkheir" From f7708c9f7122a98a2042a8b7a71ddeaf2a6c1c32 Mon Sep 17 00:00:00 2001 From: aelkheir <90580077+aelkheir@users.noreply.github.com> Date: Tue, 1 Jul 2025 17:55:32 +0300 Subject: [PATCH 4/4] Unify source file discovery accross installation setups. --- docs/auxil/sphinx_hooks.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/auxil/sphinx_hooks.py b/docs/auxil/sphinx_hooks.py index 899b49aef6b..62d8613c8b0 100644 --- a/docs/auxil/sphinx_hooks.py +++ b/docs/auxil/sphinx_hooks.py @@ -55,7 +55,9 @@ } -FILE_ROOT = Path(inspect.getsourcefile(telegram)).parent.parent.parent.resolve() +# Resolves to the parent directory of `telegram/`, depending on installation setup, +# could either be `/src` or `/site-packages` +FILE_ROOT = Path(inspect.getsourcefile(telegram)).parent.parent.resolve() def autodoc_skip_member(app, what, name, obj, skip, options): @@ -161,7 +163,7 @@ def autodoc_process_docstring( with contextlib.suppress(Exception): source_lines, start_line = inspect.getsourcelines(obj) end_line = start_line + len(source_lines) - file = Path(inspect.getsourcefile(obj)).relative_to(FILE_ROOT) + file = Path("src") / Path(inspect.getsourcefile(obj)).relative_to(FILE_ROOT) LINE_NUMBERS[name] = (file, start_line, end_line) # Since we don't document the `__init__`, we call this manually to have it available for