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

Adding documentation builds #15

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
56 changes: 56 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Documentation Build"
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
cancel-in-progress: true
on:
- pull_request
- release

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[doc]

- name: Build documentation
run: |
make -C docs html

- uses: actions/upload-artifact@v2
with:
name: DocumentationHTML
path: docs/build/html/

# Publish built docs to gh-pages branch
- name: Commit documentation changes
# push docs only when a GitHub Release is made
if: github.event_name == 'release' && github.event.action == 'published'
run: |
git clone https://github.com/IMAP-Science-Operations-Center/imap_processing.git --branch gh-pages --single-branch gh-pages
cp -r docs/build/html/* gh-pages/
cd gh-pages
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Update documentation" -a || true
# The above command will fail if no changes were present, so we ignore that.

- name: Publish docs
# push docs only when a GitHub Release is made
if: github.event_name == 'release' && github.event.action == 'published'

uses: ad-m/github-push-action@master
with:
branch: gh-pages
directory: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Documentation ignore
docs/source/reference/generated

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
29 changes: 29 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Documentation

## Building documentation

1. Install the documentation dependencies
2. Build the html documents under the `docs` directory

Using poetry:

```bash
# Install the optional documentation dependencies
poetry install --extras "doc"
# Make the html documentation
cd docs/source
poetry run sphinx-build . build
greglucas marked this conversation as resolved.
Show resolved Hide resolved
# View the documentation
open build/html/index.html
```

Using pip:

```bash
# Install the optional documentation dependencies
pip install .[doc]
# Make the html documentation
make -C docs html
# View the documentation
open docs/build/html/index.html
```
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
greglucas marked this conversation as resolved.
Show resolved Hide resolved
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
Empty file added docs/source/.nojekyll
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"""
Configuration file for the Sphinx documentation builder.

This file only contains a selection of the most common options. For a full
list see the documentation:
https://www.sphinx-doc.org/en/master/usage/configuration.html
"""

# -- Path setup --------------------------------------------------------------

import sys

# If extensions (or modules to document with autodoc) are in another directory,
greglucas marked this conversation as resolved.
Show resolved Hide resolved
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use resolve() to make it absolute, like shown here.
#
from pathlib import Path

import imap_processing

sys.path.insert(0, Path("../../imap_processing").resolve())

# -- Project information -----------------------------------------------------

project = "imap_processing"
copyright = "2023, Regents of the University of Colorado"
author = "IMAP Science Operations Center"

# The full version, including alpha/beta/rc tags
release = imap_processing.__version__


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.githubpages", # Helpful for publishing to gh-pages
"sphinx.ext.napoleon",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "pydata_sphinx_theme"

html_logo = "_static/imap-mark-hor-multicolor-dark.png"

html_theme_options = {
"github_url": "https://github.com/IMAP-Science-Operations-Center/imap_processing",
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]

# Autosummary
autosummary_generate = True
35 changes: 35 additions & 0 deletions docs/source/development/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.. _development:

Development
===========

To contribute to imap_processing, you can fork the GitHub repository,
add your code, and make a pull request. If you are adding additional functionality,
you should also include a test with your enhancement.

imap_processing is designed to be run in a containerized environment, so
the dependencies will be locked in after a release and the data products will
be versioned appropriately to correspond with the code that produced them.

A typical development workflow might look like the following:

.. code:: bash

# Install the development dependencies
pip install .[dev]

# Install the pre-commit hooks
pre-commit install

# Update the code on a feature branch
git checkout -b my-cool-feature

# Run the tests
pytest

# Commit the changes and push to your remote repository
git add my-file
git commit
git push -u origin my-cool-feature
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a great content to add to style guide. Or style guild could be included in this automated doc generator.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I agree, I think the style guide should either go into the docs, or vice-versa the style guide point to the docs.


# Go to GitHub and open a pull request!
44 changes: 44 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

IMAP Processing Documentation
=============================

The Interstellar Mapping and Acceleration Probe (IMAP) is an exciting project
aimed at studying the interstellar medium and investigating the acceleration
mechanisms of particles within our galaxy. IMAP utilizes cutting-edge
technology and advanced instrumentation to gather valuable data and expand
our understanding of space.

The IMAP project's Git repository serves as a centralized hub for collaboration
among researchers, scientists, and developers involved in the project.
It provides a platform for version control, code sharing, issue tracking,
and documentation, fostering a collaborative environment for advancing
the goals of the IMAP mission.

Through the Git repository, contributors can access project resources,
explore the codebase, propose enhancements or bug fixes, and participate
in discussions with other team members. This collaborative approach promotes
efficient development and fosters innovation in the pursuit of interstellar
mapping and particle acceleration research.

Join the IMAP Git repository to be part of an exciting scientific endeavor,
contribute your expertise, and help unlock the mysteries of the interstellar
medium and particle acceleration in our galaxy. Together, we can advance our
knowledge of the cosmos and pave the way for future discoveries in space
exploration.

The [IMAP Website](https://imap.princeton.edu/) contains information about the
entire mission, including the science goals, the spacecraft, and the instruments.
The Science Operations Center (SOC) is responsible for the data processing on the
IMAP mission and being developed at
[LASP (Laboratory of Atmospheric and Space Physics)](https://lasp.colorado.edu/).
greglucas marked this conversation as resolved.
Show resolved Hide resolved

The explicit code interfaces and structure are described in the :ref:`api`.

.. toctree::
:maxdepth: 1

reference/index
development/index

If you make use of any imap_processing code, please consider citing it in your research.
TODO: Add a Zenodo DOI badge here.
26 changes: 26 additions & 0 deletions docs/source/reference/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.. _api:

API reference
=============

.. currentmodule:: imap_processing

This page gives an overview of the routines within the imap_processing package.
The package is organized by instrument, meaning each instrument is its own
module and has submodules for each processing step.

Instruments
-----------

.. toctree::
:maxdepth: 1

swe


Utility functions can be found in modules within the top package level.

.. autosummary::
:toctree: generated/

decom
16 changes: 16 additions & 0 deletions docs/source/reference/swe.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. _swe:

SWE (Solar Wind Electrons)
==========================

.. currentmodule:: imap_processing.swe

This is the SWE Instrument module, which contains the code for processing
data from the SWE instrument.

The L0 code to decommutate the CCSDS packet data can be found below.

.. autosummary::
:toctree: generated/

decom_swe
1 change: 1 addition & 0 deletions imap_processing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.0"
Loading