Skip to content

Commit

Permalink
AVRO-312 Python Sphinx Documentation
Browse files Browse the repository at this point in the history
Generate Documentation in docs/build/*.html when ./build.sh docs is run.

Implementation detail: Uses tox to install build-time dependencies.
  • Loading branch information
kojiromike committed Jul 19, 2023
1 parent 010a075 commit 92c15ad
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lang/py/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ dist() (
"$virtualenv/bin/python3" -m build --outdir "$destination"
)

docs() {
python3 -m tox -e docs
}

interop-data-generate() {
./setup.py generate_interop_data
cp -r avro/test/interop/data ../../build/interop
Expand All @@ -76,6 +80,7 @@ main() {
case "$target" in
clean) clean;;
dist) dist;;
docs) docs;;
interop-data-generate) interop-data-generate;;
interop-data-test) interop-data-test;;
lint) lint;;
Expand Down
20 changes: 20 additions & 0 deletions lang/py/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 = source
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)
35 changes: 35 additions & 0 deletions lang/py/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

%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
Empty file.
38 changes: 38 additions & 0 deletions lang/py/docs/source/automodule.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.. automodule:: avro
:members:
.. automodule:: avro.compatibility
:members:
.. automodule:: avro.datafile
:members:
.. automodule:: avro.ipc
:members:
.. automodule:: avro.protocol
:members:
.. automodule:: avro.codecs
:members:
.. automodule:: avro.constants
:members:
.. automodule:: avro.io
:members:
.. automodule:: avro.tether
:members:
.. automodule:: avro.tether.tether_task_runner
:members:
.. automodule:: avro.tether.util
:members:
.. automodule:: avro.tether.tether_task
:members:
.. automodule:: avro.utils
:members:
.. automodule:: avro.errors
:members:
.. automodule:: avro.name
:members:
.. automodule:: avro.tool
:members:
.. automodule:: avro.timezones
:members:
.. automodule:: avro.__main__
:members:
.. automodule:: avro.schema
:members:
30 changes: 30 additions & 0 deletions lang/py/docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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 sys
sys.path.append("..")

project = 'Apache Avro'
copyright = '2023, Apache'
author = 'Apache'
release = '1.12.0'

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

extensions = ["sphinx.ext.autodoc"]

templates_path = ['_templates']
exclude_patterns = []



# -- 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']
21 changes: 21 additions & 0 deletions lang/py/docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. Avro Python documentation master file, created by
sphinx-quickstart on Tue Jul 18 22:36:41 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. toctree::
:maxdepth: 2
:caption: Contents:


intro
automodule


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

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
14 changes: 14 additions & 0 deletions lang/py/docs/source/intro.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Welcome to Avro's Python documentation!
=======================================

Avro is a data serialization system. See `avro.apache.org <https://avro.apache.org/docs/current/>`_ for background information.

Avro Python is a Python library that implements parts of the `Avro Specification <https://avro.apache.org/docs/current/specification/>`_.

The library includes the following functionality:

* Assembling schemas programmatically.
* A schema parser, which can parse Avro schema (written in JSON) into a Schema object.
* Binary encoders and decoders to encode data into Avro format and decode it back using primitive functions.
* Streams for storing and reading data, which Encoders and Decoders use.
* Support for Avro DataFile.
9 changes: 9 additions & 0 deletions lang/py/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
envlist =
build # Build the wheel
# Fastest checks first
docs
lint
typechecks
py36
Expand Down Expand Up @@ -67,6 +68,14 @@ commands_pre =
commands =
commands_post =

[testenv:docs]
deps =
sphinx
commands_pre =
commands =
sphinx-build -b html docs/source/ docs/build/html
commands_post =

[testenv:lint]
deps =
black
Expand Down

0 comments on commit 92c15ad

Please sign in to comment.