Skip to content

Commit

Permalink
Sphinx documentation (#105)
Browse files Browse the repository at this point in the history
* Sphinx documentation

* Clean up for singlehtml option

* add docs GitHub action

* add docs GitHub action

* add docs GitHub action

* add docs GitHub action

* add docs GitHub action

* add docs GitHub action

* add docs GitHub action

* change pythonpath

* remove old files

* remove old files

* remove old files

* remove redundant functions

* remove redundant functions

* .yml renive install

* .yml

* .yml

* .yml

* .yml

* .yml

* .yml debug

* .yml debug

* .yml debug

* .yml adjust build target path

* .yml reconfigure build path to carmm/docs

* remove redundant file

* .yml debug

* .yml point to main folder

* Move the build docs to the github repo

* fix .yml syntax

* revert

* create a docs artifact

* GitHub Pages now use gh-pages

* rerun all jobs

* add a github pages deployment in a .yml form using stored artifact

* add version to deploy-pages

* fix syntax .yml

* fix syntax .yml

* fix syntax .yml

* Deploy Github Pages workflow

* trigger sequence altered

* trigger sequence altered

* introduce dependancies

* test trigger on pull

* remove dependency for test

* dependency on docs.yml

* .yml debug

* .yml debug

* .yml debug

* .yml debug formatting

* combine deployment and building

* combine deployment and building

* adjust artifact name

* revert to separate docs build

* .nojekyll added to artifact

* use github-push-action

* use github-push-action

* fix .yml syntax

* fix .yml syntax

* fix .yml syntax

* fix .yml syntax

* attempt fix to trigger job

* update docs.yml

* Change the behaviour to update documentation on push to main
  • Loading branch information
ikowalec committed Mar 4, 2024
1 parent 6c6e942 commit 4d5b506
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 3 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Sphinx

on:
push:
branches:
- main

jobs:
build_docs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Install Sphinx and necessary dependencies
run: |
python -m pip install --upgrade pip
pip install sphinx sphinx-autodoc-typehints sphinx-rtd-theme
# Ensure the Python environment setup is consistent with the main.yml
- name: Setup Python environment
run: |
echo "PYTHONPATH=/home/runner/work/carmm/carmm:$PYTHONPATH" >> $GITHUB_ENV
# Build the documentation dynamically from docstrings in the code
- name: Build Sphinx API documentation
run: |
sphinx-apidoc -o carmm/docs/source .
# Build a website based on the retrieved docstrings
- name: Build Sphinx HTML
run: |
sphinx-build -b html carmm/docs/source docs
# tell GitHub not to use the Jekyll builder explicitly
- name: Prevent using Jekyll to use static files properly
run: |
touch docs/.nojekyll
# Publish built docs to gh-pages branch.
- name: Commit documentation changes
run: |
git clone https://github.com/logsdail/carmm.git --branch gh-pages --single-branch gh-pages
cp -r docs/* gh-pages/docs
cd gh-pages
git config --local user.email "action@github.com"
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: Push changes
uses: ad-m/github-push-action@master
with:
branch: gh-pages
directory: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ name: linter-check
on:
push:
# Only running on master in case there are direct merges
branches: [ master ]
#branches: [ master, ReactAims_documentation, harry_branch, cube_file_read, jack_molecules, ob ]
branches: [ main ]

pull_request:
# Run on all pull requests when updated.

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: ci-tests
on:
push:
# Only running on master in case there are direct merges
branches: [ master ]
branches: [ main ]
#branches: [ master, ReactAims_documentation, harry_branch, cube_file_read, jack_molecules, ob ]
pull_request:
# Run on all pull requests when updated.
Expand Down
20 changes: 20 additions & 0 deletions carmm/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)
35 changes: 35 additions & 0 deletions carmm/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

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
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.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

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

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

:end
popd
27 changes: 27 additions & 0 deletions carmm/docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'CARMM'
copyright = '2024, Logsdail Group'
author = 'Logsdail Group'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx_autodoc_typehints', ]

templates_path = ['_templates']
exclude_patterns = []



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'alabaster'
html_static_path = ['_static']
20 changes: 20 additions & 0 deletions carmm/docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. CARMM documentation main file, created by
sphinx-quickstart on Thu Feb 29 16:57:31 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to CARMM's documentation!
=================================

.. toctree::
:maxdepth: 4
:caption: Contents:



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

0 comments on commit 4d5b506

Please sign in to comment.