Skip to content

Commit

Permalink
Sphinx based docs with CI action to build and hosted on gh-pages (#119)
Browse files Browse the repository at this point in the history
* started rtd

* testing docs action

* update pip

* corrected python version

* added s to docs

* publish every time

* added static folder

* skipping ci for non code files

* changed to rerad the docs theme

* started install section

* added more sections

* added api class

* docs ci using conda

* added -y for freecad

* trying py 3.12

* mimic working conda ci

* using rst so no markdown convertion needed

* added github edit link

* removed path prints

* added readme link, badge

* format
  • Loading branch information
shimwell authored May 2, 2024
1 parent 956000d commit 1970ce7
Show file tree
Hide file tree
Showing 16 changed files with 505 additions and 74 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ on:
branches:
- dev
- main
paths-ignore:
- "**.md"
- "**.txt"
- "**.cff"
- 'docs/**'
- '.gitignore'
push:
branches:
- main
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: documentation

on:
pull_request:
branches:
- dev
- main
push:
branches:
- main

permissions:
contents: write

jobs:
testing:
name: Documentation
runs-on: "ubuntu-latest"
defaults:
run:
shell: bash -el {0}
strategy:
matrix:
python-version: ["3.11"]
steps:
- name: checkout actions
uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge

- name: install dependencies
run: conda install -c conda-forge freecad -y

- name: install package
run: |
pip install --upgrade pip
pip install .[docs]
- name: Sphinx build
run: |
sphinx-build docs _build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/
force_orphan: true
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Upload Python Package
name: PyPI Python Package

on:
release:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ Warning_Solids_definition.txt

.vscode
**/__pycache__

# documentation
_build
docs/source/_build/**
docs/build/**
docs/source/_autosummary/*
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[![CI testing](https://github.com/GEOUNED-org/GEOUNED/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/GEOUNED-org/GEOUNED/actions/workflows/ci.yml)

[![Upload Python Package](https://github.com/GEOUNED-org/GEOUNED/actions/workflows/python-publish.yml/badge.svg)](https://github.com/GEOUNED-org/GEOUNED/actions/workflows/python-publish.yml)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black)
[![documentation](https://github.com/GEOUNED-org/GEOUNED/actions/workflows/documentation.yml/badge.svg)](https://github.com/GEOUNED-org/GEOUNED/actions/workflows/documentation.yml)

:book: [Documentation](https://GEOUNED-org.github.io/GEOUNED/python_api.html)


# GEOUNED
A tool to convert from CAD to CSG & CSG to CAD for Monte Carlo transport codes (MCNP & OpenMC).
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 = .
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)
67 changes: 67 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# 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 --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys

sys.path.insert(0, os.path.abspath("../../src"))

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

project = "GEOUNED"
copyright = "2024, UNED"
author = "Juan-Pablo Catalan and Patrick Sauvan"

# The full version, including alpha/beta/rc tags
release = "1.0.1"


# -- 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_autodoc_typehints",
"sphinx.ext.coverage",
"sphinx.ext.napoleon",
"sphinx.ext.doctest",
"sphinx.ext.viewcode",
]

# 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 = ["_build", "Thumbs.db", ".DS_Store"]


# -- 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 = "sphinx_rtd_theme"

# 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"]

html_context = {
"display_github": True,
}
# html_favicon = "favicon.ico"
4 changes: 4 additions & 0 deletions docs/developer_guide.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Developer guide
===============

TOOD
20 changes: 20 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. GEOUNED documentation master file, created by
sphinx-quickstart on Tue Apr 30 09:47:11 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
GEOUNED
=======

GEOUNED converts CAD to Constructive Solid Geometry (CSG) formats for use in
Monte Carlo transport codes.
Supported codes include OpenMC, PHITS, Serpent and MCNP.

.. toctree::
:maxdepth: 2

install
usage
python_api
methodology
developer_guide
172 changes: 172 additions & 0 deletions docs/install.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
Install
=======

There are several options for installing GEOUNED package.
The installation selected has implications for how you run GEOUNED Python scripts.
Currently the Mamba / Conda install is the recommended method.
The main difficulty in installing GEOUNED is integration between the main dependnacy (FreeCAD) and the users system Python.
Mamba / Conda provides the a connection between the FreeCAD Python library and your system Python.
Users have had success installing FreeCAD and making use of the FreeCAD Python as well so these installation methods are listed for completeness.


Linux
-----

Mamba
~~~~~

First we need to install a Mamba distribution. There are a few options but here we opt for Miniforge3 as it includes Mamba.

You can follow the install instructions for `Miniforge3 here <https://github.com/conda-forge/miniforge>`_ or follows the commands below.
Download

.. code-block:: sh
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
bash Miniforge3-$(uname)-$(uname -m).sh
Install Miniforge3

.. code-block:: sh
bash Miniforge3-Linux-x86_64.sh
Activate the base environment in your current terminal

.. code-block:: sh
mamba activate
It is recommended to create a new environment

.. code-block:: sh
mamba create --name new_new python=3.11
Activate the new environment

.. code-block:: sh
mamba activate new_new
We have aspirations to create a conda-forge package which will combine these final two steps, but for now FreeCAD and GEOUNED can be installed in two commands.
Install FreeCAD which is the main dependency

.. code-block:: sh
mamba install -c conda-forge freecad
Install GEOUNED with pip

.. code-block:: sh
pip install git+https://github.com/GEOUNED-code/GEOUNED.git
Then you will be able to run import GEOUNED from within Python

.. code-block:: python
import geouned
Conda
~~~~~

First we need to install a Conda distribution. There are a few options but we here we opt for [MiniConda3](https://docs.anaconda.com/free/miniconda/) as it downloads quicker than the fuller [AnaConda](https://www.anaconda.com/download).

You can follow the install instructions for [MiniConda3 here](https://docs.anaconda.com/free/miniconda/) or follow the commands below.
Download.

.. code-block:: sh
mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
Install MiniConda3

.. code-block:: sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
Activate the base environment in your current terminal

.. code-block:: sh
~/miniconda3/bin/conda init bash
It is recommended to create a new environment

.. code-block:: sh
conda create --name new_new python=3.11
Activate the new environment

.. code-block:: sh
conda activate new_new
We have aspirations to create a conda-forge package which will combine these final two steps, but for now FreeCAD and GEOUNED can be installed in two commands.
Install FreeCAD which is the main dependency

.. code-block:: sh
conda install -c conda-forge freecad
Install GEOUNED with pip

.. code-block:: sh
pip install git+https://github.com/GEOUNED-code/GEOUNED.git
Then you will be able to run import GEOUNED from within Python

.. code-block:: python
import geouned
Apt-get
~~~~~~~

Snap
~~~~

AppImage
~~~~~~~~

Mac
---


Mamba
~~~~~

Conda
~~~~~

Brew
~~~~


Windows
-------

Mamba
~~~~~

Conda
~~~~~

Portable FreeCAD installer
~~~~~~~~~~~~~~~~~~~~~~~~~~

Windows Subsystem for Linux (WSL)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Loading

0 comments on commit 1970ce7

Please sign in to comment.