Skip to content

Commit abe5e81

Browse files
hugtalbotjnbrunet
andauthored
Improve documentation (#127)
* first * temp * second Signed-off-by: Jean-Nicolas Brunet <[email protected]> * add images Co-authored-by: Jean-Nicolas Brunet <[email protected]>
1 parent 1f75851 commit abe5e81

File tree

8 files changed

+256
-121
lines changed

8 files changed

+256
-121
lines changed

docs/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ project(Documentation)
22

33
set(DOCUMENTATION_FILES
44
${CMAKE_CURRENT_SOURCE_DIR}/sphinx/source/index.rst
5-
${CMAKE_CURRENT_SOURCE_DIR}/sphinx/source/menu/install.rst
5+
${CMAKE_CURRENT_SOURCE_DIR}/sphinx/source/menu/Installation.rst
66
${CMAKE_CURRENT_SOURCE_DIR}/sphinx/source/menu/Contributing.rst
77
${CMAKE_CURRENT_SOURCE_DIR}/sphinx/source/menu/SofaPlugin.rst
88
${CMAKE_CURRENT_SOURCE_DIR}/sphinx/source/menu/SofaModule.rst
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% extends "!layout.html" %}
2+
3+
{% block menu %}
4+
<a href="{{ pathto(master_doc) }}">Overview</a>
5+
{{ super() }}
6+
{% endblock %}

docs/sphinx/source/conf.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,18 @@
3434
'sphinx.ext.autodoc',
3535
'sphinx.ext.doctest',
3636
'sphinx.ext.autosummary',
37-
#'sphinx.ext.intersphinx',
38-
#'sphinx.ext.mathjax',
39-
#'sphinx.ext.ifconfig',
37+
'sphinxcontrib.contentui',
4038
'sphinx.ext.viewcode',
4139
'sphinx.ext.githubpages',
4240
'sphinx.ext.napoleon',
43-
#'autoapi.sphinx',
44-
#'sphinx.ext.inheritance_diagram'
4541
]
4642

4743
#autoapi_modules = {'Sofa': None, 'Sofa.Core' : None}
4844

4945
import sys
5046
import os
47+
import re
48+
5149
#sys.path.append("/home/dmarchal/projects/DEFROST/dev/sofa2/builds/release/lib/site-packages/")
5250
sys.path.append(os.getcwd()+"/../../sphinx-stubs")
5351
print(sys.path)
@@ -74,17 +72,28 @@
7472

7573
# General information about the project.
7674
project = u'SofaPython3'
77-
copyright = u'2018, [email protected]'
78-
author = u'[email protected]'
75+
copyright = u'2020, SOFA Framework'
76+
author = u'[email protected]'
7977

8078
# The version info for the project you're documenting, acts as replacement for
8179
# |version| and |release|, also used in various other places throughout the
8280
# built documents.
8381
#
8482
# The short X.Y version.
85-
version = u'1.0'
83+
_cmake_version_re = re.compile(r'project[^\S\n]*\(\w*[^\S\n]*VERSION[^\S\n]+(\w+).(\w+).(\w+)[^\S\n]*\)')
84+
85+
version_major = 0
86+
version_minor = 0
87+
version_patch = 0
88+
for line in open('../../../CMakeLists.txt'):
89+
version = _cmake_version_re.search(line)
90+
if version:
91+
version_major, version_minor, version_patch = version.group(1), version.group(2), version.group(3)
92+
break
93+
94+
version = f'{version_major}.{version_minor}'
8695
# The full version, including alpha/beta/rc tags.
87-
release = u'1.0'
96+
release = f'{version}.{version_patch}'
8897

8998
# The language for content autogenerated by Sphinx. Refer to documentation
9099
# for a list of supported languages.
@@ -125,7 +134,7 @@
125134
# Add any paths that contain custom static files (such as style sheets) here,
126135
# relative to this directory. They are copied after the builtin static files,
127136
# so a file named "default.css" will overwrite the builtin "default.css".
128-
html_static_path = ['_static']
137+
html_static_path = []
129138

130139
# Custom sidebar templates, must be a dictionary that maps document names
131140
# to template names.
53 KB
Loading
53.7 KB
Loading

docs/sphinx/source/index.rst

