Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use sphinx.ext.linkcode for more precise source code links #11851

Merged
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
099636d
switched from sphinx.ext.viewcode to sphinx.ext.linkcode
melechlapson Feb 20, 2024
00b05e7
removed extra line
melechlapson Feb 21, 2024
a20ad5c
Merge branch 'main' into mlapson/switch-to-sphinx-ext-linkcode
melechlapson Feb 21, 2024
2f94288
Add section header for source code links
melechlapson Feb 21, 2024
1d5c34d
removed docstring
melechlapson Feb 21, 2024
1849ce1
update return string
melechlapson Feb 21, 2024
cca9b04
added back blank line
melechlapson Feb 21, 2024
5bd18cd
Merge branch 'mlapson/switch-to-sphinx-ext-linkcode' of https://githu…
melechlapson Feb 21, 2024
b985ba6
Added a method to determine the GitHub branch
melechlapson Feb 21, 2024
914d2cd
Merge branch 'main' into mlapson/switch-to-sphinx-ext-linkcode
melechlapson Feb 21, 2024
1deb939
add blank line
melechlapson Feb 21, 2024
b84b399
remove print statement
melechlapson Feb 21, 2024
01e4ca6
Try to fix error for contextlib file
Eric-Arellano Feb 21, 2024
25ff4df
Try to fix error for Jenkins run #20240221.52
melechlapson Feb 21, 2024
ace069b
Check that qiskit in module name sooner
Eric-Arellano Feb 21, 2024
5420982
moved valid code object verification earlier
melechlapson Feb 27, 2024
d60bbf4
Merge branch 'main' into mlapson/switch-to-sphinx-ext-linkcode
melechlapson Feb 27, 2024
17881d4
added try except statement to getattr call
melechlapson Feb 27, 2024
9330e45
added extra try/except block
melechlapson Feb 27, 2024
ab8dad0
Also support Azure Pipelines
Eric-Arellano Feb 27, 2024
6ef1f68
removed unused import
melechlapson Feb 27, 2024
b45113b
Revert Azure support to keep things simple
Eric-Arellano Feb 27, 2024
a3e5297
added extra "/" to final URL
melechlapson Feb 27, 2024
e3382e7
Merge branch 'mlapson/switch-to-sphinx-ext-linkcode' of https://githu…
melechlapson Feb 27, 2024
825e02a
Merge branch 'main' into mlapson/switch-to-sphinx-ext-linkcode
melechlapson Feb 28, 2024
51f4bcb
Merge branch 'main' of github.com:Qiskit/qiskit-terra into mlapson/sw…
Eric-Arellano Mar 7, 2024
ab7f411
Move GitHub branch logic to GitHub Action
Eric-Arellano Mar 7, 2024
2a28edb
Merge branch 'mlapson/switch-to-sphinx-ext-linkcode' of github.com:me…
Eric-Arellano Mar 7, 2024
cde30ef
switched to importlib and removed redundant block of code
melechlapson Mar 20, 2024
5545bc8
Apply suggestions from code review
melechlapson Mar 21, 2024
7c95384
Merge branch 'main' into mlapson/switch-to-sphinx-ext-linkcode
melechlapson Mar 21, 2024
5b74a03
added back spaces
melechlapson Apr 4, 2024
8a805da
Merge branch 'main' of github.com:Qiskit/qiskit-terra into mlapson/sw…
Eric-Arellano Apr 4, 2024
abf4871
Clarify docs_deploy GitHub logic
Eric-Arellano Apr 4, 2024
3386c4c
Use pathlib for relativizing file name
Eric-Arellano Apr 4, 2024
614e8f8
Fix relative_to() path
Eric-Arellano Apr 5, 2024
19d052d
Remove tox prefix
Eric-Arellano Apr 5, 2024
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
switched to importlib and removed redundant block of code
melechlapson committed Mar 20, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit cde30ef4e4f451de0966280677e77ec5989da7ed
13 changes: 4 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -11,17 +11,17 @@
# that they have been altered from the originals.

from __future__ import annotations

# pylint: disable=invalid-name,missing-function-docstring

"""Sphinx documentation builder."""

import datetime
import doctest
import importlib
import inspect
import os
import re
import sys


project = "Qiskit"
project_copyright = f"2017-{datetime.date.today().year}, Qiskit Development Team"
@@ -165,13 +165,12 @@
# Source code links
# ----------------------------------------------------------------------------------


def linkcode_resolve(domain, info):
if domain != "py":
return None

module_name = info["module"]
module = sys.modules.get(module_name)
module = importlib.import_module(module_name)
if module is None or "qiskit" not in module_name:
return None

@@ -181,11 +180,7 @@ def linkcode_resolve(domain, info):
obj = getattr(obj, part)
except AttributeError:
return None
is_valid_code_object = (
inspect.isclass(obj) or inspect.ismethod(obj) or inspect.isfunction(obj)
)
if not is_valid_code_object:
return None

try:
full_file_name = inspect.getsourcefile(obj)
except TypeError: