Skip to content

Commit 520ca09

Browse files
committed
upgrade documentation
1 parent 239088f commit 520ca09

23 files changed

+1631
-4271
lines changed

changelog.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ Release notes (brainpy)
22
#######################
33

44

5+
6+
7+
.. note::
8+
9+
All history release notes please see `GitHub releases <https://github.com/brainpy/BrainPy/releases>`_.
10+
11+
12+
13+
514
brainpy 2.2.x
615
*************
716

@@ -10,12 +19,6 @@ tackling the shortcomings of brainpy 2.1.x generation,
1019
effectively bringing it to research needs and standards.
1120

1221

13-
.. note::
14-
15-
All history release notes please see `GitHub <https://github.com/brainpy/BrainPy/releases>`_.
16-
17-
18-
1922

2023
Version 2.2.1 (2022.09.09)
2124
==========================

docs/_static/numpy_arrays.png

-189 KB
Binary file not shown.

docs/_templates/class_template.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{ fullname }}
2+
{{ underline }}
3+
4+
.. currentmodule:: {{ module }}
5+
6+
.. autoclass:: {{ objname }}
7+
8+
.. automethod:: __init__
9+
10+
{% block methods %}
11+
12+
{% if methods %}
13+
.. rubric:: Methods
14+
15+
.. autosummary::
16+
{% for item in methods %}
17+
~{{ name }}.{{ item }}
18+
{%- endfor %}
19+
{% endif %}
20+
{% endblock %}
21+
22+
23+
{% block attributes %}
24+
{% if attributes %}
25+
.. rubric:: Attributes
26+
27+
.. autosummary::
28+
{% for item in attributes %}
29+
~{{ name }}.{{ item }}
30+
{%- endfor %}
31+
{% endif %}
32+
{% endblock %}

docs/apis/math.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@
1010
:maxdepth: 1
1111

1212
auto/math/variables
13-
auto/math/delay_vars
14-
auto/math/jit
13+
auto/math/object_transform
1514
auto/math/operators
16-
auto/math/controls
17-
auto/math/autograd
15+
auto/math/delay_vars
1816
auto/math/activations
19-
auto/math/function
2017
math/comparison
2118
auto/math/setting
22-
math_compat

docs/auto_generater.py

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,23 @@ def get_class_funcs(module):
3535
return classes, functions, others
3636

3737

38-
def write_module(module_name, filename, header=None):
38+
def write_module(module_name, filename, header=None, template=False):
3939
module = importlib.import_module(module_name)
4040
classes, functions, others = get_class_funcs(module)
4141

4242
fout = open(filename, 'w')
4343
# write header
4444
if header is None:
4545
header = f'``{module_name}`` module'
46-
else:
47-
header = header
4846
fout.write(header + '\n')
4947
fout.write('=' * len(header) + '\n\n')
5048
fout.write(f'.. currentmodule:: {module_name} \n')
5149
fout.write(f'.. automodule:: {module_name} \n\n')
5250

5351
# write autosummary
5452
fout.write('.. autosummary::\n')
53+
if template:
54+
fout.write(' :template: class_template.rst\n')
5555
fout.write(' :toctree: generated/\n\n')
5656
for m in functions:
5757
fout.write(f' {m}\n')
@@ -205,16 +205,20 @@ def generate_train_docs(path='apis/auto/train/'):
205205
os.makedirs(path)
206206
write_module(module_name='brainpy.train.base',
207207
filename=os.path.join(path, 'base.rst'),
208-
header='Base Training Class')
208+
header='Base Training Class',
209+
template=False)
209210
write_module(module_name='brainpy.train.online',
210211
filename=os.path.join(path, 'online.rst'),
211-
header='Online Training Method')
212+
header='Online Training Method',
213+
template=False)
212214
write_module(module_name='brainpy.train.offline',
213215
filename=os.path.join(path, 'offline.rst'),
214-
header='Offline Training Method')
216+
header='Offline Training Method',
217+
template=False)
215218
write_module(module_name='brainpy.train.back_propagation',
216219
filename=os.path.join(path, 'back_propagation.rst'),
217-
header='Back-propagation Training Method')
220+
header='Back-propagation Training Method',
221+
template=False)
218222

219223

220224
def generate_base_docs(path='apis/auto/'):
@@ -491,43 +495,38 @@ def generate_math_docs(path='apis/auto/math/'):
491495

