Skip to content

Commit 5cbe874

Browse files
authored
Merge pull request #467 from PNNL-CompBio/documentation-staging
Documentation staging
2 parents 14e793c + 90801f1 commit 5cbe874

File tree

167 files changed

+53149
-14640
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+53149
-14640
lines changed

.github/workflows/sphinx.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Sphinx-docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- documentation-staging
8+
workflow_dispatch:
9+
10+
jobs:
11+
pages:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install Pandoc
17+
uses: pandoc/actions/setup@v1
18+
with:
19+
version: 3.5
20+
21+
- name: Install dependencies
22+
run: pip install -r docs/requirements.txt
23+
24+
- name: Build HTML
25+
run: python -m sphinx.cmd.build -M html docs/source docs/build
26+
27+
- name: Upload artifacts
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: html-docs
31+
path: docs/build/html/
32+
33+
# - name: Deploy
34+
# uses: sphinx-notes/pages@v3
35+
# with:
36+
# publish: true
37+
38+
- name: Deploy
39+
uses: peaceiris/actions-gh-pages@v3
40+
with:
41+
github_token: ${{ secrets.DOCSITE_TOKEN }}
42+
publish_branch: gh-pages
43+
publish_dir: docs/build/html

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 = source
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)

coderdata/dataset.yml

Lines changed: 236 additions & 170 deletions
Large diffs are not rendered by default.
File renamed without changes.

docs/.nojekyll

Whitespace-only changes.

docs/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 = source
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)

