Skip to content

Commit

Permalink
Merge branch 'release/0.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
piskunow committed Nov 25, 2023
2 parents fc270cf + c411461 commit 7ca8ed8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ $ pip install kpm-tools

## Python API

Please see the [Python API reference] for details.
Please see the [python api reference] for details.

## Contributing

Expand Down
22 changes: 11 additions & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
project = "KPM Tools"
author = "Pablo Piskunow"
copyright = "2023, Pablo Piskunow"
autodoc_mock_imports = ["kwant"]
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
Expand Down Expand Up @@ -46,29 +47,30 @@


def linkcode_resolve(domain, info):
"""Resolve links to source."""
"""Resolve and link to source."""
if domain != "py":
return None
if not info["module"]:
return None

# Replace with your project's GitHub repository URL
# Determine the branch based on RTD version
rtd_version = os.getenv("READTHEDOCS_VERSION", "latest")
github_branch = "develop" if rtd_version == "latest" else "main"

github_repo = "https://github.com/piskunow/kpm-tools"

# Get the module object
module = sys.modules.get(info["module"])
if module is None:
return None

# Get the source file path of the module
filename = inspect.getsourcefile(module)
if filename is None:
return None

# Trim the filename to a path relative to the project root
rel_fn = os.path.relpath(filename, start=os.path.dirname(__file__))
# Adjust the file path for the repository structure
package_dir = "src/kpm_tools"
rel_fn = os.path.relpath(filename, start=os.path.dirname(package_dir))

# Get the line number of the object within the module
obj = module
for part in info["fullname"].split("."):
obj = getattr(obj, part, None)
Expand All @@ -77,9 +79,7 @@ def linkcode_resolve(domain, info):
return None

try:
lines, _ = inspect.getsourcelines(obj)
line = inspect.getsourcelines(obj)[1]
return f"{github_repo}/blob/{github_branch}/{rel_fn}#L{line}"
except Exception:
return None

line = inspect.getsourcelines(obj)[1]
return f"{github_repo}/blob/main/{rel_fn}#L{line}"
6 changes: 0 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,6 @@ def docs_build(session: Session) -> None:
"sphinx", "sphinx-click", "nbsphinx", "pandoc", "furo", "myst-parser"
)

# Call the kwant installation functions
build_kwant(session)

build_dir = Path("docs", "_build")
if build_dir.exists():
shutil.rmtree(build_dir)
Expand All @@ -302,9 +299,6 @@ def docs(session: Session) -> None:
"pandoc",
)

# Call the kwant installation functions
build_kwant(session)

build_dir = Path("docs", "_build")
if build_dir.exists():
shutil.rmtree(build_dir)
Expand Down
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.2"
version = "0.0.3"
description = "KPM Tools"
authors = ["Pablo Piskunow <[email protected]>"]
license = "BSD 2-Clause"
Expand Down

0 comments on commit 7ca8ed8

Please sign in to comment.