Skip to content

Commit

Permalink
template jupyterbook
Browse files Browse the repository at this point in the history
  • Loading branch information
jagar2 committed Sep 18, 2024
1 parent b8c5e18 commit 524ccc0
Show file tree
Hide file tree
Showing 12 changed files with 515 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: deploy-book

on:
push:
branches:
- main

env:
BASE_URL: /${{ github.event.repository.name }}

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
deploy-book:
#if: github.actor == 'jagar2' && github.repository != 'jagar2/Fall_2024_MEM679_Data-Analysis-and-Machine-Learning-for-Science-and-Manufacturing'
runs-on: self-hosted
permissions:
pages: write
id-token: write
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Build the book
run: |
jupyter-book build ./notebooks
# Upload artifact and copy to SMB share
- name: Upload and Deploy
if: contains(github.event.head_commit.message, '#push')
run: |
id
SMBSHARE="/mnt/drexel_web/2024-CCSTAE" &&
rm -rf /mnt/drexel_web/2024-CCSTAE/* &&
JBPATH="./jupyterbook" &&
cp -r $JBPATH/_build/html/* $SMBSHARE
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

notebooks/_build
44 changes: 44 additions & 0 deletions notebooks/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Book settings
# Learn more at https://jupyterbook.org/customize/config.html

title: Extremely Noisy 4DSTEM Strain Mapping Using Cycle Consistent Spatial Transforming Autoencoders
author: Authors Here
logo: assets/Drexel_M3_Logo-01.png

# Force re-execution of notebooks on each build.
# See https://jupyterbook.org/content/execute.html
execute:
execute_notebooks: force

# Define the name of the latex output file for PDF builds
latex:
latex_documents:
targetname: book.tex

# Add a bibtex file so that we can create citations
bibtex_bibfiles:
- references.bib

# Information about where the book exists on the web
repository:
url: https://github.com/m3-learning/Extremely-Noisy-4DSTEM-Strain-Mapping-Using-Cycle-Consistent-Spatial-Transforming-Autoencoders # Online location of your book
path_to_book: docs # Optional path to your book, relative to the repository root
branch: main # Which branch of the repository should be used when creating links (optional)

# Add GitHub buttons to your book
# See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository
html:
use_issues_button: true
use_repository_button: true
static_path:
- _static
css:
- custom.css
use_issues_button: true
use_repository_button: true

# Adds colab button to book
launch_buttons:
colab_url: "https://colab.research.google.com"
jupyterhub_url: "https://engr131.nrp-nautilus.io/"
thebe: true
114 changes: 114 additions & 0 deletions notebooks/_static/theme.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/* Light theme */
html[data-theme="light"] {
--pst-color-primary: #002D72;
/* Drexel Blue */
--pst-color-secondary: #FFD100;
/* Drexel Yellow */
--pst-color-success: #9DAD33;
/* Light Green */
--pst-color-info: #006298;
/* Dark Blue */
--pst-color-warning: #FF8F1C;
/* Light Orange */
--pst-color-danger: #A50021;
/* Red */
--pst-color-text-base: #002D72;
/* Drexel Blue */
--pst-color-text-muted: #A7A8AA;
/* Cool Gray 6C */
--pst-color-border: #D1D5D8;
/* Light Gray */
--pst-color-shadow: #A7A8AA;
/* Cool Gray 6C */
--pst-color-background: #FFFFFF;
/* White */
--pst-color-on-background: #F5F5F5;
/* Light Gray */
--pst-color-surface: #F0F0F0;
/* Very Light Gray */
--pst-color-on-surface: #EDEDED;
/* Lighter Gray */
--pst-color-panel-background: var(--pst-color-background);
--pst-color-link: var(--pst-color-primary);
--pst-color-link-hover: var(--pst-color-secondary);
--pst-color-inline-code: #D64309;
/* Light Red */
--pst-color-target: #C4D600;
/* Green */

.only-dark {
display: none !important;
}

/* Header styling for light theme */
h1,
h2,
h3,
h4,
h5,
h6 {
color: var(--pst-color-primary);
/* Drexel Blue */
border-bottom: 2px solid var(--pst-color-secondary);
/* Drexel Yellow */
}
}

