Skip to content

Commit b683a5e

Browse files
authored
Add autogenerated documentation (#4)
* Add various files needed for config * Rewrite API generation * Add build and upload docs * Fix copying of readme * Fix make
1 parent 58c4637 commit b683a5e

File tree

11 files changed

+117
-4
lines changed

11 files changed

+117
-4
lines changed

.github/workflows/build_docs.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Github Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-22.04
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Setup Python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.10"
18+
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install ".[docs]"
22+
- name: Build docs
23+
run: make doc
24+
25+
- name: Deploy
26+
uses: peaceiris/actions-gh-pages@v3
27+
with:
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
publish_dir: ./docs/_build/html

.github/workflows/test_package.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ jobs:
5454
path: htmlcov
5555
if-no-files-found: error
5656

57+
- name: Build documentation
58+
run: |
59+
make doc
60+
61+
- name: Upload documentation
62+
uses: actions/upload-artifact@v3
63+
with:
64+
name: documentation
65+
path: docs/_build/html
66+
if-no-files-found: error
67+
68+
5769
test-code:
5870
# This code depends on the result of check-code
5971
needs: check-code

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
doc: # Generate Sphinx HTML documentation, including API docs
2+
cp README.md docs/README.md
3+
jupyter book build docs
4+
5+
clean-pytest: # Remove output from pytest
6+
rm -rf .pytest_cache
7+
rm -rf test/__pycache__
8+
9+
clean-coverage: # Remove output from coverage
10+
rm -rf .covarge htmlcov
11+
12+
clean-mypackage: # Remove output from installing package
13+
rm -rf mypackage.egg-info mypackage/__pycache__
14+
15+
clean-mypy: # Remove output from mypy
16+
rm -rf .mypy_cache
17+
18+
clean: clean-mypy clean-mypackage clean-coverage clean-pytest

docs/_config.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Book settings
2+
# Learn more at https://jupyterbook.org/customize/config.html
3+
4+
title: MyPackage - The reproducible template for Simula Research Laboratory
5+
author: Jørgen S. Dokken
6+
logo: "logo.png"
7+
copyright: "2022"
8+
9+
# Force re-execution of notebooks on each build.
10+
# See https://jupyterbook.org/content/execute.html
11+
execute:
12+
execute_notebooks: force
13+
14+
15+
# Information about where the book exists on the web
16+
repository:
17+
url: https://github.com/jorgensd/reproducibility # Online location of your book
18+
path_to_book: docs # Optional path to your book, relative to the repository root
19+
branch: main # Which branch of the repository should be used when creating links (optional)
20+
21+
22+
sphinx:
23+
extra_extensions:
24+
- 'sphinx.ext.autodoc'
25+
- 'sphinx.ext.napoleon'
26+
- 'sphinx.ext.viewcode'
27+
28+
29+
# Add GitHub buttons to your book
30+
# See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository
31+
html:
32+
use_issues_button: true
33+
use_repository_button: true
34+
35+
36+
parse:
37+
myst_enable_extensions:
38+
- amsmath
39+
- dollarmath
40+
- linkify

docs/_toc.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
format: jb-book
2+
root: README
3+
4+
chapters:
5+
- file: "api"

docs/api.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
API Reference
2+
=============
3+
4+
.. automodule:: mypackage
5+
:members:

docs/logo.png

3.54 KB
Loading

mypackage/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
# This file is part of my_package
55
# SPDX-License-Identifier: MIT
66

7-
from .functions import addition
7+
from .functions import addition, print_add
88

9-
__all__ = ["addition"]
9+
__all__ = ["addition", "print_add"]

mypackage/functions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
# This file is part of mypackage
66
# SPDX-License-Identifier: MIT
77

8+
__all__ = ["addition", "print_add"]
9+
10+
811
def addition(a: int, b: int) -> int:
912
""" Computes a+b """
1013
return a + b
1114

1215

1316
def print_add(a: int, b: int) -> int:
17+
""" Computes and prints a + b"""
1418
c = a + b
1519
print(c)
1620
return c

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ test = [
2626
]
2727

2828
docs = [
29-
"Sphinx",
29+
"sphinx",
3030
"jupyter-book",
3131
"pandoc"
3232
]

0 commit comments

Comments
 (0)