diff --git a/.gitignore b/.gitignore index 13a1a9f..03d0620 100644 --- a/.gitignore +++ b/.gitignore @@ -128,9 +128,6 @@ dmypy.json # Pyre type checker .pyre/ -# Sphinx documentation -docs/_build/ - # Editor backup files (Emacs, vim) *~ *.sw[a-p] 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/api.rst b/docs/api.rst new file mode 100644 index 0000000..476d94d --- /dev/null +++ b/docs/api.rst @@ -0,0 +1,12 @@ +API +=== + +.. toctree:: + :maxdepth: 2 + + yaml_file + timetools + jinja + logger + + diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..b161e11 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,34 @@ +# 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 os +import sys +sys.path.insert(0, os.path.abspath('.')) + +project = 'wxflow' +copyright = '2023, NOAA/NWS/NCEP/EMC' +author = 'NOAA/NWS/NCEP/EMC' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + "sphinx.ext.autodoc", +] + +templates_path = ['_templates'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'sphinx_rtd_theme' +html_theme_path = ["_themes", ] +html_static_path = ['_static'] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..e282a2d --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,58 @@ +.. wxflow documentation master file, created by + sphinx-quickstart on Thu Jul 6 11:20:05 2023. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +wxflow +====== + +.. image:: https://img.shields.io/pypi/wxflow + :target: https://pypi.org/project/wxflow/ + :alt: PyPI +.. image:: https://github.com/NOAA-EMC/wxflow/workflows/pynorms/badge.svg + :target: https://github.com/NOAA-EMC/wxflow/actions/workflows/pynorms.yaml + :alt: pynorms +.. image:: https://github.com/NOAA-EMC/wxflow/workflows/pytests/badge.svg + :target: https://github.com/NOAA-EMC/wxflow/actions/workflows/pytests.yaml + :alt: pytests + +A Python library of common tools used in weather workflows. + +Installation +------------ + +.. code-block:: bash + + pip install wxflow + +Description +----------- + +wxflow is a Python library of common tools used in weather workflows. It is +designed to be used in NWP applications such as GFS, GEFS, and RRFS workflows. Some of the tools +included in wxflow are: + +- **logger**: A generic program-wide logging tool. +- **yamltools**: A YAML parser that allows loading of nested yaml files and resolves environment variables. +- **timetools**: A collection of datetime tools that allows for easy transformation between the various formats of datetime used in the applications. +- **executable**: A tool that allows for running command line programs within the python environment. + executables. +- **jinja**: A jinja tool that allows for the use of Jinja2 templates with filters. +- **task**: A task tool that allows for the use of a YAML file to configure + tasks. + + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + API Reference + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/jinja.rst b/docs/jinja.rst new file mode 100644 index 0000000..2eecbb6 --- /dev/null +++ b/docs/jinja.rst @@ -0,0 +1,6 @@ +.. currentmodule:: wxflow + +.. autoclass:: Jinja + :members: + :show-inheritance: + :inherited-members: diff --git a/docs/logger.rst b/docs/logger.rst new file mode 100644 index 0000000..8db4d7d --- /dev/null +++ b/docs/logger.rst @@ -0,0 +1,11 @@ +.. currentmodule:: wxflow + +.. autoclass:: Logger + :members: + :show-inheritance: + :inherited-members: +.. autoclass:: ColoredFormatter + :members: + :show-inheritance: + :inherited-members: +.. autofunction:: logit diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..32bb245 --- /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 + +%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/docs/requirements_docs.txt b/docs/requirements_docs.txt new file mode 100644 index 0000000..8d957d7 --- /dev/null +++ b/docs/requirements_docs.txt @@ -0,0 +1,2 @@ +sphinx +sphinx-autobuild diff --git a/docs/timetools.rst b/docs/timetools.rst new file mode 100644 index 0000000..44df413 --- /dev/null +++ b/docs/timetools.rst @@ -0,0 +1,18 @@ +.. currentmodule:: wxflow + +.. autofunction:: to_datetime +.. autofunction:: to_timedelta +.. autofunction:: datetime_to_YMDH +.. autofunction:: datetime_to_YMD +.. autofunction:: datetime_to_JDAY +.. autofunction:: timedelta_to_HMS +.. autofunction:: strftime +.. autofunction:: strptime +.. autofunction:: to_YMDH +.. autofunction:: to_YMD +.. autofunction:: to_JDAY +.. autofunction:: to_julian +.. autofunction:: to_isotime +.. autofunction:: to_fv3time +.. autofunction:: add_to_datetime +.. autofunction:: add_to_timedelta diff --git a/docs/yaml_file.rst b/docs/yaml_file.rst new file mode 100644 index 0000000..b0196e1 --- /dev/null +++ b/docs/yaml_file.rst @@ -0,0 +1,11 @@ +.. currentmodule:: wxflow + +.. autoclass:: YAMLFile + :members: save, dump, as_dict + :show-inheritance: +.. autofunction:: parse_yaml +.. autofunction:: parse_yamltmpl +.. autofunction:: parse_j2yaml +.. autofunction:: save_as_yaml +.. autofunction:: dump_as_yaml +.. autofunction:: vanilla_yaml diff --git a/setup.cfg b/setup.cfg index b2dfcf0..682f04a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -54,6 +54,7 @@ where=src [options.extras_require] dev = pytest>=7; pytest-cov>=3 +docs = sphinx>=4 sphinx_rtd_theme>=0.5 [green] file-pattern = test_*.py