diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..67f5955 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,18 @@ +version: 2 + +build: + os: ubuntu-22.04 + tools: + python: "3.11" + apt_packages: + - graphviz + +sphinx: + configuration: docs/conf.py + +python: + install: + - method: pip + path: . + extra_requirements: + - doc diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..105f812 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,2 @@ +_autosummary/ +_build/ diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d4bb2cb --- /dev/null +++ b/docs/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 = . +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/docs/_static/.gitkeep b/docs/_static/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/_templates/class_custom.rst b/docs/_templates/class_custom.rst new file mode 100644 index 0000000..3552ca2 --- /dev/null +++ b/docs/_templates/class_custom.rst @@ -0,0 +1,39 @@ +{{ name | escape | underline}} + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ fullname }} + :members: + :show-inheritance: + :inherited-members: + :undoc-members: + :member-order: groupwise + + {% block attributes %} + {% if attributes %} + .. rubric:: {{ _('Attributes') }} + + .. autosummary:: + {% for item in attributes %} + ~{{ name }}.{{ item }} + {%- endfor %} + {% endif %} + {% endblock %} + + {% block methods %} + {% if methods %} + .. rubric:: {{ _('Methods') }} + + .. autosummary:: + {% for item in methods %} + ~{{ name }}.{{ item }} + {%- endfor %} + {% endif %} + {% endblock %} + + {% block dia %} + .. rubric:: {{ _('Inheritance Diagram') }} + + .. inheritance-diagram:: {{ fullname }} + {% endblock %} + diff --git a/docs/_templates/function_custom.rst b/docs/_templates/function_custom.rst new file mode 100644 index 0000000..d9010b9 --- /dev/null +++ b/docs/_templates/function_custom.rst @@ -0,0 +1,5 @@ +{{ name | escape | underline}} + +.. currentmodule:: {{ module }} + +.. autofunction:: {{ fullname }} \ No newline at end of file diff --git a/docs/_templates/module_custom.rst b/docs/_templates/module_custom.rst new file mode 100644 index 0000000..04b99cf --- /dev/null +++ b/docs/_templates/module_custom.rst @@ -0,0 +1,69 @@ +{{ name | escape | underline}} + +.. automodule:: {{ fullname }} + + {% block attributes %} + {% if attributes %} + .. rubric:: Module Attributes + + .. autosummary:: + :toctree: + {% for item in attributes %} + {{ item }} + {%- endfor %} + {% endif %} + {% endblock %} + + {% block functions %} + {% if functions %} + .. rubric:: {{ _('Functions') }} + + .. autosummary:: + :toctree: + :template: function_custom.rst + {% for item in functions %} + {{ item }} + {%- endfor %} + {% endif %} + {% endblock %} + + {% block classes %} + {% if classes %} + .. rubric:: {{ _('Classes') }} + + .. autosummary:: + :toctree: + :template: class_custom.rst + {% for item in classes %} + {{ item }} + {%- endfor %} + {% endif %} + {% endblock %} + + {% block exceptions %} + {% if exceptions %} + .. rubric:: {{ _('Exceptions') }} + + .. autosummary:: + :toctree: + {% for item in exceptions %} + {{ item }} + {%- endfor %} + {% endif %} + {% endblock %} + + {% block modules %} + {% if modules %} + .. rubric:: Modules + + .. autosummary:: + :toctree: + :template: module_custom.rst + :recursive: + {% for item in modules %} + {{ item }} + {%- endfor %} + {% endif %} + {% endblock %} + + diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..578b544 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,98 @@ +# 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 + +package_path = os.path.abspath('../') +sys.path.insert(0, package_path) +os.environ['PYTHONPATH'] = ';'.join((package_path, os.environ.get('PYTHONPATH', ''))) + +# -- Project information ----------------------------------------------------- + +project = 'colorsynth' +copyright = '2023, Roy T. Smart' +author = 'Roy T. Smart' + +# -- 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.napoleon', + 'sphinx.ext.autodoc', + 'sphinx.ext.autosummary', + 'sphinx.ext.intersphinx', + 'sphinx.ext.inheritance_diagram', + 'sphinx.ext.viewcode', + 'jupyter_sphinx', +] +autosummary_generate = True # Turn on sphinx.ext.autosummary +autosummary_imported_members = True +autosummary_ignore_module_all = False +# autoclass_content = 'both' +autodoc_typehints = "description" + +# typehints_fully_qualified = True + +# napoleon_include_special_with_doc = True +# napoleon_include_init_with_doc = True + +graphviz_output_format = 'png' +inheritance_graph_attrs = dict(rankdir='TB') + +# 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 +# This pattern also affects html_static_path and html_extra_path. +# directories to ignore when looking for source files. +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 = 'pydata_sphinx_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'] + +html_theme_options = { + "icon_links": [ + { + "name": "GitHub", + "url": "https://github.com/sun-data/colorsynth", + "icon": "fa-brands fa-github", + "type": "fontawesome", + }, + { + "name": "PyPI", + "url": "https://pypi.org/project/colorsynth/", + "icon": "fa-brands fa-python", + }, + ], +} + +# https://github.com/readthedocs/readthedocs.org/issues/2569 +master_doc = 'index' + +intersphinx_mapping = { + 'python': ('https://docs.python.org/3', None), + 'numpy': ('https://numpy.org/doc/stable/', None), + 'matplotlib': ('https://matplotlib.org/stable', None), + 'astropy': ('https://docs.astropy.org/en/stable/', None), +} diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..f8bc2b7 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,18 @@ +Introduction +============ + +.. autosummary:: + :toctree: _autosummary + :template: module_custom.rst + :recursive: + + colorsynth + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..922152e --- /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