From b1430d9bae3a25d44725f7515c994b564c12267e Mon Sep 17 00:00:00 2001 From: Naoto Mizuno Date: Sun, 18 Oct 2020 13:19:19 +0900 Subject: [PATCH] Add sphinx document --- .gitignore | 1 + docs/Makefile | 23 +++++++++++ docs/_templates/autosummary/class.rst | 13 +++++++ docs/conf.py | 56 +++++++++++++++++++++++++++ docs/convolution.rst | 9 +++++ docs/dsu.rst | 8 ++++ docs/fenwicktree.rst | 8 ++++ docs/index.rst | 38 ++++++++++++++++++ docs/lazysegtree.rst | 8 ++++ docs/make.bat | 35 +++++++++++++++++ docs/math.rst | 14 +++++++ docs/maxflow.rst | 8 ++++ docs/mincostflow.rst | 8 ++++ docs/modint.rst | 8 ++++ docs/scc.rst | 8 ++++ docs/segtree.rst | 8 ++++ docs/string.rst | 10 +++++ docs/twosat.rst | 8 ++++ setup.cfg | 3 ++ 19 files changed, 274 insertions(+) create mode 100644 docs/Makefile create mode 100644 docs/_templates/autosummary/class.rst create mode 100644 docs/conf.py create mode 100644 docs/convolution.rst create mode 100644 docs/dsu.rst create mode 100644 docs/fenwicktree.rst create mode 100644 docs/index.rst create mode 100644 docs/lazysegtree.rst create mode 100644 docs/make.bat create mode 100644 docs/math.rst create mode 100644 docs/maxflow.rst create mode 100644 docs/mincostflow.rst create mode 100644 docs/modint.rst create mode 100644 docs/scc.rst create mode 100644 docs/segtree.rst create mode 100644 docs/string.rst create mode 100644 docs/twosat.rst diff --git a/.gitignore b/.gitignore index b6e4761..6a0852a 100644 --- a/.gitignore +++ b/.gitignore @@ -70,6 +70,7 @@ instance/ # Sphinx documentation docs/_build/ +docs/generated/ # PyBuilder target/ diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..fddf683 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,23 @@ +# 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) + +clean: + rm -rf $(BUILDDIR) generated + +.PHONY: help clean 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) diff --git a/docs/_templates/autosummary/class.rst b/docs/_templates/autosummary/class.rst new file mode 100644 index 0000000..72decc1 --- /dev/null +++ b/docs/_templates/autosummary/class.rst @@ -0,0 +1,13 @@ +{{ fullname }} +{{ underline }} + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ objname }} + +{% block methods %} + .. rubric:: Methods +{% for item in methods %} + .. automethod:: {{ item }} +{%- endfor %} +{% endblock %} diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..0e3c3d3 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,56 @@ +# 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('../atcoder')) + + +# -- Project information ----------------------------------------------------- + +project = 'ac-library-python' +copyright = '2020, Naoto Mizuno' +author = 'Naoto Mizuno' + + +# -- 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.autosummary', + 'sphinx.ext.napoleon', +] + +autosummary_generate = True + +# 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 = 'sphinx_rtd_theme' + +# 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'] diff --git a/docs/convolution.rst b/docs/convolution.rst new file mode 100644 index 0000000..02ba882 --- /dev/null +++ b/docs/convolution.rst @@ -0,0 +1,9 @@ +Convolution +=========== + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + atcoder.convolution.convolution + atcoder.convolution.convolution_int diff --git a/docs/dsu.rst b/docs/dsu.rst new file mode 100644 index 0000000..090b837 --- /dev/null +++ b/docs/dsu.rst @@ -0,0 +1,8 @@ +Disjoint Union Set +================== + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + atcoder.dsu.DSU diff --git a/docs/fenwicktree.rst b/docs/fenwicktree.rst new file mode 100644 index 0000000..faec6d9 --- /dev/null +++ b/docs/fenwicktree.rst @@ -0,0 +1,8 @@ +Fenwick Tree +============ + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + atcoder.fenwicktree.FenwickTree diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..b42acec --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,38 @@ + +ac-library-python: Python port of AtCoder Library. +================================================== + +.. toctree:: + :maxdepth: 1 + :caption: Data Structures: + + fenwicktree + segtree + lazysegtree + string + +.. toctree:: + :maxdepth: 1 + :caption: Math: + + math + convolution + modint + +.. toctree:: + :maxdepth: 1 + :caption: Graphs: + + dsu + maxflow + mincostflow + scc + twosat + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/lazysegtree.rst b/docs/lazysegtree.rst new file mode 100644 index 0000000..2998149 --- /dev/null +++ b/docs/lazysegtree.rst @@ -0,0 +1,8 @@ +Lazy Segment Tree +================= + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + atcoder.lazysegtree.LazySegTree diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..2119f51 --- /dev/null +++ b/docs/make.bat @@ -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.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 diff --git a/docs/math.rst b/docs/math.rst new file mode 100644 index 0000000..683543b --- /dev/null +++ b/docs/math.rst @@ -0,0 +1,14 @@ +Math +==== + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + atcoder.math.inv_mod + atcoder.math.crt + atcoder.math.floor_sum + +Note +---- +``atcoder.math.pow_mod`` is not implemented. Use ``pow(x, n, m)`` instead of it. diff --git a/docs/maxflow.rst b/docs/maxflow.rst new file mode 100644 index 0000000..61054bb --- /dev/null +++ b/docs/maxflow.rst @@ -0,0 +1,8 @@ +Maximum Flow +============ + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + atcoder.maxflow.MFGraph diff --git a/docs/mincostflow.rst b/docs/mincostflow.rst new file mode 100644 index 0000000..2e35e5d --- /dev/null +++ b/docs/mincostflow.rst @@ -0,0 +1,8 @@ +Minimum-Cost Flow +================= + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + atcoder.mincostflow.MCFGraph diff --git a/docs/modint.rst b/docs/modint.rst new file mode 100644 index 0000000..0dd6350 --- /dev/null +++ b/docs/modint.rst @@ -0,0 +1,8 @@ +Modint +====== + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + atcoder.modint.Modint diff --git a/docs/scc.rst b/docs/scc.rst new file mode 100644 index 0000000..676cce0 --- /dev/null +++ b/docs/scc.rst @@ -0,0 +1,8 @@ +Strongly Connected Components +============================= + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + atcoder.scc.SCCGraph diff --git a/docs/segtree.rst b/docs/segtree.rst new file mode 100644 index 0000000..a621546 --- /dev/null +++ b/docs/segtree.rst @@ -0,0 +1,8 @@ +Segment Tree +============ + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + atcoder.segtree.SegTree diff --git a/docs/string.rst b/docs/string.rst new file mode 100644 index 0000000..db93234 --- /dev/null +++ b/docs/string.rst @@ -0,0 +1,10 @@ +String Algorithms +================= + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + atcoder.string.suffix_array + atcoder.string.lcp_array + atcoder.string.z_algorithm diff --git a/docs/twosat.rst b/docs/twosat.rst new file mode 100644 index 0000000..169e1fe --- /dev/null +++ b/docs/twosat.rst @@ -0,0 +1,8 @@ +2-SAT +===== + +.. autosummary:: + :toctree: generated/ + :nosignatures: + + atcoder.twosat.TwoSAT diff --git a/setup.cfg b/setup.cfg index aca82ac..fb00f9a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,6 +13,9 @@ lint = pep8-naming mypy test = pytest +docs = + sphinx + sphinx_rtd_theme [mypy] disallow_untyped_defs = True