-
Notifications
You must be signed in to change notification settings - Fork 13
set up sphinx doc #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
marcobarilari
merged 25 commits into
cpp-lln-lab:dev
from
marcobarilari:marco_sphinx-docs
Oct 31, 2020
Merged
set up sphinx doc #138
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 f5e9bcf
build doc locally
marcobarilari 782ac71
add readthedocs yml files
marcobarilari 3a0844b
Update docs/source/conf.py
marcobarilari 966b852
Update docs/source/conf.py
marcobarilari 47c03f4
Update docs/source/conf.py
marcobarilari 759662e
Update docs/source/conf.py
marcobarilari e7d75e3
Update docs/source/conf.py
marcobarilari f38b7bc
Update docs/source/conf.py
marcobarilari b208cd8
Update docs/source/conf.py
marcobarilari 83461e4
Update docs/source/index.rst
marcobarilari b52733c
re build sphinx doc
marcobarilari f4cf18c
CI md fix
marcobarilari 9dd8cb5
CI md fix 2
marcobarilari 3671580
ignore files defined by virtual env
Remi-Gau 84ef912
CI fix 3
marcobarilari de17a47
Merge remote-tracking branch 'origin/marco_sphinx-docs' into marco_sp…
marcobarilari 6276d1f
remove content of the build folder
Remi-Gau f4a8c72
fix extra space in index
Remi-Gau 2e901af
add some demo for cpp ptb functions and those in subfolders
Remi-Gau e47f8dd
add function list in src
marcobarilari c49eb8f
add all the function to sphinx function description
marcobarilari 8a4043f
fix contenents
marcobarilari 449adac
add installation
marcobarilari 19fd82f
make installation section nicer
marcobarilari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: | ||
|
|
||
| # Optionally set the version of Python and requirements required to build your docs | ||
| python: | ||
| version: 3.7 | ||
| install: | ||
| - requirements: docs/requirements.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Sphinx | ||
| sphinxcontrib-matlabdomain | ||
| sphinxcontrib-napoleon | ||
| sphinx_rtd_theme |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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', | ||
| ] | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.