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

Feature/improve docs #35

Merged
merged 23 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ jobs:
poetry --version

- name: Install System Dependencies (Ubuntu)
if: startsWith(matrix.os, 'ubuntu') && (matrix.session == 'tests' || matrix.session == 'pre-commit')
if: startsWith(matrix.os, 'ubuntu') && (matrix.session == 'no')
run: |
sudo apt-get update
sudo apt-get install -y python3-dev python3-setuptools python3-scipy python3-matplotlib python3-pytest python3-sympy g++ build-essential gfortran libopenblas-dev liblapack-dev libmumps-scotch-dev

- name: Install Python dependencies (Ubuntu)
if: startsWith(matrix.os, 'ubuntu') && (matrix.session == 'tests' || matrix.session == 'pre-commit')
if: startsWith(matrix.os, 'ubuntu') && (matrix.session == 'no')
run: |
python -m pip install cython tinyarray

- name: Clone and Install kwant (Ubuntu)
if: startsWith(matrix.os, 'ubuntu') && (matrix.session == 'tests' || matrix.session == 'pre-commit')
if: startsWith(matrix.os, 'ubuntu') && (matrix.session == 'no')
run: |
git clone https://github.com/kwant-project/kwant.git
cd kwant
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ You can install _KPM Tools_ via [pip] from [PyPI]:
$ pip install kpm-tools
```

## Usage
## Python API

Please see the [Command-line Reference] for details.
Please see the [Python API reference] for details.

## Contributing

Expand Down Expand Up @@ -83,4 +83,4 @@ This project was generated from [@cjolowicz]'s [Hypermodern Python Cookiecutter]

[license]: https://github.com/piskunow/kpm-tools/blob/main/LICENSE
[contributor guide]: https://github.com/piskunow/kpm-tools/blob/main/CONTRIBUTING.md
[command-line reference]: https://kpm-tools.readthedocs.io/en/latest/usage.html
[python api reference]: https://kpm-tools.readthedocs.io/en/latest/api.html
81 changes: 81 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Python API

```{eval-rst}
.. click:: kpm_tools.__main__:main
:prog: kpm-tools
:nested: full
```

Each of the following sections describes the usage of different modules in the `kpm_tools` package.

## Bloch Module

```{eval-rst}
.. automodule:: kpm_tools.bloch
:members:
:undoc-members:
:show-inheritance:
```

## Common Module

```{eval-rst}
.. automodule:: kpm_tools.common
:members:
:undoc-members:
:show-inheritance:
```

## Evolution Module

```{eval-rst}
.. automodule:: kpm_tools.evolution
:members:
:undoc-members:
:show-inheritance:
```

## Hamiltonians Module

```{eval-rst}
.. automodule:: kpm_tools.hamiltonians
:members:
:undoc-members:
:show-inheritance:
```

## KPM Functions Module

```{eval-rst}
.. automodule:: kpm_tools.kpm_funcs
:members:
:undoc-members:
:show-inheritance:
```

## KPM Generator Module

```{eval-rst}
.. automodule:: kpm_tools.kpm_generator
:members:
:undoc-members:
:show-inheritance:
```

## Plotting Module

```{eval-rst}
.. automodule:: kpm_tools.plotting
:members:
:undoc-members:
:show-inheritance:
```

## Tiles Module

```{eval-rst}
.. automodule:: kpm_tools.tiles
:members:
:undoc-members:
:show-inheritance:
```
47 changes: 47 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
"""Sphinx configuration."""

import inspect
import os
import sys


project = "KPM Tools"
author = "Pablo Piskunow"
copyright = "2023, Pablo Piskunow"
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx.ext.linkcode",
"sphinx_click",
"myst_parser",
"nbsphinx",
Expand Down Expand Up @@ -36,3 +43,43 @@


""" # noqa: B950


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

# Replace with your project's GitHub repository URL
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__))

# Get the line number of the object within the module
obj = module
for part in info["fullname"].split("."):
obj = getattr(obj, part, None)

if obj is None:
return None

try:
lines, _ = inspect.getsourcelines(obj)
except Exception:
return None

line = inspect.getsourcelines(obj)[1]
return f"{github_repo}/blob/main/{rel_fn}#L{line}"
5 changes: 2 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ end-before: <!-- github-only -->

[license]: license
[contributor guide]: contributing
[command-line reference]: usage
[python api]: api

```{toctree}
---
Expand All @@ -15,8 +15,7 @@ maxdepth: 1
---

Tutorials <tutorials>
usage
reference
api
contributing
Code of Conduct <codeofconduct>
License <license>
Expand Down
Loading
Loading