From 057ad7621af3023bdb0b09a9e3acb08d7a878a9b Mon Sep 17 00:00:00 2001 From: Jack Grahl Date: Sat, 5 Mar 2022 14:39:43 +0000 Subject: [PATCH 1/4] Add Sphinx docs. --- docs/.gitignore | 1 + docs/Makefile | 20 +++++++++++++++++++ docs/conf.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 20 +++++++++++++++++++ docs/make.bat | 35 +++++++++++++++++++++++++++++++++ pyproject.toml | 1 + 6 files changed, 129 insertions(+) create mode 100644 docs/.gitignore create mode 100644 docs/Makefile create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/make.bat diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..69fa449 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +_build/ diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d4bb2cb --- /dev/null +++ b/docs/Makefile @@ -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) diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..0e2acfa --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,52 @@ +# 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('.')) + + +# -- Project information ----------------------------------------------------- + +project = 'Flask-Selfdoc' +copyright = '2022, Arnaud Coomans, Jack Grahl' +author = 'Arnaud Coomans, Jack Grahl' + + +# -- 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 = [ +] + +# 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 = 'alabaster' + +# 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'] \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..a8acccd --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,20 @@ +.. Flask-Selfdoc documentation master file, created by + sphinx-quickstart on Sat Mar 5 14:34:55 2022. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to Flask-Selfdoc's documentation! +========================================= + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..153be5e --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +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 + 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 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/pyproject.toml b/pyproject.toml index ccc4250..ee799bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,7 @@ Flask = "^1.0" [tool.poetry.dev-dependencies] pytest = "^6.2.5" requests = "^2.26.0" +Sphinx = "^4.4.0" [tool.poetry.scripts] test = 'run_tests:test' From 591de51e1a1c6d76b0819b9b3f24f0de7bf1f8ed Mon Sep 17 00:00:00 2001 From: Jack Grahl Date: Sun, 6 Mar 2022 11:33:21 +0000 Subject: [PATCH 2/4] Change theme to flask - broken. --- docs/conf.py | 5 +++-- pyproject.toml | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 0e2acfa..c6884fa 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -28,6 +28,7 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ + "pallets_sphinx_themes" ] # Add any paths that contain templates here, relative to this directory. @@ -44,9 +45,9 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'alabaster' +html_theme = 'flask' # 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'] \ No newline at end of file +html_static_path = ['_static'] diff --git a/pyproject.toml b/pyproject.toml index ee799bd..9270232 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ Flask = "^1.0" pytest = "^6.2.5" requests = "^2.26.0" Sphinx = "^4.4.0" +Pallets-Sphinx-Themes = "^2.0.2" [tool.poetry.scripts] test = 'run_tests:test' From 300c0d3ceec462110a14c43c4d0251e712f9f591 Mon Sep 17 00:00:00 2001 From: Jack Grahl Date: Tue, 8 Mar 2022 22:42:18 +0000 Subject: [PATCH 3/4] Add jinja2 explicitly - needed for sphinx. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 9270232..2944ff2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,7 @@ license = "MIT" [tool.poetry.dependencies] python = "^3.6" Flask = "^1.0" +Jinja2 = "^3.0.3" [tool.poetry.dev-dependencies] pytest = "^6.2.5" From 69751982d0b8a2ecb767e28981a2f504721a2d64 Mon Sep 17 00:00:00 2001 From: Jack Grahl Date: Mon, 2 May 2022 11:45:28 +0100 Subject: [PATCH 4/4] Add a task to try building the docs. --- .github/workflows/build_docs.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/build_docs.yml diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml new file mode 100644 index 0000000..c95c26a --- /dev/null +++ b/.github/workflows/build_docs.yml @@ -0,0 +1,24 @@ +name: Build the Sphinx docs +on: + - pull_request + +jobs: + testing: + strategy: + fail-fast: false + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install poetry + run: pip install poetry + - name: Install requirements + run: poetry install + - name: Run doctests + run: poetry run doctest + - name: build docs + run: | + cd docs/ + poetry run make