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

chore: generate docs with sphinx #61

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ include CONTRIBUTING.md
include codecov.yml
include tox.ini

recursive-include docs *.md *.svg
recursive-include docs *.md *.txt *.rst conf.py Makefile make.bat *.svg

graft tests
prune docs/_build
prune bin

global-exclude *.py[co] __pycache__
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)
22 changes: 22 additions & 0 deletions docs/code_examples/flask_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from flask import Flask
from graphql_server.flask import GraphQLView

from schema import schema

app = Flask(__name__)

app.add_url_rule('/graphql', view_func=GraphQLView.as_view(
'graphql',
schema=schema,
graphiql=True,
))

# Optional, for adding batch query support (used in Apollo-Client)
app.add_url_rule('/graphql/batch', view_func=GraphQLView.as_view(
'graphql',
schema=schema,
batch=True
))

if __name__ == '__main__':
app.run()
77 changes: 77 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 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 = 'graphql-server 3'
copyright = '2020, graphql-python.org'
author = 'graphql-python.org'

# The full version, including alpha/beta/rc tags
release = '3.0.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_rtd_theme'
]

# 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']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False


# -- 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'

# Output file base name for HTML help builder.
htmlhelp_basename = 'graphql-server-3-doc'

# 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']

# -- AutoDoc configuration -------------------------------------------------
# autoclass_content = "both"
autodoc_default_options = {
'members': True,
'inherited-members': False,
'special-members': '__init__',
'undoc-members': False,
'show-inheritance': False
}
autosummary_generate = True
81 changes: 0 additions & 81 deletions docs/flask.md

This file was deleted.

25 changes: 25 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Welcome to GraphQL-Server documentation!
========================================

.. warning::

Please note that the following documentation describes the current version which is currently only available
as a pre-release and needs to be installed with "`--pre`"

Contents
--------

.. toctree::
:maxdepth: 2

intro
usage/index
modules/graphql-server


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

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

`GraphQL-Server`_ is a base library that serves as a helper for building GraphQL
servers or integrations into existing web frameworks using `GraphQL-Core-3`_.

The package also provides some built-in server integrations:

- Flask
- WebOb
- Sanic
- AIOHTTP

Any other existing server frameworks can be implemented by using the public
helper functions provided on this package.


Getting started
---------------

You can install GraphQL-Server using pip_::

pip install --pre graphql-server

You can also install GraphQL-Server with pipenv_, if you prefer that::

pipenv install --pre graphql-server

.. warning::

Please note that the following documentation describes the current version
which is currently only available as a pre-release and needs to be installed
with "`--pre`".

Also note that the conda-forge package is not available as the current setup
for pre / rc releases is not well documented, check this `conda-forge`_
issue to know more. However you can still use pip inside conda to install
the prerelease version.

Now you can start using GraphQL-Server by importing from the top-level
:mod:`graphql-server` package. Nearly everything defined in the sub-packages
can also be imported directly from the top-level package.

.. currentmodule:: graphql_server

Using the public helper functions, you can define a GraphQLView class on your
server and start adding the graphiql options along with parsing, validation and
execution functions related to graphql.


Reporting Issues and Contributing
---------------------------------

Please visit the `GitHub repository of GraphQL-Server`_ if you're interested
in the current development or want to report issues or send pull requests.

.. _GraphQL-Core-3: https://github.com/graphql-python/graphql-core
.. _GraphQL-Server: https://github.com/graphql-python/graphql-server
.. _GitHub repository of GraphQL-Server: https://github.com/graphql-python/graphql-server
.. _pip: https://pip.pypa.io/
.. _pipenv: https://github.com/pypa/pipenv
.. _conda-forge: https://github.com/conda-forge/python-feedstock/issues/270
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

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.http://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
6 changes: 6 additions & 0 deletions docs/modules/aiohttp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
AIOHTTP
=======

.. currentmodule:: graphql_server.aiohttp

.. automodule:: graphql_server.aiohttp
6 changes: 6 additions & 0 deletions docs/modules/flask.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FLASK
=====

.. currentmodule:: graphql_server.flask

.. automodule:: graphql_server.flask
33 changes: 33 additions & 0 deletions docs/modules/graphql-server.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Reference
=========

.. currentmodule:: graphql_server

.. autofunction:: run_http_query
.. autofunction:: encode_execution_results
.. autofunction:: format_execution_result
.. autofunction:: json_encode
.. autofunction:: load_json_body

.. _data-structures:

Data Structures
---------------

.. autoclass:: GraphQLParams
.. autoclass:: GraphQLResponse
.. autoclass:: ServerResponse
.. autoclass:: HttpQueryError

.. _sub-packages:

Sub-Packages
------------

.. toctree::
:maxdepth: 1

aiohttp
flask
sanic
webob
Loading