diff --git a/README.md b/README.md index e51718a..0a2cf75 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/conf.py b/docs/conf.py index 1fcc385..b6ce2da 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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", @@ -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) @@ -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}" diff --git a/noxfile.py b/noxfile.py index a13536d..130d2be 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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) @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 14aa962..6209964 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "kpm-tools" -version = "0.0.2" +version = "0.0.3" description = "KPM Tools" authors = ["Pablo Piskunow "] license = "BSD 2-Clause"