From de828313190129fccf92e780ef4e8b5733800015 Mon Sep 17 00:00:00 2001 From: BO ZHANG Date: Tue, 23 Aug 2022 21:33:13 +0800 Subject: [PATCH] added sphinx doc --- doc/Makefile | 20 ++++++++++++ doc/apidoc.sh | 2 ++ doc/make.bat | 35 +++++++++++++++++++++ doc/preview.sh | 3 ++ doc/source/api/csst_proto.rst | 27 ++++++++++++++++ doc/source/conf.py | 59 +++++++++++++++++++++++++++++++++++ doc/source/index.rst | 50 +++++++++++++++++++++++++++++ doc/source/numpydoc.rst | 9 ++++++ doc/source/sphinxdoc.rst | 8 +++++ doc/source/unittest.rst | 7 +++++ 10 files changed, 220 insertions(+) create mode 100644 doc/Makefile create mode 100644 doc/apidoc.sh create mode 100644 doc/make.bat create mode 100644 doc/preview.sh create mode 100644 doc/source/api/csst_proto.rst create mode 100644 doc/source/conf.py create mode 100644 doc/source/index.rst create mode 100644 doc/source/numpydoc.rst create mode 100644 doc/source/sphinxdoc.rst create mode 100644 doc/source/unittest.rst diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/doc/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 = 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) diff --git a/doc/apidoc.sh b/doc/apidoc.sh new file mode 100644 index 0000000..f29cbb4 --- /dev/null +++ b/doc/apidoc.sh @@ -0,0 +1,2 @@ +rm -rf source/api/* +sphinx-apidoc -o source/api ../csst_proto --ext-viewcode --ext-githubpages diff --git a/doc/make.bat b/doc/make.bat new file mode 100644 index 0000000..061f32f --- /dev/null +++ b/doc/make.bat @@ -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 + +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.https://www.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/doc/preview.sh b/doc/preview.sh new file mode 100644 index 0000000..3a23e69 --- /dev/null +++ b/doc/preview.sh @@ -0,0 +1,3 @@ + +make clean html +open ./build/html/index.html \ No newline at end of file diff --git a/doc/source/api/csst_proto.rst b/doc/source/api/csst_proto.rst new file mode 100644 index 0000000..d6617d0 --- /dev/null +++ b/doc/source/api/csst_proto.rst @@ -0,0 +1,27 @@ +csst\_proto package +=================== + + +csst\_proto.flip\_image +----------------------- + +.. automodule:: csst_proto.flip_image + :members: + :undoc-members: + :show-inheritance: + +csst\_proto.some\_other\_modules +-------------------------------- + +.. automodule:: csst_proto.some_other_modules + :members: + :undoc-members: + :show-inheritance: + +csst\_proto.top\_level\_interface +--------------------------------- + +.. automodule:: csst_proto.top_level_interface + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 0000000..4da35ed --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,59 @@ +# 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 = 'csst_proto' +copyright = '2022, CSST Team' +author = 'CSST Team' + +# The full version, including alpha/beta/rc tags +release = '0.0.1' + + +# -- 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 = ["recommonmark", + "sphinx.ext.autodoc", + "sphinx.ext.napoleon", + "sphinx.ext.viewcode", + "sphinx.ext.mathjax", + ] + +# 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 = [] + + +# -- 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'] \ No newline at end of file diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 0000000..fda2ba9 --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,50 @@ +.. csst_proto documentation master file, created by + sphinx-quickstart on Tue Aug 23 20:39:04 2022. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +csst_proto +========== + +.. meta:: + :description lang=cn: Automate building, versioning, and hosting of your technical documentation continuously on Read the Docs. + + +.. image:: https://readthedocs.org/projects/csst/badge/?version=latest + :target: https://csst.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + + +homepage +-------- + +`csst_proto` is the pipeline package for the **CSST** (Chinese Space Station Telescope). + +GitLab: +https://csst-tb.bao.ac.cn/code/csst-l1/csst_proto + + + +.. toctree:: + :hidden: + :maxdepth: 2 + :caption: unittest + + unittest.rst + + +.. toctree:: + :hidden: + :maxdepth: 2 + :caption: code style + + numpydoc.rst + sphinxdoc.rst + + +.. toctree:: + :hidden: + :maxdepth: 2 + :caption: API + + api/csst_proto.rst \ No newline at end of file diff --git a/doc/source/numpydoc.rst b/doc/source/numpydoc.rst new file mode 100644 index 0000000..fe058d9 --- /dev/null +++ b/doc/source/numpydoc.rst @@ -0,0 +1,9 @@ +Numpydoc +======== + +Numpydoc style, conf https://numpydoc.readthedocs.io/en/latest/format.html + +More specifically, + +- PEP 7 – Style Guide for C Code: https://peps.python.org/pep-0007/ +- PEP 8 – Style Guide for Python Code: https://peps.python.org/pep-0008/ diff --git a/doc/source/sphinxdoc.rst b/doc/source/sphinxdoc.rst new file mode 100644 index 0000000..4a795a9 --- /dev/null +++ b/doc/source/sphinxdoc.rst @@ -0,0 +1,8 @@ +sphinx-based documentation +========================== + +sphinx homepage: +https://www.sphinx-doc.org/en/master/index.html + +a tutorial on how to write restructured text (.rst) files: +https://docutils.sourceforge.io/rst.html diff --git a/doc/source/unittest.rst b/doc/source/unittest.rst new file mode 100644 index 0000000..1cab618 --- /dev/null +++ b/doc/source/unittest.rst @@ -0,0 +1,7 @@ +Unit test +========= + +use + +- `unittest` (https://docs.python.org/3.8/library/unittest.html) +- `pytest` (https://docs.pytest.org/en/stable/) -- GitLab