Skip to content

Commit

Permalink
intialize documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
skim0119 committed Apr 8, 2022
1 parent 20e8a69 commit acb02dc
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 1 deletion.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -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)
55 changes: 55 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Documentation

We use [`Sphinx`](https://www.sphinx-doc.org/en/master/) and [`ReadtheDocs`](https://readthedocs.org/) to organize our [documentation page]().

In addition, we utilize the following extensions to enhance the documentation :coffee:
- `numpydoc`: We favor [numpy documentation style](https://numpydoc.readthedocs.io/en/latest/format.html) for API documentation.
- `myst_parser`: We like to write documentation and guidelines in `markdown` format.

## Build documentation

The `sphinx` is already initialized in `docs` directory. In order to build the documentation, you will need additional packages listed in `docs/requirements.txt`.

```bash
pip install sphinx sphinx_rtd_theme myst-parser numpydoc
cd docs
make clean
make html
```

Once the documentation building is done, open `docs/_build/html/index.html` to view.

Use `make help` for other options.

## User Guide

User guidelines and tutorials are written in `.rst` or `.md` format.
These files will be managed in `docs` directory.

## API documentation

The docstring for function or modules are automatically parsed using `sphinx`+`numpydoc`.
Any inline function description, such as

```py
""" This is the form of a docstring.
... description
Attributes
----------
x : type
x description
y : type
y description
"""
```

will be parsed and displayed in API documentation. See `numpydoc` for more details.

## ReadtheDocs

`ReadtheDocs` runs `sphinx` internally and maintain the documentation website. We will always activate the `stable` and `latest` version, and few past-documentations will also be available for the support.

@nmnaughton and @skim449 has access to the `ReadtheDocs` account.
103 changes: 103 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# 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

# import sphinx_rtd_theme

sys.path.insert(0, os.path.abspath("../"))

from miv.version import VERSION


# -- Project information -----------------------------------------------------

project = "Mind-in-Vitro MiV-OS"
copyright = "2022, GazzolaLab"
author = "Gazzola Lab"

# The full version, including alpha/beta/rc tags
release = VERSION

# -- 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.autosectionlabel",
"sphinx_autodoc_typehints",
#'sphinx.ext.napoleon',
"sphinx.ext.viewcode",
"sphinx_rtd_theme",
"sphinx.ext.mathjax",
"numpydoc",
"myst_parser",
]

myst_enable_extensions = [
"amsmath",
"colon_fence",
"deflist",
"dollarmath",
"fieldlist",
"html_admonition",
"html_image",
]

# 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 = [
"README.md", # File reserved to explain how documentationing works.
]

autodoc_default_flags = [
"members",
"private-members",
"special-members",
"show-inheritance",
]
autosectionlabel_prefix_document = True

source_parsers = {}
source_suffix = [".rst", ".md"]

master_doc = "index"
# -- 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_book_theme"
html_theme_options = {
"repository_url": "https://github.com/GazzolaLab/MiV-OS",
"use_repository_button": True,
}
html_title = "MiV-OS"
# html_logo = ""
# pygments_style = "sphinx"

# 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_css_files = ["css/*", "css/logo.css"]

# -- Options for numpydoc ---------------------------------------------------
numpydoc_show_class_members = False
3 changes: 3 additions & 0 deletions docs/guide/tutorials.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*****************
Tutorial Examples
*****************
21 changes: 21 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. MiV-OS documentation master file, created by
sphinx-quickstart on Thu Mar 24 23:35:49 2022.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to MiV-OS's documentation!
================================

.. toctree::
:maxdepth: 2
:caption: Contents:

guide/tutorials


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -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.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
11 changes: 11 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# File: docs/requirements.txt

-r ../requirements.txt
docutils
myst-parser
numpydoc
readthedocs-sphinx-search==0.1.1
sphinx==4.4.0
sphinx-autodoc-typehints
sphinx-book-theme
sphinx_rtd_theme==1.0.0
15 changes: 14 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,20 @@
]

# What packages are optional?
EXTRAS = {"dev": ["black", "pre-commit", "pytest", "flake8"], "build": ["twine"]}
EXTRAS = {
"dev": ["black", "pre-commit", "pytest", "flake8"],
"build": ["twine"],
"docs": [
"sphinx==4.4.0",
"sphinx_rtd_theme==1.0.0",
"sphinx-book-theme",
"readthedocs-sphinx-search==0.1.1",
"sphinx-autodoc-typehints",
"myst-parser",
"numpydoc",
"docutils",
],
}

here = os.path.abspath(os.path.dirname(__file__))

Expand Down

0 comments on commit acb02dc

Please sign in to comment.