Skip to content

Commit 548883a

Browse files
committed
preparing for moving lesson to sphinx
1 parent 348d263 commit 548883a

21 files changed

+261
-114
lines changed

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
_drafts/
2-
_site/
3-
.sass-cache
1+
.jupyter_cache/
2+
_build/

Gemfile

Lines changed: 0 additions & 2 deletions
This file was deleted.

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = content
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

_config.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

_episodes/01-wishlist.md renamed to content/01-wishlist.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
---
2-
layout: episode
3-
title: "Motivation and wishlist"
4-
teaching: 15
5-
exercises: 25
6-
questions:
7-
- Why documenting code?
8-
- What is our wishlist on a suitably good documentation?
9-
objectives:
10-
- Arrive at a checklist for designing and deploying code documentation.
11-
keypoints:
12-
- Documentation is part of the code and should be versionable.
13-
- Documentation (sources) should be tracked with the corresponding code in the same repository.
14-
- Use lightweight and standard markup languages such as reStructuredText or Markdown.
15-
---
1+
# Motivation and wishlist
2+
3+
```{questions}
4+
- Why documenting code?
5+
- What is our wishlist on a suitably good documentation?
6+
```
7+
8+
```{objectives}
9+
- Arrive at a checklist for designing and deploying code documentation.
10+
```
1611

1712
## Why documenting code?
1813

@@ -171,3 +166,9 @@ or verbally), please do!
171166

