@@ -24,3 +24,116 @@ sphinx-quickstart # launch a basic interactive set up of sphinx
2424```
2525
2626Answer the questions on prompt.
27+
28+ ## Setting up conf.py for matlab doc
29+
30+ Following the documentation from
31+ [ matlabdomain for sphinx] ( https://github.com/sphinx-contrib/matlabdomain ) .
32+
33+ Specify the extensions you are using:
34+
35+ ``` python
36+ extensions = [
37+ ' sphinxcontrib.matlab' ,
38+ ' sphinx.ext.autodoc' ]
39+ ```
40+
41+ ` matlab_src_dir ` in ` docs/source/conf.py ` should have the path (relative to ` conf.py ` )
42+ to the folder containing your matlab code:
43+
44+ ``` python
45+ matlab_src_dir = os.path.dirname(os.path.abspath(' ../../src' ))
46+ ```
47+
48+ ## reStructured text markup
49+
50+ reStructured text mark up
51+ [ primer] ( https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html ) .
52+
53+ ## "Templates"
54+
55+ There are different ways you can document the help section of your matlab
56+ functions so it can be documented automatically by sphinx.
57+
58+ ``` matlab
59+ function y = my_function(arg1, arg2)
60+ %
61+ % Describe what the function does here.
62+ %
63+ % y = my_function_napoleon(arg1, arg2)
64+ %
65+ % :param arg1: The first input value
66+ % :param arg2: The second input value
67+ % :returns: The input value multiplied by two
68+
69+ y = arg1 + arg2
70+ ```
71+
72+ "Napoleon" way more similar to Numpy:
73+
74+ ``` matlab
75+ function y = my_function_napoleon(arg1, arg2)
76+ %
77+ % Describe what the function does here.
78+ %
79+ % y = my_function_napoleon(arg1, arg2)
80+ %
81+ % Parameters:
82+ % x: The first input value
83+ %
84+ % y: The second input value
85+ %
86+ % Returns:
87+ % The input value multiplied by two
88+
89+ y = x * 2;
90+ ```
91+
92+ You then just need to insert this in your ` .rst ` file for the documentation to
93+ be done automatically.
94+
95+ ``` rst
96+
97+ .. automodule:: src .. <-- This is necessary for autodocumenting the rest
98+
99+ .. autofunction:: my_function
100+
101+ .. autofunction:: my_function_napoleon
102+ ```
103+
104+ ## Build the documentation locally
105+
106+ From the ` docs ` directory:
107+
108+ ``` bash
109+ sphinx-build -b html source build
110+ ```
111+
112+ This will build an html version of the doc in the ` build ` folder.
113+
114+ ## Buid the documentation with Read the Docs
115+
116+ Add a [ ` .readthedocs.yml ` ] ( ../.readthedocs.yml ) file in the root of your repo.
117+
118+ See [ HERE] ( https://docs.readthedocs.io/en/stable/config-file/v2.html ) for
119+ details.
120+
121+ You can then trigger the build of the doc by going to the [ read the docs]
122+ website: https://readthedocs.org .
123+
124+ You might need to be added as a maintainer of the doc.
125+
126+ The doc can be built from any branch of a repo.
127+
128+ <!-- TODO -->
129+
130+ ## Other matlab projects that use...
131+
132+ ### Sphinx
133+
134+ Some are listed
135+ https://github.com/sphinx-contrib/matlabdomain#users
136+
137+ ### Read the docs
138+
139+ - [ qMRLab] ( https://github.com/qMRLab/qMRLab/wiki/Guideline:-Generating-Documentation )
0 commit comments