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

Feat/10 update and auto deploy sphinx #27

Merged
merged 30 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5529adb
Updated dev-dependencies, added first version of Sphinx documentation…
MarcoHuebner May 7, 2023
b35dc8a
Added Logo, updated theme, updated GitHub workflow, fixed docstrings …
MarcoHuebner May 14, 2023
130d670
Updated urllib3 version, but everything <2.0.0 (deprecating `strict`)…
MarcoHuebner May 14, 2023
cd73ac7
Updated poetry as recommended in cachecontrol issue report.
MarcoHuebner May 14, 2023
0030116
Fixed black formatting, fixed make docs (is now ran by poetry).
MarcoHuebner May 14, 2023
bc90982
Fixed linting issue, updated packages, updated make docs.
MarcoHuebner May 14, 2023
5588077
Updated ReadMe, added developer sphinx documentation, added custom pr…
MarcoHuebner May 20, 2023
a6fdd9b
Add deployment workflow, needs Repo updates
MarcoHuebner Oct 22, 2023
0fb69bf
Merge branch 'dev' into feature/sphinx-documentation
MarcoHuebner Oct 28, 2023
45c938e
Update depencies for Sphinx documentation #10
MarcoHuebner Oct 28, 2023
399d840
Remove redundant docu information #10
MarcoHuebner Oct 28, 2023
3d64188
Remove unused mdinclude, fix run-test py version, update pre-commit #10
MarcoHuebner Oct 28, 2023
c14d781
Fix dependency group for SPhinx workflow #10
MarcoHuebner Oct 28, 2023
ddf5a92
FIx docstring parameter rendering in Sphinx #10
MarcoHuebner Nov 2, 2023
5780d16
Fix image rendering by mimicing folder structure #10
MarcoHuebner Nov 2, 2023
1ef778e
Add comment on warnings related to ext.napoleon #10
MarcoHuebner Nov 2, 2023
085b8dc
Rename deploy-docs #10
MarcoHuebner Nov 2, 2023
0a7d486
Fix black format issue in conf.py #10
MarcoHuebner Nov 2, 2023
280e552
Update deploy key, add deploy trigger comment #10
MarcoHuebner Nov 4, 2023
8afd597
Update documentation deploy workflow #10
MarcoHuebner Nov 4, 2023
2e12450
Switch to matrix.os definition #10
MarcoHuebner Nov 4, 2023
203a56a
Fix pull_request target in deploy workflow #10
MarcoHuebner Nov 4, 2023
c6acb19
Merge branch 'feature/sphinx-documentation' into feat/10-update-and-a…
MarcoHuebner Nov 5, 2023
c09bcc7
Update poetry.lock #10
MarcoHuebner Nov 5, 2023
ddf9356
Import package version to Sphinx docu #10
MarcoHuebner Nov 5, 2023
44a2ff1
Manually fix black formatting issue #10
MarcoHuebner Nov 5, 2023
45d0b1d
With auto-deploy working, decrease retention days #10
MarcoHuebner Nov 5, 2023
4f5533e
Update readme and Sphinx header references #10
MarcoHuebner Nov 5, 2023
1d303c1
Fix deploy to update files on the remote #10
MarcoHuebner Nov 5, 2023
404ea85
Merge branch 'dev' into feat/10-update-and-auto-deploy-sphinx
MarcoHuebner Dec 3, 2023
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
61 changes: 61 additions & 0 deletions .github/workflows/deploy-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Deploy docs

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

env:
POETRY_VERSION: 1.6.1