Lines changed: 17 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,39 @@
1-
Welcome to SofaPython3 !
2-
========================
3-
4-
The project is python3 binding for the Sofa simulation framework.
5-
It is composed of one *Sofa plugin* and several *python modules*.
6-
7-
*Sofa plugin* embeds a python3 interpreter and a scene loader. This plugins allows you to load
8-
a python interpreter in a sofa simulation to write Sofa scene directly using python. It also
9-
permits to implement in python3 custom sofa component like ForceField, Controllers, Visitors.
10-
11-
Apart from the SofaPython3 plugin we also provide several *python modules* that exposes python different
12-
parts of Sofa.
13-
14-
The general guidelines design for these binding was to be as much as possible idiomatic python3 API
15-
and with tight integration for numpy.
16-
171
General overview
18-
-----------------
19-
The Sofa python module:
20-
^^^^^^^^^^^^^^^^^^^^^^^
21-
Exposes the base Sofa object to build and manipulate a Sofa simulation.
22-
23-
- contains 4 submodules :
24-
- Sofa.Core, that contains bindings for scene components,
25-
- Sofa.Simulation, that contains functions to conduct simulation,
26-
- Sofa.Types, that contains default types available in Sofa,
27-
- Sofa.Helper, that contains utility functions.
28-
- provides a copy-less API to access the sofa Data containers
29-
- allows to implement custom sofa object (ForceField, Controller) in python
30-
- has docstring documentation
31-
32-
Try it: ```python import Sofa```
33-
34-
The SofaRuntime python module
35-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
36-
- access the runtime specific stuff (GUI, GLViewers, runSofa internal status) [POC]
37-
- docstring with sphinx content [TBD]
38-
39-
Try it: ```python import SofaRuntime```
2+
================
403

41-
Developer's environment
42-
^^^^^^^^^^^^^^^^^^^^^^^
43-
- autogenerated documentation using sphinx [DONE]
44-
- automated update the docs from the c++'s docstring: https://sofapython3.readthedocs.io/en/latest/ [WIP]
45-
- code completion with common editor [WIP, some editor are not working with c++ modules]
4+
The SofaPython3 project brings python bindings for the `SOFA simulation framework <https://www.sofa-framework.org>`_.
5+
Thereby, it allows users to use most of the components and features found in SOFA directly into their python scripts.
466

7+
This project is composed of two modules: a *SOFA plugin* and several *python modules*.
478

48-
Execution environment
49-
^^^^^^^^^^^^^^^^^^^^^
50-
- SofaPython3 is a plugin to include a python3 environment in a Sofa scene [DONE],
9+
1. The **SofaPython3 plugin** embeds a python interpreter and a SOFA scene loader. This plugin allows one to load a python
10+
script as the main simulation scene file. The scene loader will automatically detect the ".py", ".py3", ".py3scn" or
11+
".pyscn" file extension and load the script into the embedded python interpreter. Whereas traditional XML-based scene
12+
file would discribe the SOFA scene structure, the python scene script will instead programmatically construct the SOFA
13+
scene.
5114

52-
Try it: ```xml <RequiredPlugin='SofaPython3'/>```
15+
2. The **SofaPython3 bindings** makes the link between the SOFA API and python. These are compiled (C++) python
16+
modules compatible with the C-Python ABI and therefore directly accessible from any python interpreter, given
17+
that the python version is compatible. Hence, the python interpreter embedded inside the *SofaPython3 plugin* will be able
18+
to load these binding modules. In addition, one could load the binding modules directly inside their own python
19+
interpreter without requiring the load of the plugin.
5320

54-
55-
- Sofa and SofaRuntime are the python module that can be imported in any python interpreter (python3, ipython, jupyter)[DONE],
56-
57-
Try it: ```python python3 minimalscene.py```
58-
59-
- Access to Sofa simulation within the MathLab python interpreter [WIP-POC].
60-
- Make a full python GUI application (with UI framework like PySide2, pygame) and render an integrated sofa scene in an opengl context [POC]
61-
62-
63-
Global diagram of SofaPython3
64-
-----------------------------
6521
.. figure:: images/SP3_global_arch.png
66-
:alt: How SP3 fits in the SOFA usage pipeline
67-
:align: center
22+
:alt: How SP3 fits in the SOFA usage pipeline
23+
:align: center
6824

6925
Content
7026
-------
7127

72-
7328
.. toctree::
7429
:glob:
7530
:maxdepth: 1
7631

77-
menu/Welcome
78-
menu/install
32+
menu/Compilation
7933
menu/SofaPlugin
8034
menu/SofaModule
8135
menu/pythonLibraries
8236
menu/CustomModule
8337
menu/Contributing
8438

85-
86-
Contributors
87-
------------
88-
89-
- Damien Marchal, Research Engineer CNRS
90-
- Bruno Marques, Research Engineer Inria
91-
- Eve Le Guillou, Enginnering Student
92-
9339

0 commit comments

Comments
 (0)