diff --git a/.gitignore b/.gitignore index 1b6d0d5f0bc3f67a7ff5e6894783f0936f2782d4..54a51e8a71907179cc36973fb701a940dae5f742 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,12 @@ * !*.py +!*.rst !.vscode !.gitignore !requirements.txt !tests/ -!plot_serializer/ \ No newline at end of file +!plot_serializer/ +!doc/ +!make.bat +!Makefile \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 795d95781372e0fc483fcb74c499e2891d25d4bd..746b413d8a9747ec2f3395a51d029786f3df04ac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,3 +45,6 @@ lint: # script: # - pytest +doc: + script: + - make html diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..26217e7ecf2a3c15682a061a05e7d650f7db8fd2 --- /dev/null +++ b/Makefile @@ -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 = doc +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) diff --git a/doc/conf.py b/doc/conf.py new file mode 100644 index 0000000000000000000000000000000000000000..85450f5d1dac6f1d75363d63eb9ff3b53e174ad6 --- /dev/null +++ b/doc/conf.py @@ -0,0 +1,61 @@ +# 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 = "Plot Serializer" +copyright = "2023, Michaela Lestakova, Kevin Logan" +author = "Michaela Lestakova, Kevin Logan" + + +# -- 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.viewcode", + "sphinx_rtd_theme", + "sphinx.ext.autosummary", + "autoapi.extension", +] + +napoleon_google_docstring = True +autoapi_dirs = ["../plot_serializer"] + +# 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/doc/index.rst b/doc/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..9bb8bf2a0b1c73fa1e6d81fe74fd25304c4080de --- /dev/null +++ b/doc/index.rst @@ -0,0 +1,19 @@ +.. Plot Serializer documentation master file, created by + sphinx-quickstart on Fri Aug 11 11:31:38 2023. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to Plot Serializer's documentation! +=========================================== + +.. toctree:: + autoapi/index + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/make.bat b/make.bat new file mode 100644 index 0000000000000000000000000000000000000000..976e41b3f028add18063a7ed9932e15a577799d9 --- /dev/null +++ b/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=doc +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 diff --git a/plot_serializer/adapters.py b/plot_serializer/adapters.py index 2c5ce37118cd740786a8b62ac352ba2b953a9e22..7568dd0338c76d50ab54bcbab2ce9f36d654f8e2 100644 --- a/plot_serializer/adapters.py +++ b/plot_serializer/adapters.py @@ -1,3 +1,8 @@ +"""Adapters + + +""" + from plot_serializer.plot import Plot, Axis, PlottedElement diff --git a/plot_serializer/serializer.py b/plot_serializer/serializer.py index 6f8ce69bc394b8c3c03f12c6286caf25cbfd2dbf..f43854e1b03533c2d8ebfdb8f03a9b500a843685 100644 --- a/plot_serializer/serializer.py +++ b/plot_serializer/serializer.py @@ -32,6 +32,14 @@ class Serializer: return converted_plot def to_json(self, header=["id"]) -> str: + """Exports plot to json. + + Args: + header (list, optional): list of keys to appear on top of the json string. Defaults to ["id"]. + + Returns: + str: json string + """ d = json.loads(json.dumps(self.plot, default=lambda o: self._getattrorprop(o))) od = OrderedDict() for k in header: diff --git a/requirements.txt b/requirements.txt index 8a43b6f988c6f3a8ed662a9b3c5dbe033289f356..b4c7ad7d156736d692e7f54c01de03c99cfab507 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,8 @@ numpy pandas matplotlib sphinx # documentation +sphinx_rtd_theme +sphinx-autoapi flake8 # linting black # autoformatting mypy # typechecking