172167
- [A beginner’s guide to writing documentation](http://www.writethedocs.org/guide/writing/beginners-guide-to-docs/)
173168
- [What nobody tells you about documentation](https://www.divio.com/blog/documentation/)
169+
170+
```{keypoints}
171+
- Documentation is part of the code and should be versionable.
172+
- Documentation (sources) should be tracked with the corresponding code in the same repository.
173+
- Use lightweight and standard markup languages such as reStructuredText or Markdown.
174+
```

_episodes/03-tools.md renamed to content/03-tools.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
---
2-
layout: episode
3-
title: "Popular tools and solutions"
4-
teaching: 10
5-
exercises: 0
1+
# Popular tools and solutions
2+
63
questions:
74
- What tools are out there?
85
- What are their pros and cons?
96
objectives:
107
- Choose the right tool for the right reason.
118
keypoints:
129
- Some popular solutions make reproducibility and maintenance of multiple code versions difficult.
13-
---
10+
1411

1512
## What tools and solutions are out there?
1613

_episodes/04-sphinx.md renamed to content/04-sphinx.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
---
2-
layout: episode
3-
title: "Sphinx and reStructuredText"
4-
teaching: 5
5-
exercises: 15
1+
# Sphinx and reStructuredText
2+
63
questions:
74
- How do we get started on writing Sphinx documentation in RST?
85
objectives:

_episodes/05-rtd-gitlab.md renamed to content/05-rtd-gitlab.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
---
2-
layout: episode
3-
title: "Deploying Sphinx documentation to Read the Docs"
4-
teaching: 0
5-
exercises: 20
1+
# Deploying Sphinx documentation to Read the Docs
2+
63
questions:
74
- How do Python projects deploy their documentation?
85
- Can we use their solutions for projects which do not use Python?

_episodes/05-rtd.md renamed to content/05-rtd.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
---
2-
layout: episode
3-
title: "Deploying Sphinx documentation to Read the Docs"
4-
teaching: 0
5-
exercises: 20
1+
# Deploying Sphinx documentation to Read the Docs
2+
63
questions:
74
- How do Python projects deploy their documentation?
85
- Can we use their solutions for projects which do not use Python?

_episodes/06-gh-pages.md renamed to content/06-gh-pages.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
---
2-
layout: episode
3-
title: Hosting websites/homepages on GitHub Pages
4-
teaching: 0
5-
exercises: 20
1+
# Hosting websites/homepages on GitHub Pages
2+
63
questions:
74
- How to serve a website/homepage using GitHub
85
---
@@ -27,7 +24,11 @@ material is hosted.
2724

2825
---
2926

30-
<img src="{{ site.baseurl }}/img/gh-pages.jpg" width="50%">
27+
```{figure} img/gh-pages.svg
28+
:alt: Scheme that describes how branch names end up websites
29+
30+
Scheme that describes how branch names end up websites.
31+
```
3132

3233
---
3334

_episodes/07-discussion.md renamed to content/07-discussion.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
---
2-
layout: episode
3-
title: "Discussion after the exercises"
4-
teaching: 5
5-
exercises: 0
1+
# Discussion after the exercises
2+
63
questions:
74
- What recommendations can we take home?
85
---

content/conf.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
# import os
14+
# import sys
15+
# sys.path.insert(0, os.path.abspath('.'))
16+
17+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = "Code documentation lesson"
21+
copyright = "2021, CodeRefinery team"
22+
author = "CodeRefinery team"
23+
github_user = "coderefinery"
24+
github_repo_name = "" # auto-detected from dirname if blank
25+
github_version = "main"
26+
conf_py_path = "/content/" # with leading and trailing slash
27+
28+
# -- General configuration ---------------------------------------------------
29+
30+
# Add any Sphinx extension module names here, as strings. They can be
31+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
32+
# ones.
33+
extensions = [
34+
# githubpages just adds a .nojekyll file
35+
"sphinx.ext.githubpages",
36+
"sphinx_lesson",
37+
# remove once sphinx_rtd_theme updated for contrast and accessibility:
38+
"sphinx_rtd_theme_ext_color_contrast",
39+
]
40+
41+
# Settings for myst_nb:
42+
# https://myst-nb.readthedocs.io/en/latest/use/execute.html#triggering-notebook-execution
43+
# jupyter_execute_notebooks = "off"
44+
# jupyter_execute_notebooks = "auto" # *only* execute if at least one output is missing.
45+
# jupyter_execute_notebooks = "force"
46+
jupyter_execute_notebooks = "cache"
47+
48+
# Add any paths that contain templates here, relative to this directory.
49+
# templates_path = ['_templates']
50+
51+
# List of patterns, relative to source directory, that match files and
52+
# directories to ignore when looking for source files.
53+
# This pattern also affects html_static_path and html_extra_path.
54+
exclude_patterns = [
55+
"README*",
56+
"_build",
57+
"Thumbs.db",
58+
".DS_Store",
59+
"jupyter_execute",
60+
"*venv*",
61+
]
62+
63+
64+
# -- Options for HTML output -------------------------------------------------
65+
66+
# The theme to use for HTML and HTML Help pages. See the documentation for
67+
# a list of builtin themes.
68+
#
69+
html_theme = "sphinx_rtd_theme"
70+
71+
# Add any paths that contain custom static files (such as style sheets) here,
72+
# relative to this directory. They are copied after the builtin static files,
73+
# so a file named "default.css" will overwrite the builtin "default.css".
74+
# html_static_path = ['_static']
75+
76+
77+
# HTML context:
78+
from os.path import basename, dirname, realpath
79+
80+
html_context = {
81+
"display_github": True,
82+
"github_user": github_user,
83+
# Auto-detect directory name. This can break, but
84+
# useful as a default.
85+
"github_repo": github_repo_name or basename(dirname(realpath(__file__))),
86+
"github_version": github_version,
87+
"conf_py_path": conf_py_path,
88+
}
89+
90+
# Intersphinx mapping. For example, with this you can use
91+
# :py:mod:`multiprocessing` to link straight to the Python docs of that module.
92+
# List all available references:
93+
# python -msphinx.ext.intersphinx https://docs.python.org/3/objects.inv
94+
# extensions.append('sphinx.ext.intersphinx')
95+
# intersphinx_mapping = {
96+
# #'python': ('https://docs.python.org/3', None),
97+
# #'sphinx': ('https://www.sphinx-doc.org/', None),
98+
# #'numpy': ('https://numpy.org/doc/stable/', None),
99+
# #'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
100+
# #'pandas': ('https://pandas.pydata.org/docs/', None),
101+
# #'matplotlib': ('https://matplotlib.org/', None),
102+
# 'seaborn': ('https://seaborn.pydata.org/', None),
103+
# }

guide.md renamed to content/guide.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
---
2-
layout: default
3-
permalink: /guide/
4-
---
5-
61
# Instructor guide
72

83
* [Why we teach this lesson](#why-we-teach-this-lesson)
File renamed without changes.
File renamed without changes.
File renamed without changes.

content/index.rst

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
Code documentation lesson
2+
=========================
3+
4+
In this lesson we will discuss different solutions for implementing and
5+
deploying code documentation.
6+
7+
We will learn how to build documentation with the
8+
**documentation generator** [Sphinx](http://www.sphinx-doc.org) (and compare it
9+
with others) and how to
10+
deploy it to [Read the Docs](https://readthedocs.org), a service which hosts
11+
open documentation for free.
12+
13+
This demonstration will be **independent of programming languages** and relevant
14+
also for your Fortran, C, C++, R, or Matlab projects.
15+
16+
We will also learn how
17+
to deploy a **project website or personal homepage** to [GitHub Pages](https://pages.github.com).
18+
The approach that we will learn will be transferable to
19+
[GitLab Pages](https://about.gitlab.com/features/pages/) and
20+
[Bitbucket Pages](https://pages.bitbucket.io).
21+
22+
23+
.. prereq::
24+
25+
1. Basic understanding of Git.
26+
27+
2. You need to have [Sphinx](http://www.sphinx-doc.org) installed (as part of your Python environment installation).
28+
29+
3. You need a [GitHub](https://github.com) account (if you want to deploy the documentation via GitHub).
30+
31+
32+
.. csv-table::
33+
:widths: auto
34+
:delim: ;
35+
36+
15 min ; :doc:`01-wishlist`
37+
10 min ; :doc:`03-tools`
38+
20 min ; :doc:`04-sphinx`
39+
20 min ; :doc:`05-rtd-gitlab`
40+
20 min ; :doc:`05-rtd`
41+
20 min ; :doc:`06-gh-pages`
42+
5 min ; :doc:`07-discussion`
43+
44+
45+
.. toctree::
46+
:maxdepth: 1
47+
:caption: The lesson
48+
49+
01-wishlist.md
50+
03-tools.md
51+
04-sphinx.md
52+
05-rtd-gitlab.md
53+
05-rtd.md
54+
06-gh-pages.md
55+
07-discussion.md
56+
57+
58+
.. toctree::
59+
:maxdepth: 1
60+
:caption: Reference
61+
62+
guide

index.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

jekyll-common

Submodule jekyll-common deleted from 4fb9b5f

0 commit comments

Comments
 (0)