/* Dark theme */
html[data-theme="dark"] {
--pst-color-primary: #FFD100;
/* Drexel Yellow */
--pst-color-secondary: #002D72;
/* Drexel Blue */
--pst-color-success: #6CACE4;
/* Light Blue */
--pst-color-info: #C7E1D2;
/* Light Green */
--pst-color-warning: #D86018;
/* Orange */
--pst-color-danger: #A50021;
/* Red */
--pst-color-text-base: #ffffff;
/* White */
--pst-color-text-muted: #BCB4A5;
/* Warm Gray 3C */
--pst-color-border: #A7A8AA;
/* Cool Gray 6C */
--pst-color-shadow: var(--pst-color-background);
--pst-color-background: #001d48;
/* Drexel Blue */
--pst-color-on-background: #001d48;
/* Drexel Blue */
--pst-color-surface: #006298;
/* Dark Blue */
--pst-color-on-surface: #006298;
/* Dark Blue */
--pst-color-panel-background: var(--pst-color-background);
--pst-color-link: var(--pst-color-primary);
--pst-color-link-hover: var(--pst-color-secondary);
--pst-color-inline-code: #D86018;
/* Orange */
--pst-color-target: #FF8F1C;
/* Light Orange */

.only-light {
display: none !important;
}

img {
filter: brightness(0.8) contrast(1.2);
}

/* Header styling for dark theme */
h1,
h2,
h3,
h4,
h5,
h6 {
color: var(--pst-color-primary);
/* Drexel Yellow */
border-bottom: 2px solid var(--pst-color-secondary);
/* Drexel Blue */
}
}
9 changes: 9 additions & 0 deletions notebooks/_toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Table of contents
# Learn more at https://jupyterbook.org/customize/toc.html

format: jb-book
root: intro
chapters:
- file: markdown
- file: notebooks
- file: markdown-notebooks
Binary file added notebooks/assets/Drexel_M3_Logo-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions notebooks/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Welcome to your Jupyter Book

This is a small sample book to give you a feel for how book content is
structured.
It shows off a few of the major file types, as well as some sample content.
It does not go in-depth into any particular topic - check out [the Jupyter Book documentation](https://jupyterbook.org) for more information.

Check out the content pages bundled with this sample book to see more.

```{tableofcontents}
```
53 changes: 53 additions & 0 deletions notebooks/markdown-notebooks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
jupytext:
formats: md:myst
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.11.5
kernelspec:
display_name: Python 3
language: python
name: python3
---

# Notebooks with MyST Markdown

Jupyter Book also lets you write text-based notebooks using MyST Markdown.
See [the Notebooks with MyST Markdown documentation](https://jupyterbook.org/file-types/myst-notebooks.html) for more detailed instructions.
This page shows off a notebook written in MyST Markdown.

## An example cell

With MyST Markdown, you can define code cells with a directive like so:

```{code-cell}
print(2 + 2)
```

When your book is built, the contents of any `{code-cell}` blocks will be
executed with your default Jupyter kernel, and their outputs will be displayed
in-line with the rest of your content.

```{seealso}
Jupyter Book uses [Jupytext](https://jupytext.readthedocs.io/en/latest/) to convert text-based files to notebooks, and can support [many other text-based notebook files](https://jupyterbook.org/file-types/jupytext.html).
```

## Create a notebook with MyST Markdown

MyST Markdown notebooks are defined by two things:

1. YAML metadata that is needed to understand if / how it should convert text files to notebooks (including information about the kernel needed).
See the YAML at the top of this page for example.
2. The presence of `{code-cell}` directives, which will be executed with your book.

That's all that is needed to get started!

## Quickly add YAML metadata for MyST Notebooks

If you have a markdown file and you'd like to quickly add YAML metadata to it, so that Jupyter Book will treat it as a MyST Markdown Notebook, run the following command:

```
jupyter-book myst init path/to/markdownfile.md
```
55 changes: 55 additions & 0 deletions notebooks/markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Markdown Files

Whether you write your book's content in Jupyter Notebooks (`.ipynb`) or
in regular markdown files (`.md`), you'll write in the same flavor of markdown
called **MyST Markdown**.
This is a simple file to help you get started and show off some syntax.

## What is MyST?

MyST stands for "Markedly Structured Text". It
is a slight variation on a flavor of markdown called "CommonMark" markdown,
with small syntax extensions to allow you to write **roles** and **directives**
in the Sphinx ecosystem.

For more about MyST, see [the MyST Markdown Overview](https://jupyterbook.org/content/myst.html).

## Sample Roles and Directives

Roles and directives are two of the most powerful tools in Jupyter Book. They
are like functions, but written in a markup language. They both
serve a similar purpose, but **roles are written in one line**, whereas
**directives span many lines**. They both accept different kinds of inputs,
and what they do with those inputs depends on the specific role or directive
that is being called.

Here is a "note" directive:

```{note}
Here is a note
```

It will be rendered in a special box when you build your book.

Here is an inline directive to refer to a document: {doc}`markdown-notebooks`.


## Citations

You can also cite references that are stored in a `bibtex` file. For example,
the following syntax: `` {cite}`holdgraf_evidence_2014` `` will render like
this: {cite}`holdgraf_evidence_2014`.

Moreover, you can insert a bibliography into your page with this syntax:
The `{bibliography}` directive must be used for all the `{cite}` roles to
render properly.
For example, if the references for your book are stored in `references.bib`,
then the bibliography is inserted with:

```{bibliography}
```

## Learn more

This is just a simple starter to get you started.
You can learn a lot more at [jupyterbook.org](https://jupyterbook.org).
Loading

0 comments on commit 524ccc0

Please sign in to comment.