Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5eb0b56
set up basic environment for sphinx doc
marcobarilari Oct 25, 2020
f5e9bcf
build doc locally
marcobarilari Oct 25, 2020
782ac71
add readthedocs yml files
marcobarilari Oct 25, 2020
3a0844b
Update docs/source/conf.py
marcobarilari Oct 25, 2020
966b852
Update docs/source/conf.py
marcobarilari Oct 25, 2020
47c03f4
Update docs/source/conf.py
marcobarilari Oct 25, 2020
759662e
Update docs/source/conf.py
marcobarilari Oct 25, 2020
e7d75e3
Update docs/source/conf.py
marcobarilari Oct 25, 2020
f38b7bc
Update docs/source/conf.py
marcobarilari Oct 25, 2020
b208cd8
Update docs/source/conf.py
marcobarilari Oct 25, 2020
83461e4
Update docs/source/index.rst
marcobarilari Oct 25, 2020
b52733c
re build sphinx doc
marcobarilari Oct 25, 2020
f4cf18c
CI md fix
marcobarilari Oct 25, 2020
9dd8cb5
CI md fix 2
marcobarilari Oct 25, 2020
3671580
ignore files defined by virtual env
Remi-Gau Oct 25, 2020
84ef912
CI fix 3
marcobarilari Oct 25, 2020
de17a47
Merge remote-tracking branch 'origin/marco_sphinx-docs' into marco_sp…
marcobarilari Oct 25, 2020
6276d1f
remove content of the build folder
Remi-Gau Oct 25, 2020
f4a8c72
fix extra space in index
Remi-Gau Oct 25, 2020
2e901af
add some demo for cpp ptb functions and those in subfolders
Remi-Gau Oct 25, 2020
e47f8dd
add function list in src
marcobarilari Oct 31, 2020
c49eb8f
add all the function to sphinx function description
marcobarilari Oct 31, 2020
8a4043f
fix contenents
marcobarilari Oct 31, 2020
449adac
add installation
marcobarilari Oct 31, 2020
19fd82f
make installation section nicer
marcobarilari Oct 31, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@
# exclude content of logfiles folders
*.tsv
*.mat
check_my_code_report.txt
check_my_code_report.txt

# exclude content of files for virtual env (mostly for the doc)
cpp_ptb

# ignore file created by sphynx
/docs/build
26 changes: 26 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py
builder: html
fail_on_warning: true

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF
formats:
- pdf

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt
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)
139 changes: 139 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Setting up sphinx to create a matlab doc

## Set up virtual environment

```bash
virtualenv -p python3 cpp_ptb
source cpp_ptb/bin/activate

pip install -r requirements.txt
```

## Quick start on the doc

See the [sphinx doc](https://www.sphinx-doc.org/en/master/usage/quickstart.html)
for more.

This
[blog post](https://medium.com/@richdayandnight/a-simple-tutorial-on-how-to-document-your-python-project-using-sphinx-and-rinohtype-177c22a15b5b)
is also useful.

```bash
cd docs
sphinx-quickstart # launch a basic interactive set up of sphinx
```

Answer the questions on prompt.

## Setting up conf.py for matlab doc

Following the documentation from
[matlabdomain for sphinx](https://github.com/sphinx-contrib/matlabdomain).

Specify the extensions you are using:

```python
extensions = [
'sphinxcontrib.matlab',
'sphinx.ext.autodoc']
```

`matlab_src_dir` in `docs/source/conf.py` should have the path (relative to `conf.py`)
to the folder containing your matlab code:

```python
matlab_src_dir = os.path.dirname(os.path.abspath('../../src'))
```

## reStructured text markup

reStructured text mark up
[primer](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html).

## "Templates"

There are different ways you can document the help section of your matlab
functions so it can be documented automatically by sphinx.

```matlab
function y = my_function(arg1, arg2)
%
% Describe what the function does here.
%
% y = my_function_napoleon(arg1, arg2)
%
% :param arg1: The first input value
% :param arg2: The second input value
% :returns: The input value multiplied by two

y = arg1 + arg2
```

"Napoleon" way more similar to Numpy:

```matlab
function y = my_function_napoleon(arg1, arg2)
%
% Describe what the function does here.
%
% y = my_function_napoleon(arg1, arg2)
%
% Parameters:
% x: The first input value
%
% y: The second input value
%
% Returns:
% The input value multiplied by two

y = x * 2;
```

You then just need to insert this in your `.rst` file for the documentation to
be done automatically.

```rst

.. automodule:: src .. <-- This is necessary for autodocumenting the rest

.. autofunction:: my_function

.. autofunction:: my_function_napoleon
```

## Build the documentation locally

From the `docs` directory:

```bash
sphinx-build -b html source build
```

This will build an html version of the doc in the `build` folder.

## Buid the documentation with Read the Docs

Add a [`.readthedocs.yml`](../.readthedocs.yml) file in the root of your repo.

See [HERE](https://docs.readthedocs.io/en/stable/config-file/v2.html) for
details.

You can then trigger the build of the doc by going to the [read the docs](https://readthedocs.org)
website.

You might need to be added as a maintainer of the doc.

The doc can be built from any branch of a repo.

<!-- TODO -->

## Other matlab projects that use

### Sphinx

Some are listed
[sphinx-contrib/matlabdomain#users](https://github.com/sphinx-contrib/matlabdomain#users)

### Read the docs

- [qMRLab](https://github.com/qMRLab/qMRLab/wiki/Guideline:-Generating-Documentation)
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.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
4 changes: 4 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Sphinx
sphinxcontrib-matlabdomain
sphinxcontrib-napoleon
sphinx_rtd_theme
Binary file added docs/source/_static/cpp_lab_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# 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 = 'CPP_PTB'
copyright = '2020, CPP_PTB developers'
author = 'CPP_PTB developers'

# The full version, including alpha/beta/rc tags
release = 'v1.0.0'


# -- 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 = [
'sphinxcontrib.matlab',
'sphinx.ext.autodoc']
matlab_src_dir = os.path.dirname(os.path.abspath('../../src'))
primary_domain = 'mat'

# 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']

html_logo = '_static/cpp_lab_logo.png'

# html_theme_options = {
# 'github_user': 'cpp-lln-lab',
# 'github_repo': 'CPP_BIDS_SPM_pipeline',
# 'github_button': True,
# 'github_banner': True
# }
# html_theme_options = {
# 'collapse_navigation': False,
# 'display_version': False,
# 'navigation_depth': 4,
# }

html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
'donate.html',
]
}
Loading