Skip to content

Add documentation #111

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

Merged
merged 9 commits into from
Apr 10, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,6 @@ dmypy.json

# Poetry local config
poetry.toml

# dummy test file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, didn't mean to leave that in. Good catch, reverted in 300a089

x.py
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ pip install postgrest-py

```py
import asyncio
from postgrest_py import PostgrestClient
from postgrest_py import AsyncPostgrestClient

async def main():
async with PostgrestClient("http://localhost:3000") as client:
async with AsyncPostgrestClient("http://localhost:3000") as client:
r = await client.from_("countries").select("*").execute()
countries = r.json()
countries = r.data

asyncio.run(main())
```
Expand Down Expand Up @@ -112,10 +112,6 @@ poetry run pytest

Read more [here](https://github.com/supabase/postgrest-py/blob/master/CHANGELOG.md).

## TODO

Read more [here](https://github.com/supabase/postgrest-py/blob/master/TODO.md).

## SPONSORS

We are building the features of Firebase using enterprise-grade, open source products. We support existing communities wherever possible, and if the products don’t exist we build them and open source them ourselves. Thanks to these sponsors who are making the OSS ecosystem better for everyone.
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 = .
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)
14 changes: 14 additions & 0 deletions docs/api/client.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Client
======

To run any queries, the first step is to construct a client.

The library offers both synchronous and asynchronous clients.

.. autoclass:: postgrest_py.AsyncPostgrestClient
:members:
:inherited-members:

.. autoclass:: postgrest_py.SyncPostgrestClient
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions docs/api/exceptions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Exceptions
==========

.. autoexception:: postgrest_py.APIError
:members:
27 changes: 27 additions & 0 deletions docs/api/filters.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Filter Builder
==============

This is a kind of `request builder <Request Builders>`_. It contains all the methods used to
filter data during queries.

.. note::
In the source code, there are separate AsyncFilterRequestBuilders and SyncFilterRequestBuilders.
These classes are otherwise exactly the same, and provide the same interface.

.. warning::
These classes are not meant to be constructed by the user.

.. tip::
The full list of supported filter operators are on the `PostgREST documentation <https://postgrest.org/en/stable/api.html#operators>`_

.. tip::
All the filter methods return a modified instance of the filter builder, allowing fluent chaining of filters.


.. autoclass:: postgrest_py.AsyncFilterRequestBuilder
:members:
:inherited-members:

.. autoclass:: postgrest_py.SyncFilterRequestBuilder
:members:
:inherited-members:
16 changes: 16 additions & 0 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
API Reference
=============

The library offers both synchronous and asynchronous clients.
Note that the synchronous and asynchronous classes all provide the exact same interface.

.. toctree::
:maxdepth: 3
:caption: Contents:

Client <client>
Request Builders <request_builders>
Filters <filters>
Responses <responses>
Types <types>
Exceptions <exceptions>
33 changes: 33 additions & 0 deletions docs/api/request_builders.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Request Builders
================

.. note::
In the source code, there are separate synchronous and asynchronous request builder classes.
These classes are otherwise exactly the same, and provide the same interfaces.

.. warning::
These classes are not meant to be constructed by the user.

.. autoclass:: postgrest_py.AsyncRequestBuilder
:members:
:inherited-members:

.. autoclass:: postgrest_py.AsyncSelectRequestBuilder
:members:
:inherited-members:

.. autoclass:: postgrest_py.AsyncQueryRequestBuilder
:members:
:inherited-members:

.. autoclass:: postgrest_py.SyncRequestBuilder
:members:
:inherited-members:

.. autoclass:: postgrest_py.SyncSelectRequestBuilder
:members:
:inherited-members:

.. autoclass:: postgrest_py.SyncQueryRequestBuilder
:members:
:inherited-members:
7 changes: 7 additions & 0 deletions docs/api/responses.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Responses
=========

Once a query is run, the postgrest_py parses the server's response into an APIResponse object.

.. autoclass:: postgrest_py.APIResponse
:members:
16 changes: 16 additions & 0 deletions docs/api/types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Types
=====

Some type aliases and enums used in the library.

.. autoclass:: postgrest_py.types.CountMethod
:members:

.. autoclass:: postgrest_py.types.Filters
:members:

.. autoclass:: postgrest_py.types.RequestMethod
:members:

.. autoclass:: postgrest_py.types.ReturnMethod
:members:
64 changes: 64 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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 = "postgrest-py"
copyright = (
"2022, Anand Krishna, Daniel Reinón García, Joel Lee, Leynier Gutiérrez González"
)
author = "Anand Krishna, Daniel Reinón García, Joel Lee, Leynier Gutiérrez González"


# -- 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.napoleon",
"sphinx.ext.extlinks",
]

# Napolean config
napoleon_google_docstring = True

# autodoc config
autodoc_member_order = "bysource"
autodoc_class_signature = "separated"

# 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 = "furo"

# 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"]
4 changes: 4 additions & 0 deletions docs/examples/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Examples
========

Stay tuned! Examples are coming soon.
27 changes: 27 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Welcome to postgrest-py's documentation!
========================================

`PostgREST <https://postgrest.org>`_ client library for Python. This library provides an ORM interface to PostgREST.

.. attention::
This library is currently unstable. If you find any bugs, please file an `issue <https://github.com/supabase-community/postgrest-py/issues/>`_.

Installation
============
Requirements:

- Python >= 3.7

**With pip:**
pip install postgrest-py

**With poetry:**
poetry add postgrest-py


.. toctree::
:maxdepth: 3
:caption: Contents:

API Reference </api/index>
Examples </examples/index>
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

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
Loading