Skip to content

Commit 0a9f9a4

Browse files
committed
docs: Prepare for readthedocs
1 parent 89ecd7d commit 0a9f9a4

File tree

8 files changed

+168
-3
lines changed

8 files changed

+168
-3
lines changed

.readthedocs.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
# Required
5+
version: 2
6+
7+
# Set the version of Python and other tools you might need
8+
build:
9+
os: ubuntu-22.04
10+
tools:
11+
python: "3.12"
12+
13+
# Build documentation in the docs/ directory with Sphinx
14+
sphinx:
15+
configuration: docs/conf.py
16+
17+
# If using Sphinx, optionally build your docs in additional formats such as PDF
18+
# formats:
19+
# - pdf
20+
21+
# Optionally declare the Python requirements required to build your docs
22+
python:
23+
install:
24+
- method: pip
25+
path: .
26+
extra_requirements:
27+
- docs

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
VENV = build/venv
22

33
venv: $(VENV)/.installed
4-
$(VENV)/.installed: Makefile
4+
$(VENV)/.installed: Makefile pyproject.toml
55
python3 -mvenv $(VENV)
66
$(VENV)/bin/python3 -m ensurepip
77
$(VENV)/bin/pip install -q -U pip
8-
$(VENV)/bin/pip install -q -e .[dev]
8+
$(VENV)/bin/pip install -q -e .[dev,docs]
99
touch $(VENV)/.installed
1010

1111
build: venv
@@ -19,5 +19,9 @@ test: venv
1919
coverage: venv
2020
$(VENV)/bin/pytest . -q --cov=multipart --cov-branch --cov-report=term --cov-report=html:build/htmlcov
2121

22+
.PHONY: docs
23+
docs: venv
24+
cd docs; ../$(VENV)/bin/sphinx-build -M html . ../build/docs
25+
2226
upload: build
2327
$(VENV)/bin/python3 -m twine upload --skip-existing dist/multipart-*

docs/api.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
=============
2+
API Reference
3+
=============
4+
5+
.. py:currentmodule:: multipart
6+
7+
SansIO Parser
8+
=============
9+
10+
.. autoclass:: PushMultipartParser
11+
:members:
12+
13+
.. autoclass:: MultipartSegment
14+
:members:
15+
16+
Stream Parser
17+
=============
18+
19+
.. autoclass:: MultipartParser
20+
:members:
21+
22+
.. autoclass:: MultipartPart
23+
:members:
24+
25+
WSGI Helper
26+
===========
27+
28+
.. autofunction:: is_form_request
29+
.. autofunction:: parse_form_data
30+
31+
Header utils
32+
============
33+
34+
.. autofunction:: parse_options_header
35+
.. autofunction:: header_quote
36+
.. autofunction:: header_unquote
37+
.. autofunction:: content_disposition_quote
38+
.. autofunction:: content_disposition_unquote
39+
40+
41+
Exceptions
42+
==========
43+
44+
45+
.. autoexception:: MultipartError
46+
47+
.. autoexception:: ParserError
48+
49+
.. autoexception:: StrictParserError
50+
51+
.. autoexception:: ParserLimitReached
52+
53+
.. autoexception:: ParserStateError

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. py:currentmodule:: multipart
2+
.. include:: ../CHANGELOG.rst

docs/conf.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
# import os
14+
# import sys
15+
# sys.path.insert(0, os.path.abspath('.'))
16+
17+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = "Multipart"
21+
copyright = "2010-%Y, Marcel Hellkamp"
22+
author = "Marcel Hellkamp"
23+
24+
25+
# -- General configuration ---------------------------------------------------
26+
# -- General configuration
27+
28+
extensions = [
29+
"sphinx.ext.duration",
30+
"sphinx.ext.doctest",
31+
"sphinx.ext.autodoc",
32+
"sphinx.ext.autosummary",
33+
"sphinx.ext.intersphinx",
34+
]
35+
36+
intersphinx_mapping = {
37+
"rtd": ("https://docs.readthedocs.io/en/stable/", None),
38+
"python": ("https://docs.python.org/3/", None),
39+
"sphinx": ("https://www.sphinx-doc.org/en/master/", None),
40+
}
41+
intersphinx_disabled_domains = ["std"]
42+
43+
#templates_path = ["_templates"]
44+
45+
# -- Options for EPUB output
46+
epub_show_urls = "footnote"
47+
48+
# List of patterns, relative to source directory, that match files and
49+
# directories to ignore when looking for source files.
50+
# This pattern also affects html_static_path and html_extra_path.
51+
exclude_patterns = []
52+
53+
# -- Options for HTML output -------------------------------------------------
54+
55+
# The theme to use for HTML and HTML Help pages. See the documentation for
56+
# a list of builtin themes.
57+
#
58+
html_theme = "sphinx_rtd_theme"
59+
60+
# Add any paths that contain custom static files (such as style sheets) here,
61+
# relative to this directory. They are copied after the builtin static files,
62+
# so a file named "default.css" will overwrite the builtin "default.css".
63+
#html_static_path = ["_static"]
64+
65+
autoclass_content = 'both'
66+
autodoc_member_order = 'bysource'

docs/index.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.. py:currentmodule:: multipart
2+
.. include:: ../README.rst
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
7+
Home <self>
8+
api
9+
changelog

multipart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ def parse_form_data(
917917
results may be empty or incomplete. If False, then exceptions are
918918
not suppressed. A value of None (default) throws exceptions in
919919
strict mode but suppresses errors in non-strict mode.
920-
:param **kwargs: Additional keyword arguments are forwarded to
920+
:param kwargs: Additional keyword arguments are forwarded to
921921
:class:`MultipartParser`. This is particularly useful to change the
922922
default parser limits.
923923
:raises MultipartError: See `ignore_errors` parameters.

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ dev = [
3939
"build",
4040
"twine",
4141
]
42+
docs = [
43+
"Sphinx>=8,<9",
44+
"sphinx_rtd_theme"
45+
]
4246

4347
[tool.flit.sdist]
4448
include = [

0 commit comments

Comments
 (0)