From 8e1b40dfef75fa7445c9585c2f26cd6708c9ed40 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Wed, 28 Feb 2024 13:06:16 +0100 Subject: [PATCH] Fixes for Github workflow --- .github/workflows/ci.yml | 2 +- docs/Makefile | 20 +++++++++++++ docs/check_sphinx.py | 17 +++++++++++ docs/conf.py | 61 ++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 60 +++++++++++++++++++++++++++++++++++++++ docs/quickstart.rst | 18 ++++++++++++ fix.sh | 2 ++ pyproject.toml | 6 ++-- tox.ini | 4 +-- 9 files changed, 185 insertions(+), 5 deletions(-) create mode 100644 docs/Makefile create mode 100644 docs/check_sphinx.py create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/quickstart.rst diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9330d1b..b6fcb12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: python: ['3.10', '3.11', '3.12'] - django: ['4.2'] + django: ['3.2', '4.2'] name: Run the test suite (Python ${{ matrix.python }}, Django ${{ matrix.django }}) 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/check_sphinx.py b/docs/check_sphinx.py new file mode 100644 index 0000000..cc1003a --- /dev/null +++ b/docs/check_sphinx.py @@ -0,0 +1,17 @@ +import subprocess + + +def test_linkcheck(tmpdir): + doctrees = tmpdir.join("doctrees") + htmldir = tmpdir.join("html") + subprocess.check_call( + ["sphinx-build", "-W", "-blinkcheck", "-d", str(doctrees), ".", str(htmldir)], + ) + + +def test_build_docs(tmpdir): + doctrees = tmpdir.join("doctrees") + htmldir = tmpdir.join("html") + subprocess.check_call( + ["sphinx-build", "-W", "-bhtml", "-d", str(doctrees), ".", str(htmldir)], + ) diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..cafa1bf --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,61 @@ +# 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 sys +from pathlib import Path + +current_dir = Path(__file__).parents[1] +code_directory = current_dir / "mail_editor" + +sys.path.insert(0, str(code_directory)) + + +# -- Project information ----------------------------------------------------- + +project = "mail_editor" +copyright = "2024, Maykin Media" +author = "Maykin Media" + +# The full version, including alpha/beta/rc tags +release = "0.1.0" + + +# -- 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.todo", +] + +# 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 = [] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..b7d7b05 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,60 @@ +.. mail_editor documentation master file, created by startproject. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to mail_editor's documentation! +================================================= + +|build-status| |code-quality| |black| |coverage| |docs| + +|python-versions| |django-versions| |pypi-version| + + + +Features +======== + +* ... +* ... + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + quickstart + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + + +.. |build-status| image:: https://github.com/maykinmedia/mail_editor/workflows/Run%20CI/badge.svg + :alt: Build status + :target: https://github.com/maykinmedia/mail_editor/actions?query=workflow%3A%22Run+CI%22 + +.. |code-quality| image:: https://github.com/maykinmedia/mail_editor/workflows/Code%20quality%20checks/badge.svg + :alt: Code quality checks + :target: https://github.com/maykinmedia/mail_editor/actions?query=workflow%3A%22Code+quality+checks%22 + +.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/psf/black + +.. |coverage| image:: https://codecov.io/gh/maykinmedia/mail_editor/branch/master/graph/badge.svg + :target: https://codecov.io/gh/maykinmedia/mail_editor + :alt: Coverage status + +.. |docs| image:: https://readthedocs.org/projects/mail_editor/badge/?version=latest + :target: https://mail_editor.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + +.. |python-versions| image:: https://img.shields.io/pypi/pyversions/mail_editor.svg + +.. |django-versions| image:: https://img.shields.io/pypi/djversions/mail_editor.svg + +.. |pypi-version| image:: https://img.shields.io/pypi/v/mail_editor.svg + :target: https://pypi.org/project/mail_editor/ diff --git a/docs/quickstart.rst b/docs/quickstart.rst new file mode 100644 index 0000000..af6c472 --- /dev/null +++ b/docs/quickstart.rst @@ -0,0 +1,18 @@ +========== +Quickstart +========== + +Installation +============ + +Install from PyPI with pip: + +.. code-block:: bash + + pip install mail_editor + + +Usage +===== + + diff --git a/fix.sh b/fix.sh index fdb2e72..9e1d041 100755 --- a/fix.sh +++ b/fix.sh @@ -7,3 +7,5 @@ black ./mail_editor isort --profile black ./tests autoflake --in-place --remove-all-unused-imports -r ./tests black ./tests + +black ./docs diff --git a/pyproject.toml b/pyproject.toml index 3ba3e25..a57c2ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ classifiers = [ ] requires-python = ">=3.10" dependencies = [ - "django>=4.2", + "django>=3.2", "django-choices", "django-ckeditor", "requests", @@ -50,6 +50,8 @@ tests = [ "isort", "black", "flake8", + "autoflake", + "django_webtest", ] coverage = [ "pytest-cov", @@ -76,7 +78,7 @@ sections=["FUTURE", "STDLIB", "DJANGO", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER [tool.pytest.ini_options] testpaths = ["tests"] -DJANGO_SETTINGS_MODULE = "testapp.settings" +DJANGO_SETTINGS_MODULE = "tests.settings" [tool.bumpversion] current_version = "0.3.5" diff --git a/tox.ini b/tox.ini index 77bf28d..df1515b 100644 --- a/tox.ini +++ b/tox.ini @@ -20,7 +20,7 @@ DJANGO = [testenv] setenv = - DJANGO_SETTINGS_MODULE=testapp.settings + DJANGO_SETTINGS_MODULE=tests.settings PYTHONPATH={toxinidir} extras = tests @@ -41,7 +41,7 @@ commands = isort --check-only --diff . [testenv:black] extras = tests skipsdist = True -commands = black --check mail_editor docs testapp tests +commands = black --check mail_editor docs tests [testenv:flake8] extras = tests