Skip to content

Commit

Permalink
Adds more documentation. (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtiesling authored Nov 23, 2023
1 parent 10a9879 commit b6a4763
Show file tree
Hide file tree
Showing 17 changed files with 1,044 additions and 16 deletions.
32 changes: 32 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.9"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
# golang: "1.19"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
# python:
# install:
# - requirements: docs/requirements.txt
65 changes: 63 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,67 @@
[![CI Testing](https://github.com/dtiesling/flask-muck/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/dtiesling/flask-muck/actions/workflows/test.yml)

# flask-muck
Batteries included framework for generating RESTful APIs with built-in CRUD in a Flask/SqlAlchemy stack.
Flask-Muck is a batteries-included framework for automatically generating RESTful APIs with Create, Read,
Update and Delete (CRUD) endpoints in a Flask/SqlAlchemy application stack.

With Flask-Muck you don't have to worry about the CRUD.

```python
from flask import Blueprint
from flask_muck.views import MuckApiView
import marshmallow as ma
from marshmallow import fields as mf

from myapp import db

class MyModel(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255), nullable=False)

class MyModelSchema(ma.Schema):
id = mf.Integer(dump_only=True)
name = mf.String(required=True)

class MyModelApiView(MuckApiView):
api_name = "my-model"
Model = MyModel
ResponseSchema = MyModel
CreateSchema = MyModel
PatchSchema = MyModel
UpdateSchema = MyModel
searchable_columns = [MyModel.name]

blueprint = Blueprint("api", __name__, url_prefix="/api/")
MyModelApiView.add_crud_to_blueprint(blueprint)

# Available Endpoint
# CREATE | curl -X POST "/api/v1/my-model" -H "Content-Type: application/json" \-d "{\"name\": \"Ayla\"}"
# LIST ALL | curl -X GET "/api/v1/my-model" -d "Accept: application/json"
# LIST ALL PAGINATED | curl -X GET "/api/v1/my-model?limit=100&offset=50" -d "Accept: application/json"
# SEARCH | curl -X GET "/api/v1/my-model?search=ayla" -d "Accept: application/json"
# FILTER | curl -X GET "/api/v1/my-model?filter={\"name\": \"Ayla\"}" -d "Accept: application/json"
# SORT | curl -X GET "/api/v1/my-model?sort=name" -d "Accept: application/json"
# FETCH | curl -X GET "/api/v1/my-model/1" -d "Accept: application/json"
# UPDATE | curl -X PUT "/api/v1/my-model" -H "Content-Type: application/json" \-d "{\"name\": \"Ayla\"}"
# PATCH | curl -X PATCH "/api/v1/my-model" -H "Content-Type: application/json" \-d "{\"name\": \"Ayla\"}"
# DELETE | curl -X DELETE "/api/v1/my-model/1"
```

## Install

`pip install flask-muck`

Flask-Muck supports Python >= 3.9

## Documentation

Refer to the [examples](./examples) directory for more information on usage and available features.

Full documentation is coming soon.

## License

MIT licensed. See the [LICENSE](./LICENSE) file for more details.



## [DOCUMENTATION COMING SOON, SEE EXAMPLES FOLDER TO GET STARTED]
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 = .
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)
32 changes: 32 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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
import os
import sys

sys.path.insert(0, os.path.abspath("../src/"))

project = "Flask-Muck"
copyright = "2023, Daniel Tiesling"
author = "Daniel Tiesling"

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

extensions = [
"sphinx.ext.autodoc",
]

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- 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"]
22 changes: 22 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. Flask-Muck documentation master file, created by
sphinx-quickstart on Wed Nov 22 07:17:46 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Flask-Muck's documentation!
======================================

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

reference_index



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

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
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=.
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
5 changes: 5 additions & 0 deletions docs/reference_index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
API REFERENCE
=============

.. autoclass:: flask_muck.MuckApiView
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pipenv = "*"
install = "*"
marshmallow = "*"
flask-muck = {file = "../.."}
flask-login = "*"
webargs = "*"

[dev-packages]
Expand Down
Loading

0 comments on commit b6a4763

Please sign in to comment.