jobs:
build-and-deploy:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
os: [ubuntu-latest]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Run poetry image
uses: abatilo/[email protected]
with:
poetry-version: $POETRY_VERSION
- name: Install dependencies
run: |
poetry install --with dev
- name: Build docs
run: |
cd docs
poetry run make clean
poetry run make html
# create distinguished subdirectories for each branch
# NOTE: force_orphan will delete all files in the branch (thus main & dev could not be concurrently deployed)
- name: Deploy docs main
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.base_ref == 'main')
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
publish_dir: ./docs/build/html
publish_branch: gh-pages
- name: Deploy docs dev
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/dev' || (github.event_name == 'pull_request' && github.base_ref == 'dev')
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
publish_dir: ./docs/build/html
destination_dir: dev
publish_branch: gh-pages
37 changes: 36 additions & 1 deletion .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ jobs:
run: |
poetry run pytest --cov=pystatis tests
code-quality:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
# only support specific python version, as guidelines differ beween (minor) versions
python-version: ["3.11.6"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
Expand All @@ -76,3 +78,36 @@ jobs:
run: poetry run safety check
- name: Run mypy
run: poetry run mypy src
sphinx-documentation:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Run poetry image
uses: abatilo/[email protected]
with:
poetry-version: $POETRY_VERSION
- name: Install dependencies
run: |
poetry install --with dev
- name: Build documentation
run: |
cd docs
poetry run make clean
poetry run make html
- name: Upload documentation as artifacts
uses: actions/upload-artifact@v3
with:
name: docs
path: docs/build/html/*
retention-days: 5
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ repos:
files: ^\.github/workflows/
types: [yaml]
args: ["--schemafile", "https://json.schemastore.org/github-workflow"]
- repo: https://github.com/thclark/pre-commit-sphinx
rev: 0.0.1
hooks:
- id: build-docs
name: "Check if documentation compiles"
args: ['--cache-dir', 'docs/build/doctrees', '--html-dir', 'docs/build/html', '--source-dir', 'docs/source']
language_version: python3
additional_dependencies: [myst-parser]
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ clear_cache("21311-0001") # only deletes the data for the object with the speci
clear_cache() # deletes the complete cache
```

### Full documentation

The full documentation of the main and dev branches are hosted via [GitHub Pages (main)](https://correlaid.github.io/pystatis/) and [GitHub Pages (dev)](https://correlaid.github.io/pystatis/dev/). It can also be built locally by running

```bash
cd docs && make clean && make html
```

from the project root directory. Besides providing parsed docstrings of the individual package modules, the full documentation currently mirrors most of the readme, like installation and usage. The mirroring crucially relies on the names of the section headers in the ReadMe, so change them with care!

More information on how to use sphinx is provided [here](https://docs.readthedocs.io/en/stable/intro/getting-started-with-sphinx.html).

## License

Distributed under the MIT License. See `LICENSE.txt` for more information.
Expand All @@ -128,7 +140,6 @@ Distributed under the MIT License. See `LICENSE.txt` for more information.
A few ideas we should implement in the maybe-near future:

- Improve Table parsing. Right now, the parsing is really simple and we should align the cube and table format so that the data frame for tables is more convenient to use.
- Create a source code documentation with Sphinx or similar tools.
- Mechanism to download data that is newer than the cached version. Right now, once data is cached, it is always retrieved from cache no matter if there is a newer version online. However, this could be quite challenging as the GENESIS API is really bad in providing a good and consistent field for the last update datetime.
- Improve Table and Cube metadata so the user can look up the variables contained in the dataset and for each variable the values that this variable can have.
- Understand and support time series.
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)
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

%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
Binary file added docs/source/_static/pystatis_logo.ico
Binary file not shown.
Binary file added docs/source/_static/pystatis_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/assets/structure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import subprocess

# 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 = "pystatis"
copyright = "2022, Michael Aydinbas"
authors = [
"Michael Aydinbas <[email protected]>",
"Ariz Weber <[email protected]>",
"CorrelAid <[email protected]>",
"Daniel Pleus <[email protected]>",
"Felix Schmitz <[email protected]>",
"Frederik Hering <[email protected]>",
"Marco Hübner <[email protected]>",
]
maintainers = ["Michael Aydinbas <[email protected]>"]
release = (
subprocess.check_output(["poetry", "version"], text=True)
.strip()
.split()[-1]
)
version = release


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

extensions = [
"myst_parser",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary", # used to generate overview tables
"sphinx.ext.napoleon", # used for google-style docstrings
]

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 = "sphinx_rtd_theme"
html_static_path = ["_static"]

html_title = "pystatis"
html_short_title = "pystatis documentation"
html_logo = "_static/pystatis_logo.png"
html_favicon = "_static/pystatis_logo.ico"
autodoc_typehints = "description"
6 changes: 6 additions & 0 deletions docs/source/contribute.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Developer Information
=====================

.. include:: ../../README.md
:parser: myst_parser.sphinx_
:start-after: ## How to contribute?
36 changes: 36 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. pystatis documentation master file, created by
sphinx-quickstart on Sun May 7 19:10:45 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

pystatis
========

.. include:: ../../README.md
:parser: myst_parser.sphinx_
:start-after: # ``pystatis``
:end-before: ## Installation

.. toctree::
:maxdepth: 2
:caption: Contents

install
start
use
roadmap
contribute
license

.. toctree::
:maxdepth: 2
:caption: Modules

pystatis

Indices and tables
------------------

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
7 changes: 7 additions & 0 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Installation
============

.. include:: ../../README.md
:parser: myst_parser.sphinx_
:start-after: ## Installation
:end-before: ## Getting started
7 changes: 7 additions & 0 deletions docs/source/license.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
License
==========

.. include:: ../../README.md
:parser: myst_parser.sphinx_
:start-after: ## License
:end-before: ## Roadmap
Loading
Loading