Skip to content

Commit ded27db

Browse files
Include show source button, inherited members in API reference (#25)
1 parent 37ebb64 commit ded27db

5 files changed

Lines changed: 36 additions & 7 deletions

File tree

.github/workflows/deploy_public.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Install dependencies
4444
run: |
4545
python -m pip install --upgrade pip
46-
python -m pip install build sphinx pydata_sphinx_theme
46+
python -m pip install build sphinx==5.3.0 pydata_sphinx_theme==0.11.0
4747
4848
- name: Get new version number from input
4949
id: version_number

build_doc.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
sphinx-build -b html ./docs ./build/html
1+
sphinx-build -b html ./docs ./build/html -E
22
pause

docs/conf.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
# -- Path setup --------------------------------------------------------------
88

9+
import inspect
10+
911
# If extensions (or modules to document with autodoc) are in another directory,
1012
# add these directories to sys.path here. If the directory is relative to the
1113
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -24,6 +26,7 @@
2426
project = "fourinsight-api"
2527
copyright = f"{date.today().year}, 4Subsea"
2628
author = "4Subsea"
29+
github_repo = "https://github.com/4Subsea/fourinsight-api-python/"
2730

2831
# The full version, including alpha/beta/rc tags
2932
version = metadata.version(project)
@@ -40,7 +43,33 @@
4043
"sphinx.ext.autodoc",
4144
"sphinx.ext.napoleon",
4245
"sphinx.ext.intersphinx",
46+
"sphinx.ext.linkcode",
4347
]
48+
49+
50+
def linkcode_resolve(domain, info):
51+
if domain != "py":
52+
return None
53+
if not info["module"]:
54+
return None
55+
56+
obj = sys.modules[info["module"]]
57+
58+
for part in info["fullname"].split("."):
59+
obj = getattr(obj, part)
60+
obj = inspect.unwrap(obj)
61+
62+
try:
63+
path = os.path.relpath(inspect.getfile(obj))
64+
src, lineno = inspect.getsourcelines(obj)
65+
66+
path = f"{github_repo}blob/main/{path}#L{lineno}-L{lineno + len(src) - 1}"
67+
68+
except Exception:
69+
path = None
70+
return path
71+
72+
4473
autosummary_generate = True
4574

4675
# Napoleon settings
@@ -86,7 +115,7 @@
86115
"icon_links": [
87116
{
88117
"name": "GitHub",
89-
"url": "https://github.com/4Subsea/fourinsight-api-python",
118+
"url": github_repo,
90119
"icon": "fab fa-github",
91120
},
92121
{

tox-deploy.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ envlist = py39
55
[testenv]
66
deps =
77
build
8-
sphinx
9-
pydata_sphinx_theme
8+
sphinx==5.3.0
9+
pydata_sphinx_theme==0.11.0
1010
commands =
1111
python -m build --outdir ./build
1212
sphinx-build -b html ./docs ./build/html

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ deps =
1515
basepython = python3.9
1616
changedir = docs
1717
deps =
18-
sphinx
19-
pydata_sphinx_theme
18+
sphinx==5.3.0
19+
pydata_sphinx_theme==0.11.0
2020
commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html

0 commit comments

Comments
 (0)