Skip to content

Commit

Permalink
Add initial documentation (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBoothroyd authored Dec 1, 2023
1 parent bec54a8 commit f5c863f
Show file tree
Hide file tree
Showing 12 changed files with 306 additions and 45 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
make lint
make test
make test-examples
make docs-build
- name: CodeCov
uses: codecov/codecov-action@v3.1.1
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Publish Documentation

on:
push:
branches:
- main
tags:
- '*'

jobs:
deploy-docs:

runs-on: ubuntu-latest
container: condaforge/mambaforge:latest

steps:
- name: Prepare container
run: |
apt update && apt install -y git make
- name: Checkout
uses: actions/checkout@v3.3.0

- name: Determine Version
shell: bash
run: |
if [ "$GITHUB_REF" = "refs/heads/main" ]; then
echo "VERSION=latest" >> $GITHUB_ENV
elif [ "${GITHUB_REF#refs/tags/}" != "$GITHUB_REF" ]; then
VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\///')
echo "VERSION=$VERSION stable" >> $GITHUB_ENV
else
echo "Invalid ref: $GITHUB_REF"
exit 1
fi
- name: Build and Deploy Documentation
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
git config --global --add safe.directory "$PWD"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git fetch --all --prune
make env
pip install git+https://${INSIDER_DOCS_TOKEN}@github.com/SimonBoothroyd/griffe-pydantic.git@fix-inheritence-static
pip install git+https://${INSIDER_DOCS_TOKEN}@github.com/SimonBoothroyd/mkdocstrings-python.git
sed -i 's/# extensions/extensions/' mkdocs.yml
make docs-deploy VERSION="$VERSION"
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CONDA_ENV_RUN := conda run --no-capture-output --name $(PACKAGE_NAME)
EXAMPLES_SKIP := examples/md-simulations.ipynb
EXAMPLES := $(filter-out $(EXAMPLES_SKIP), $(wildcard examples/*.ipynb))

.PHONY: pip-install env lint format test test-examples
.PHONY: pip-install env lint format test test-examples docs-build docs-deploy

pip-install:
$(CONDA_ENV_RUN) pip install --no-build-isolation --no-deps -e .
Expand Down Expand Up @@ -36,3 +36,12 @@ test:

test-examples:
$(CONDA_ENV_RUN) jupyter nbconvert --to notebook --execute $(EXAMPLES)

docs-build:
$(CONDA_ENV_RUN) mkdocs build

docs-deploy:
ifndef VERSION
$(error VERSION is not set)
endif
$(CONDA_ENV_RUN) mike deploy --push --update-aliases $(VERSION)
60 changes: 17 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
SMIRNOFF Energy Evaluations
===========================
[![Test Status](https://github.com/simonboothroyd/smee/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/simonboothroyd/smee/actions/workflows/ci.yaml)
[![codecov](https://codecov.io/gh/simonboothroyd/smee/branch/main/graph/badge.svg)](https://codecov.io/gh/simonboothroyd/smee/branch/main)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
<h1 align="center">SMIRNOFF Energy Evaluations</h1>

<p align="center">Differentiably evaluate energies of molecules using SMIRNOFF force fields</p>

<p align="center">
<a href="https://github.com//actions?query=workflow%3Aci">
<img alt="ci" src="https://github.com/SimonBoothroyd/smee/actions/workflows/ci.yaml/badge.svg" />
</a>
<a href="https://codecov.io/gh/SimonBoothroyd/smee/branch/main">
<img alt="coverage" src="https://codecov.io/gh/SimonBoothroyd/smee/branch/main/graph/badge.svg" />
</a>
<a href="https://opensource.org/licenses/MIT">
<img alt="license" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
</a>
</p>

---

The `smee` framework aims to offer a simple API for differentiably evaluating the energy of [SMIRNOFF](https://openforcefield.github.io/standards/standards/smirnoff/)
force fields applied to molecules using `pytorch`.
Expand All @@ -15,10 +27,6 @@ The package currently supports evaluating the energy of force fields that contai

parameter handlers in addition to limited support for registering custom handlers.

***Warning**: This code is currently experimental and under active development. If you are using this it, please be
aware that it is not guaranteed to provide correct results, the documentation and testing maybe be incomplete, and the
API can change without notice.*

## Installation

This package can be installed using `conda` (or `mamba`, a faster version of `conda`):
Expand All @@ -37,40 +45,6 @@ mamba install -c conda-forge jupyter nglview "smirnoff-plugins >=0.0.4"

To get started, see the [examples](examples).

## Development

A development conda environment can be created and activated by running:

```shell
make env
conda activate smee
```

The environment will include all example and development dependencies, including linters and testing apparatus.

Unit / example tests can be run using:

```shell
make test
make test-examples
```

The codebase can be formatted by running:

```shell
make format
```

or checked for lint with:

```shell
make lint
```

## License

The main package is release under the [MIT license](LICENSE).

## Copyright

Copyright (c) 2023, Simon Boothroyd
11 changes: 11 additions & 0 deletions devtools/envs/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,14 @@ dependencies:
- pytest-mock

- codecov

# Docs
- mkdocs
- mkdocs-material
- mkdocs-gen-files
- mkdocs-literate-nav
- mkdocs-jupyter
- mkdocstrings
- mkdocstrings-python
- black
- mike
28 changes: 28 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Development

To create a development environment, you must have [`mamba` installed](https://mamba.readthedocs.io/en/latest/installation/mamba-installation.html).

A development conda environment can be created and activated with:

```shell
make env
conda activate smee
```

To format the codebase:

```shell
make format
```

To run the unit tests:

```shell
make test
```

To serve the documentation locally:

```shell
mkdocs serve
```
1 change: 1 addition & 0 deletions docs/examples
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--8<-- "README.md"
16 changes: 16 additions & 0 deletions docs/javascripts/mathjax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};

document$.subscribe(() => {
MathJax.typesetPromise()
})
39 changes: 39 additions & 0 deletions docs/scripts/gen_ref_pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Generate the code reference pages and navigation."""

import pathlib

import mkdocs_gen_files

nav = mkdocs_gen_files.Nav()
src = pathlib.Path(__file__).parent.parent.parent / "smee"

mod_symbol = '<code class="doc-symbol doc-symbol-nav doc-symbol-module"></code>'

for path in sorted(src.rglob("*.py")):
if "tests" in str(path):
continue

module_path = path.relative_to(src.parent).with_suffix("")
doc_path = path.relative_to(src).with_suffix(".md")
full_doc_path = pathlib.Path("reference", doc_path)

parts = tuple(module_path.parts)

if parts[-1] == "__init__":
parts = parts[:-1]
doc_path = doc_path.with_name("index.md")
full_doc_path = full_doc_path.with_name("index.md")
elif parts[-1].startswith("_"):
continue

nav_parts = [f"{mod_symbol} {part}" for part in parts]
nav[tuple(nav_parts)] = doc_path.as_posix()

with mkdocs_gen_files.open(full_doc_path, "w") as fd:
ident = ".".join(parts)
fd.write(f"::: {ident}")

mkdocs_gen_files.set_edit_path(full_doc_path, ".." / path)

with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file:
nav_file.writelines(nav.build_literate_nav())
128 changes: 128 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
site_name: "smee"
site_description: "Differentiably evaluate energies of molecules."
site_url: "https://github.com/SimonBoothroyd/smee"
repo_url: "https://github.com/SimonBoothroyd/smee"
repo_name: "SimonBoothroyd/smee"
site_dir: "site"
watch: [mkdocs.yml, README.md, smee/, docs]
copyright: Copyright &copy; 2023 Simon Boothroyd
edit_uri: edit/main/docs/

validation:
omitted_files: warn
absolute_links: warn
unrecognized_links: warn

nav:
- Home:
- Overview: index.md
- Examples:
- examples/README.md
- examples/compute-energy.ipynb
- examples/conformer-minimization.ipynb
- examples/custom-handler.ipynb
- examples/md-simulations.ipynb
- examples/parameter-gradients.ipynb
- API reference: reference/
- Development: development.md

theme:
name: material
features:
- announce.dismiss
- content.action.edit
- content.action.view
- content.code.annotate
- content.code.copy
- content.tooltips
- navigation.footer
- navigation.indexes
- navigation.sections
- navigation.tabs
- navigation.tabs.sticky
- navigation.top
- search.highlight
- search.suggest
- toc.follow
palette:
- media: "(prefers-color-scheme)"
toggle:
icon: material/brightness-auto
name: Switch to light mode
- media: "(prefers-color-scheme: light)"
scheme: default
primary: teal
accent: purple
toggle:
icon: material/weather-sunny
name: Switch to dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: black
accent: lime
toggle:
icon: material/weather-night
name: Switch to system preference

markdown_extensions:
- attr_list
- def_list
- admonition
- footnotes
- pymdownx.highlight:
anchor_linenums: true
line_spans: __span
pygments_lang_class: true
- pymdownx.inlinehilite
- pymdownx.superfences
- pymdownx.magiclink
- pymdownx.snippets:
base_path: [!relative $config_dir]
check_paths: true
- pymdownx.details
- pymdownx.arithmatex:
generic: true
- pymdownx.tabbed:
alternate_style: true
- toc:
permalink: "#"

plugins:
- autorefs
- search
- gen-files:
scripts:
- docs/scripts/gen_ref_pages.py
- mkdocs-jupyter:
include: [ "examples/*.ipynb" ]
- literate-nav:
nav_file: SUMMARY.md
- mkdocstrings:
handlers:
python:
paths: [smee/]
options:
# extensions: [ griffe_pydantic ]
docstring_options:
ignore_init_summary: true
returns_multiple_items: false
returns_named_value: false
docstring_section_style: list
filters: ["!^_"]
heading_level: 1
inherited_members: true
merge_init_into_class: true
separate_signature: true
show_root_heading: true
show_root_full_path: false
show_signature_annotations: true
show_symbol_type_heading: true
show_symbol_type_toc: true
signature_crossrefs: true
summary: true
members_order: source

extra_javascript:
- javascripts/mathjax.js
- https://polyfill.io/v3/polyfill.min.js?features=es6
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
Loading

0 comments on commit f5c863f

Please sign in to comment.