492496
module_and_name = [
493497
('pre_syn_post', '``pre-syn-post`` Transformations',),
494-
('sparse_matmul', 'Sparse Matrix Multiplication',),
495-
('event_matmul', 'Event-based Matrix Multiplication',),
496-
('spikegrad', 'Surrogate Gradients for Spike Operation',),
498+
('surrogate', 'Surrogate Gradients',),
497499
('op_register', 'Operator Registration',),
498500
('wrap_jax', 'Other Operators',),
499501
]
500502
write_submodules(module_name='brainpy.math.operators',
501503
filename=os.path.join(path, 'operators.rst'),
502-
header='Sparse & Event-based Operators',
504+
header='Brain Dynamics Modeling Operators',
505+
submodule_names=[k[0] for k in module_and_name],
506+
section_names=[k[1] for k in module_and_name])
507+
508+
module_and_name = [
509+
('autograd', 'Automatic Differentiation'),
510+
('controls', 'Control Flows'),
511+
# ('parallels', 'Parallel Compilation'),
512+
('jit', 'JIT Compilation'),
513+
('function', 'Function to Object'),
514+
]
515+
write_submodules(module_name='brainpy.math.object_transform',
516+
filename=os.path.join(path, 'object_transform.rst'),
517+
header='Object-oriented Transformation',
503518
submodule_names=[k[0] for k in module_and_name],
504519
section_names=[k[1] for k in module_and_name])
505520

506521
write_module(module_name='brainpy.math.activations',
507522
filename=os.path.join(path, 'activations.rst'),
508523
header='Activation Functions')
509-
write_module(module_name='brainpy.math.autograd',
510-
filename=os.path.join(path, 'autograd.rst'),
511-
header='Automatic Differentiation')
512-
write_module(module_name='brainpy.math.controls',
513-
filename=os.path.join(path, 'controls.rst'),
514-
header='Control Flows')
515-
516-
write_module(module_name='brainpy.math.parallels',
517-
filename=os.path.join(path, 'parallels.rst'),
518-
header='Parallel Compilation')
519-
write_module(module_name='brainpy.math.jit',
520-
filename=os.path.join(path, 'jit.rst'),
521-
header='JIT Compilation')
522-
write_module(module_name='brainpy.math.jaxarray',
524+
write_module(module_name='brainpy.math.ndarray',
523525
filename=os.path.join(path, 'variables.rst'),
524526
header='Math Variables')
525527
write_module(module_name='brainpy.math.setting',
526528
filename=os.path.join(path, 'setting.rst'),
527529
header='Setting')
528-
write_module(module_name='brainpy.math.function',
529-
filename=os.path.join(path, 'function.rst'),
530-
header='Function')
531530
write_module(module_name='brainpy.math.delayvars',
532531
filename=os.path.join(path, 'delay_vars.rst'),
533532
header='Delay Variables')

docs/conf.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@
6565
'sphinx.ext.autosummary',
6666
'sphinx.ext.intersphinx',
6767
'sphinx.ext.mathjax',
68-
# 'sphinx-mathjax-offline',
6968
'sphinx.ext.napoleon',
7069
'sphinx.ext.viewcode',
7170
'sphinx_autodoc_typehints',
7271
'myst_nb',
7372
'matplotlib.sphinxext.plot_directive',
74-
'sphinx_thebe'
73+
'sphinx_thebe',
74+
75+
# 'sphinx-mathjax-offline',
7576
]
7677
# Add any paths that contain custom static files (such as style sheets) here,
7778
# relative to this directory. They are copied after the builtin static files,
@@ -102,9 +103,9 @@
102103
"dollarmath",
103104
"amsmath",
104105
"deflist",
106+
"colon_fence",
105107
# "html_admonition",
106108
# "html_image",
107-
"colon_fence",
108109
# "smartquotes",
109110
# "replacements",
110111
# "linkify",

docs/index.rst

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ high-performance Brain Dynamics Programming (BDP). Among its key ingredients, Br
4444
tutorial_analysis/index
4545

4646

47+
.. toctree::
48+
:maxdepth: 1
49+
:caption: Advanced Tutorials
50+
51+
tutorial_advanced/variables.ipynb
52+
tutorial_advanced/base_and_collector.ipynb
53+
tutorial_advanced/compilation.ipynb
54+
tutorial_advanced/differentiation.ipynb
55+
tutorial_advanced/adavanced_lowdim_analysis.ipynb
56+
tutorial_advanced/operator_customization.ipynb
57+
tutorial_advanced/interoperation.ipynb
58+
59+
60+
4761
.. toctree::
4862
:maxdepth: 1
4963
:caption: Toolboxes
@@ -60,25 +74,12 @@ high-performance Brain Dynamics Programming (BDP). Among its key ingredients, Br
6074
tutorial_toolbox/inputs
6175

6276

63-
.. toctree::
64-
:maxdepth: 1
65-
:caption: Advanced Tutorials
66-
67-
tutorial_advanced/variables.ipynb
68-
tutorial_advanced/base_and_collector.ipynb
69-
tutorial_advanced/compilation.ipynb
70-
tutorial_advanced/differentiation.ipynb
71-
tutorial_advanced/adavanced_lowdim_analysis.ipynb
72-
tutorial_advanced/operator_customization.ipynb
73-
tutorial_advanced/interoperation.ipynb
74-
75-
76-
7777
.. toctree::
7878
:maxdepth: 1
7979
:caption: Frequently Asked Questions
8080

8181
tutorial_FAQs/citing_and_publication
82+
tutorial_FAQs/uniqueness_of-brainpy-math
8283

8384

8485
.. toctree::

0 commit comments

Comments
 (0)