Skip to content

Commit 4fb98d4

Browse files
jnbrunethugtalbot
andauthored
Improve documentation and fix compilation issues (#139)
* Udpdate doc * Update requirements for readthedocs Co-authored-by: Hugo Talbot <[email protected]>
1 parent ce76e20 commit 4fb98d4

File tree

33 files changed

+6501
-224
lines changed

33 files changed

+6501
-224
lines changed

.readthedocs.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# .readthedocs.yml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Build documentation in the docs/ directory with Sphinx
9+
sphinx:
10+
configuration: docs/sphinx/source/conf.py
11+
12+
# Build documentation with MkDocs
13+
#mkdocs:
14+
# configuration: mkdocs.yml
15+
16+
# Optionally build your docs in additional formats such as PDF
17+
formats:
18+
- pdf
19+
20+
# Optionally set the version of Python and requirements required to build your docs
21+
python:
22+
version: 3.7
23+
install:
24+
- requirements: docs/sphinx/source/requirements.txt

bindings/Sofa/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project(Bindings.Sofa)
22

3-
set(SOFABINDINGS_MODULE_LIST Core Components Helper Simulation Types)
3+
set(SOFABINDINGS_MODULE_LIST Core Helper Simulation Types)
44

55
foreach(sofabindings_module ${SOFABINDINGS_MODULE_LIST})
66
add_subdirectory(src/SofaPython3/Sofa/${sofabindings_module})

bindings/Sofa/package/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,17 @@
3434
import traceback
3535
import importlib
3636

37+
import Sofa.constants
3738
import Sofa.Helper
3839
import Sofa.Core
3940
import Sofa.Simulation
4041
import Sofa.Types
41-
import Sofa.Components
42+
# import Sofa.Components
4243
import SofaTypes
4344

4445
from .prefab import *
4546

46-
__all__=["animation", "prefab"]
47+
__all__=["constants", "Helper", "Core", "Simulation", "Types", "SofaTypes", "prefab"]
4748

4849
# Keep a list of the modules always imported in the Sofa-PythonEnvironment
4950
try:

bindings/SofaRuntime/src/SofaPython3/SofaRuntime/Timer/Submodule_Timer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ py::module addSubmoduleTimer(py::module &m)
180180
timer.def("stepEnd", [](const std::string& id){ AdvancedTimer::stepEnd(id);}, py::arg("id"));
181181
timer.def("end", [](const std::string& id){ AdvancedTimer::end(id);}, py::arg("id"));
182182

183-
timer.def("setOutputType", &AdvancedTimer::setOutputType, py::arg("id"), py::arg("newOutputType"), doc::Timer::setOutputType);
183+
timer.def("setOutputType", [](const std::string& id, const std::string& type){ AdvancedTimer::setOutputType(id, type);}, py::arg("id"), py::arg("newOutputType"), doc::Timer::setOutputType);
184184
timer.def("getRecords", &getRecords, py::arg("id"));
185185

186186
return timer;

bindings/SofaRuntime/src/SofaPython3/SofaRuntime/Timer/Submodule_Timer_doc.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ Sets the interval for the given timer.
4949

5050
static auto setOutputType =
5151
R"(
52-
Changes the output type for a given timer.
52+
Set the outputType for the given AdvancedTimer.
53+
54+
@param id string id of the timer
55+
@param type string output type name (example : "json")
5356
)";
5457
}

docs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +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/Compilation.rst
56
${CMAKE_CURRENT_SOURCE_DIR}/sphinx/source/menu/Contributing.rst
67
${CMAKE_CURRENT_SOURCE_DIR}/sphinx/source/menu/SofaPlugin.rst
78
${CMAKE_CURRENT_SOURCE_DIR}/sphinx/source/menu/SofaModule.rst

docs/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Generating the sphinx documentation
2+
3+
The sphinx documentation is automatically built by readthedocs.io when a commit is
4+
added to the master branch. This readme describes the steps to locally build the
5+
documentation on your PC. It is written for Ubuntu 20.04, but the steps are very
6+
similar with other Linux distributions.
7+
8+
### 1. Installing the requirements
9+
The following dependencies are required:
10+
11+
```shell
12+
sudo apt install build-essential python3 python3-pip python3-sphinx
13+
pip3 install --user sphinx_rtd_theme
14+
```
15+
16+
Go inside the `SofaPython3/docs/sphinx` directory and run
17+
18+
```shell
19+
pip3 install --user -r source/requirements.txt
20+
```
21+
22+
### 2. Generating the stubs
23+
Install the pybind11-stubgen:
24+
```shell
25+
python -m pip install git+https://github.com/sizmailov/pybind11-stubgen.git
26+
```
27+
28+
Make sure python can find SofaPython3 modules, i.e.:
29+
```shell
30+
export SOFA_ROOT=/opt/sofa_v20.12/build/install
31+
export PYTHONPATH="$SOFA_ROOT/plugins/SofaPython3/lib/python3/site-packages"
32+
```
33+
34+
The following line can be used to make sure Sofa bindings can be found by python:
35+
```shell
36+
python -c "import importlib;print('OK') if importlib.util.find_spec('Sofa') else print('NOT OK');"
37+
```
38+
39+
Go inside the `SofaPython3/docs` directory and run
40+
```shell
41+
pybind11-stubgen -o sphinx-stubs --no-setup-py --ignore-invalid=signature --root-module-suffix="" SofaRuntime
42+
pybind11-stubgen -o sphinx-stubs --no-setup-py --ignore-invalid=signature --root-module-suffix="" Sofa
43+
pybind11-stubgen -o sphinx-stubs --no-setup-py --ignore-invalid=signature --root-module-suffix="" SofaExporter
44+
pybind11-stubgen -o sphinx-stubs --no-setup-py --ignore-invalid=signature --root-module-suffix="" SofaTypes
45+
pybind11-stubgen -o sphinx-stubs --no-setup-py --ignore-invalid=signature --root-module-suffix="" splib
46+
```

0 commit comments

Comments
 (0)