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

Tweak documentation section #19

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Changes from 1 commit
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
75 changes: 28 additions & 47 deletions docs/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,27 @@ pip-compile --extra=docs --output-file=requirements-docs.txt pyproject.toml

---

## Documentation configuration
## Documentation configuration (`_config.yml`)
### Required info
```yaml
# _config.yml
title: Example paper
author: Henrik Finsberg and Jørgen Dokken
copyright: "2023"
only_build_toc_files: true
bibtex_bibfiles: "references.bib"
```

---

## Documentation configuration (`_config.yml`)
**Recommended configuration**
```yaml
only_build_toc_files: true
exclude_patterns: [".pytest_cache/*", ".github/*"]
parse:
myst_enable_extensions:
- amsmath
- dollarmath
- linkify

sphinx:
config:
bibtex_reference_style: author_year
Expand All @@ -126,13 +132,11 @@ sphinx:
.py:
- jupytext.reads
- fmt: py

exclude_patterns: [".pytest_cache/*", ".github/*"]
```

---

## And a table of contents called `_toc.yml`
## And a table of contents (`_toc.yml`)

```yaml
format: jb-book
Expand All @@ -153,12 +157,13 @@ Install JupyterBook
```
python3 -m pip install jupyter-book
```
<div style="display:contents;" data-marpit-fragment>

Build the book (in the root where `_config.yml` amd `_toc.yml` is located).

```
jupyter-book build .
```
<div/>

---

Expand Down Expand Up @@ -221,56 +226,38 @@ parse:

## More MyST features

- Create citations: https://jupyterbook.org/en/stable/tutorials/references.html#create-a-citation
- Adding images: https://jupyterbook.org/en/stable/content/figures.html
- More: https://jupyterbook.org/en/stable/content/index.html
* Create citations: https://jupyterbook.org/en/stable/tutorials/references.html#create-a-citation
* Adding images: https://jupyterbook.org/en/stable/content/figures.html
* More: https://jupyterbook.org/en/stable/content/index.html

---

## Publishing the book to GitHub pages

- Create a new file `.github/workflows/build_docs.yml` which contains a workflow for building the docs
- Also remember to go to your [repository settings on GitHub](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow) to allow for GitHub pages, see
- Also remember to go to your [repository settings on GitHub](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow) to allow for GitHub pages

---

### Example workflow
```yaml
# Simple workflow for deploying static content to GitHub Pages
name: Build docs

on:
workflow_dispatch:
workflow_call:
pull_request:
branches:
- main
push:
branches: "main"

jobs:
build_docs:
runs-on: ubuntu-22.04
env:
PYTHON_VERSION: "3.10"
PUBLISH_DIR: ./_build/html

steps:
# checkout the repository
- uses: actions/checkout@v4

# setup Python
- name: Install Python ${{ env.PYTHON_VERSION }}
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
python-version: "3.10"

# preserve pip cache to speed up installation
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('*requirements-docs.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip
Expand All @@ -280,35 +267,33 @@ jobs:
run: python3 -m jupyter book build .

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
uses: actions/upload-artifact@v3
with:
name: documentation
path: ${{ env.PUBLISH_DIR }}
path: ./_build/html
if-no-files-found: error
```

---

## Publishing the book to GitHub pages
### Publishing the book to GitHub pages

- Create a new file `.github/workflows/publish_docs.yml` which contains a workflow for publishing the docs to github pages

---

### Deploying the book
```yaml
name: Github Pages

on:
push:
branches: [main] # Only run on push to main
branches: [main]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
Expand All @@ -326,8 +311,7 @@ jobs:

runs-on: ubuntu-latest
steps:
- name: Download docs artifact
# docs artifact is uploaded by build-docs job
- name: Download docs artifact from build-docs
uses: actions/download-artifact@v3
with:
name: documentation
Expand All @@ -338,9 +322,6 @@ jobs:
with:
path: "./public"

- name: Checkout
uses: actions/checkout@v4

- name: Setup Pages
uses: actions/configure-pages@v3

Expand Down
Loading