docs/README.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
2+
# Documentation Site Using Sphinx
3+
4+
This document includes:
5+
- [The Sphinx local directory structure](#local-directory-structure)
6+
- [Sphinx commands](#sphinx-commands)
7+
- [Guide to updating the documentation site](#updating-the-documentation-site)
8+
- [Helpful sphinx features](#helpful-sphinx-features)
9+
- [Site Deployment](#deploying-the-documentation-site-using-github-actions)
10+
11+
12+
## Local Directory Structure
13+
14+
![Directory Structure](local_struct.jpg?raw=true)
15+
16+
## Sphinx Commands
17+
18+
### Dependencies
19+
20+
Included in `coderdata/docs/requirements.txt`. Example installations that enable various sphinx extensions.
21+
22+
- sphinx
23+
- myst-parser - adds support for markdown files
24+
- sphinx-design - provides extra design functions (i.e buttons and grids)
25+
- nbsphinx - enables rendering of .ipynb files
26+
- sphinx_tabs - adds tabbed content components
27+
28+
### Build
29+
30+
To build the Sphinx documentation locally, navigate to the `docs/` directory and run the `sphinx-build` command. This command processes the content files from the `docs/source/` directory and generates the rendered HTML output in the `docs/build/` directory.
31+
32+
```sh
33+
$ cd ../coderdata/docs
34+
35+
$ python -m sphinx.cmd.build -M html <SOURCEDIR/> <OUTPUTDIR/>
36+
37+
$ python -m sphinx.cmd.build -M html source/ build/
38+
```
39+
To view the rendered site open `coderdata/docs/build/html/index.html`.
40+
41+
### Quickstart
42+
43+
To create a basic sphinx set-up in a local repository use sphinx quickstart command.
44+
45+
```sh
46+
$ cd ../repo/docs
47+
$ python -m sphinx.cmd.quickstart
48+
```
49+
Questions will follow this command and when it prompts if you'd like to separate the source and build directories select yes.
50+
51+
## Updating the Documentation Site
52+
53+
The `conf.py` file is the central configuration file for Sphinx and it determines the behavior and appearance of the generated documentation. Specifically it configures extensions, defines metadata, controls output settings, and customizes sphinx behavior. The `index.rst` file is the starting page for the Sphinx documentation build process. It acts as the root file, linking all other pages and defining the document hierarchy. All other .md and .rst files are added and internally referenced within the index page and/or within the sidebar.
54+
55+
### Pages
56+
**Note:** All updates will be made in the `documentation-staging` branch.\
57+
To update pages navigate to `docs/source/`, all .rst and .md files live here. Here is a reference of the main pages used for the documentation site. The tutorial page consists if the docsite_tutorial.ipynb converted to an html. The notebook lives in `docs/source/_notebooks/` and is converted to an html during the build process based on code within `conf.py`.
58+
59+
| Page | File Name | Content |
60+
| -----------------| ----------------------------------------------------------------------- | ------------------------------ |
61+
| Home Page | index.rst | Introduction and Install |
62+
| Usage | usage.md | API and CLI |
63+
| API Reference | APIreference.rst | Autogenerated documentation from docstrings|
64+
| Datasets | datasets_included.rst | Datasets overview |
65+
| Tutorial | docsite_tutorial.ipynb | Deep Learning Tutorial |
66+
| Contributing | contribution_guide.rst *includes contribution.md and add_code_guide.md* | Contribution Guide |
67+
68+
**Note:**
69+
- When adding pages, reStructuredText files are the most sphinx friendly and allow for use of helpful directives. However, Markdown files can be used and will render properly when the myst-parser extension is used.
70+
- New pages must be added to the `.. toctree::` in the `index.rst` to be recognized by Sphinx.
71+
- Currently the API reference does not include documentation for `plot_2D_respones_metric`, `format`, `split_train_test_validate`, and `split_train_other`. It seems that the most updated `coderdata` directory currently does not include docstrings for these functions.
72+
73+
### Tutorial
74+
75+
The tutorial is sourced in `source/_notebooks/` and when built pushed to `_notebooks/` in `gh-pages` branch. It uses nbsphinx extension to convert from .ipynb to an html and is referenced in the `index.rst` and the `my_custom_sidebar.html`. The dependencies for this should only be needed in your local environment and not in the `requirements.txt`.
76+
77+
### Images and Graphics
78+
79+
To add any new images they will live in `docs/source/_static/` and when built are pushed to `_images` in `gh-pages` branch. The coderdata_header.jpg was made using [canva](https://www.canva.com/) and coderdata_1.jpg was made using biorender.
80+
81+
### Site Theme and Design
82+
83+
The original sphinx theme used is 'sphinxdoc', however, to change certain aspects I created `custom.css` to override the sphinxdoc theme. To update the custom theme navigate to `docs/source/_static/custom.css`. Changes to the sidebar can be made in `docs/source/_templates/my_custom_sidebar.html`. Any other custom templates will be added to `docs/source/_templates/`.
84+
85+
**Note:** The sphinxdoc theme is auto-generated during the build command into `docs/build/html/_static/sphinxdoc.css`. It is regenerated everytime sphinx build runs so changes must be made in custom.css.
86+
87+
88+
## Helpful Sphinx Features
89+
90+
### Site Links
91+
92+
- [sphinx-doc.org](https://www.sphinx-doc.org/en/master/index.html)
93+
- [sphinx.org/sample-sites](https://sphinx-themes.org/sample-sites/default-sphinxdoc/)
94+
- [sphinx.org/directives](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#rst-directives)
95+
96+
97+
### Directives and Examples Used in CoderData Documentation
98+
99+
- .. automodule::
100+
This is used to generate documentation from the package. It is used in API reference.
101+
102+
```sh
103+
.. automodule:: <pkg>.module
104+
:members: <function>
105+
:undoc-members:
106+
:show-inheritance:
107+
```
108+
109+
- .. include::
110+
To include content from another file. Example shows how to render a markdown file when using the include call.
111+
112+
```sh
113+
.. include:: guide.md
114+
:parser: myst_parser.sphinx_
115+
```
116+
117+
- .. image::
118+
119+
```sh
120+
.. image:: _static/image.png
121+
:align: center
122+
:scale: 100%
123+
```
124+
## Deploying the Documentation Site Using Github Actions
125+
126+
### Directory Structure for Deployment with Relevant Branches
127+
128+
![Directory Structure](deploy_struct.jpg?raw=true)
129+
130+
### Site Deployment
131+
132+
- We added `sphinx.yml` to the `.github/workflows/` directory in the `documentation-staging` branch.
133+
134+
- Then in `documentation-staging` we included all the source directory files that are needed to build the documentation. (These are all the same files that are needed to build the documentation locally, the only addition is `requirements.txt`).
135+
**Note:** If you have been building the documentation locally and then are moving to commit to the staging branch there is no need to include any files from `docs/build/` directory.
136+
137+
- Once a push is made from `documentation-staging` the workflow is triggered.
138+
139+
- The built html files are then deployed to the root of the `gh-pages` branch. The included files in the branch are shown in the graphic above.
140+
141+
**Note:** When updates to the python files in `coderdata` directory occur in `main`, those changes must be transfered to the `documentation-staging` branch in order for Sphinx to see the updated docstrings with the functions and correctly autogenerate the documentation for the API reference page.

docs/Rplots.pdf

-5.76 KB
Binary file not shown.

docs/_config.yml

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

docs/_data/beataml_table.csv

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

0 commit comments

Comments
 (0)