Skip to content

Commit

Permalink
Merge branch 'release/0.0.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
piskunow committed Dec 6, 2023
2 parents 2707f65 + 6f97486 commit 45cedde
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pip==23.3.1
nox==2023.4.22
nox-poetry==1.0.3
poetry==1.7.1
virtualenv==20.24.7
virtualenv==20.25.0
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand Down Expand Up @@ -57,14 +57,14 @@ jobs:
- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/[email protected].10
uses: pypa/[email protected].11
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/[email protected].10
uses: pypa/[email protected].11
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"

Expand Down
56 changes: 29 additions & 27 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,42 +46,44 @@
""" # noqa: B950


def get_object_line_number(info):
"""Return object line number from module."""
try:
module = sys.modules.get(info["module"])
if module is None:
return None

# walk through the nested module structure
obj = module
for part in info["fullname"].split("."):
obj = getattr(obj, part, None)
if obj is None:
return None

return inspect.getsourcelines(obj)[1]
except (TypeError, OSError):
return None


def linkcode_resolve(domain, info):
"""Resolve and link to source."""
"""Point to the source code repository, file and line number."""
# only add links to python modules
if domain != "py":
return None
if not info["module"]:
return None

# Determine the branch based on RTD version
rtd_version = os.getenv("READTHEDOCS_VERSION", "latest")
github_branch = "develop" if rtd_version == "latest" else "main"
filename = "src/" + info["module"].replace(".", "/")

# point to the right repository, branch, file and line
github_repo = "https://github.com/piskunow/kpm-tools"

module = sys.modules.get(info["module"])
if module is None:
line = get_object_line_number(info)
if line is None:
return None

try:
filename = inspect.getsourcefile(module)
if filename is None:
return None

# Assuming your package is installed in 'site-packages'
# and the source is in 'src/kpm_tools' in the repo
src_path = filename.split("site-packages")[1]
rel_fn = "src" + src_path

obj = module
for part in info["fullname"].split("."):
obj = getattr(obj, part, None)

if obj is None:
return None
# Determine the branch based on RTD version
rtd_version = os.getenv("READTHEDOCS_VERSION", "latest")
github_branch = "develop" if rtd_version == "develop" else "main"

line = inspect.getsourcelines(obj)[1]
return f"{github_repo}/blob/{github_branch}/{rel_fn}#L{line}"
except Exception as e:
print(f"Error generating linkcode URL for {info['module']}: {e}")
return None
return f"{github_repo}/blob/{github_branch}/{filename}.py#L{line}"
50 changes: 25 additions & 25 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "kpm-tools"
version = "0.0.6"
version = "0.0.7"
description = "KPM Tools"
authors = ["Pablo Piskunow <[email protected]>"]
license = "BSD 2-Clause"
Expand Down

0 comments on commit 45cedde

Please sign in to comment.