Skip to content

Commit

Permalink
Files for setting up the github workflow/Docs were copied from MALA a…
Browse files Browse the repository at this point in the history
…nd originally authored by Daniel Kotik

Co-authored-by: Daniel Kotik <d.kotik@hzdr.de>
  • Loading branch information
RandomDefaultUser and DanielKotik committed Aug 16, 2021
1 parent 2e479da commit c204ecf
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: docs

on:
pull_request:
branches:
- master
- develop
- main
push:
branches:
- main
- develop

jobs:
test-docstrings:
runs-on: ubuntu-18.04
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: Upgrade pip
run: python3 -m pip install --upgrade pip

- name: Install dependencies
run: pip install -qU pydocstyle

- name: Check docstrings
run: pydocstyle --convention=numpy malada

build-and-deploy-pages:
needs: test-docstrings
runs-on: ubuntu-18.04
steps:
- name: Check out repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # 0 fetches complete history and tags

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: Upgrade pip
run: python3 -m pip install --upgrade pip

- name: Install dependencies
run: |
pip install -q -r docs/requirements.txt
- name: Build API and docs
run: |
sphinx-apidoc -o docs/source/api malada
sphinx-build -W --keep-going -b html -d docs/_build/doctrees docs/source docs/_build/html
mv -v docs/_build/html public
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
23 changes: 23 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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)

apidocs:
sphinx-apidoc -f -o source/api ../malada
5 changes: 5 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
docutils==0.16 # dependency of myst-parser; problems with 0.17.*
sphinx==3.5.*
sphinx_rtd_theme==0.5.*
myst-parser==0.14.*
sphinx-markdown-tables==0.0.15
112 changes: 112 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# 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 subprocess
import sys
# sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('../../'))


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

project = 'Materials Learning Algorithms Data Acquisition (MALADA)'
copyright = 'noneyet'

author = 'L. Fiedler'

# The version info for the project
tag = subprocess.run(['git', 'describe', '--tags'], capture_output=True,
text=True)
version = tag.stdout.strip()


# -- 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 = [
'myst_parser',
'sphinx_markdown_tables',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon',
# 'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
]

napoleon_google_docstring = False
napoleon_numpy_docstring = True

autodoc_mock_imports = [
'ase',
'optuna',
'mpmath',
'torch',
'numpy',
'scipy',
'oapackage',
'matplotlib',
'horovod',
'lammps',
'total_energy',
]

autodoc_member_order = 'groupwise'

# 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 = '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 = []

html_context = {
'display_github': True,
'github_repo': 'mala-project/malada',
'github_version': 'develop',
'conf_py_path': '/docs/source/',
}

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = "./img/logos/mala_vertical.png"

# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
html_favicon = "./img/logos/mala_favicon.png"

# The suffix of source file names.
source_suffix = {
'.rst': 'restructuredtext',
'.txt': 'markdown',
'.md': 'markdown',
}

0 comments on commit c204ecf

Please sign in to comment.