Skip to content
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

Updated version of documentation #449

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
905e5dc
Remove the automock of Sofa
damienmarchal May 24, 2023
225a4c6
WIPPP
damienmarchal Jun 5, 2023
582ec1a
WIP
damienmarchal Jun 7, 2023
d21a12f
WIP2
damienmarchal Jun 7, 2023
bd12e8e
Remove sphinx-stubs as don't need them anymore.
damienmarchal Jun 7, 2023
0350f34
FIX Documentation
damienmarchal Jun 7, 2023
53aa155
W
damienmarchal Jun 7, 2023
3271198
WIP
damienmarchal Jun 7, 2023
5ff0262
WIP
damienmarchal Jun 7, 2023
2f25ac7
W
damienmarchal Jun 7, 2023
8b0a564
WIP
damienmarchal Jun 7, 2023
3f78144
W
damienmarchal Jun 7, 2023
5b38e02
W
damienmarchal Jun 7, 2023
0605073
W
damienmarchal Jun 7, 2023
34771db
W
damienmarchal Jun 8, 2023
43a29ae
W
damienmarchal Jun 8, 2023
8b6eb9d
W
damienmarchal Jun 8, 2023
2660fe1
D
damienmarchal Jun 8, 2023
75dae83
review and clean of documentation
hugtalbot Aug 29, 2023
ba0fbbc
Update requirements for automatization
hugtalbot Aug 29, 2023
194733c
Add action to generate doc on new release
hugtalbot Aug 29, 2023
0d58bdd
Up
damienmarchal Aug 30, 2023
d69e16f
Clean code, format and add full documentation
hugtalbot Aug 31, 2023
ebd0624
Merge branch 'master' into xp-readthedocs
hugtalbot Aug 31, 2023
36af3c5
Add as a trigger of action the edit of a release
hugtalbot Aug 31, 2023
0e28dc3
Merge branch 'master' into xp-readthedocs
hugtalbot Aug 31, 2023
a9ac53b
FIX
damienmarchal Aug 31, 2023
ca2ce2e
Merge remote-tracking branch 'origin/xp-readthedocs' into xp-readthedocs
damienmarchal Aug 31, 2023
da8fb59
Various documentation fixes.
damienmarchal Aug 31, 2023
4319f5c
Refactor the documentation organization & sections & subsection so th…
damienmarchal Sep 1, 2023
cc41156
Last improvements before upload
hugtalbot Sep 5, 2023
114ead7
Merge remote-tracking branch 'origin/master' into xp-readthedocs
damienmarchal Sep 13, 2024
acb13ef
We shouldent import scipy for our users. They are competent enough
damienmarchal Sep 13, 2024
8d82fba
FIX
damienmarchal Sep 13, 2024
fec35a5
Merge branch 'master' into xp-readthedocs
damienmarchal Oct 17, 2024
cd3a3b7
Fix broken tests.
damienmarchal Oct 17, 2024
d5c41ff
Remove an introduced change in SofaRuntime.
damienmarchal Oct 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build, zip and upload documentation for release

on:
release:
types:
- created
- edited
workflow_dispatch: # This allows manual triggering

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8 # Replace with your desired Python version

- name: Install dependencies
run: |
cd docs/sphinx/
pip install -r source/requirements.txt # Replace with your project's requirements file

- name: Build Sphinx documentation
run: |
mkdir build/
sphinx-build -b html -a -E source/ build/ # Replace with your documentation source and build directories

- name: Zip Documentation
run: |
# Create a zip file of the documentation
cd build/
zip -r SofaPython3_${{ steps.branch_name.outputs.branch_name }}_docs.zip .

- name: Upload to GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
SofaPython3_${{ steps.branch_name.outputs.branch_name }}_docs.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
__pycache__/
*.pyc
*.so
docs/stubs
docs/sphinx/build/
docs/sphinx/source/*/_autosummary*
docs/sphinx/build/*
docs/sphinx/source/*/generated
docs/sphinx/source/*/*/generated
docs/sphinx/source/*/*/*/generated
20 changes: 7 additions & 13 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,10 @@ version: 2
sphinx:
configuration: docs/sphinx/source/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF
formats:
- pdf

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/sphinx/source/requirements.txt
build:
os: "ubuntu-22.04"
commands:
- mkdir --parents $READTHEDOCS_OUTPUT/html/
- wget https://github.com/sofa-framework/SofaPython3/releases/download/release-v23.06/SofaPython3_v23.06_docs.zip
- unzip SofaPython3_v23.06_docs.zip
- cp --recursive build/html/* $READTHEDOCS_OUTPUT/html/
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.12)

project(SofaPython3 VERSION 20.12.00)
project(SofaPython3 VERSION 24.12.00)
damienmarchal marked this conversation as resolved.
Show resolved Hide resolved

find_package(Sofa.Config REQUIRED)

Expand Down
1 change: 0 additions & 1 deletion Plugin/src/SofaPython3/Prefab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ void Prefab::reinit()

doReInit();

/// Beurk beurk beurk
sofa::simulation::node::init(this);
execute<VisualInitVisitor>(sofa::core::visual::visualparams::defaultInstance());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ namespace sofapython3

PYBIND11_MODULE(SofaBaseTopology, m)
{
m.doc() = "Implements some topology component (Regular and SparseGridTopology)";

sofa::component::topology::container::grid::init();

moduleAddRegularGridTopology(m);
moduleAddSparseGridTopology(m);
}

} // namespace sofapython3
} // namespace sofapython3
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace sofapython3

PYBIND11_MODULE(SofaConstraintSolver, m)
{
m.doc() = "Implements the solver for constraint problems";

moduleAddConstraintSolver(m);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ namespace sofapython3::doc::SofaDeformable {

static auto LinearSpringClass =
R"(
A LinearSpring between two objects, specified by indices on a topology.
A linear spring connecting pair of nodes of two different objects
)";

static auto LinearSpringInit =
R"(
Create a linear spring from indices and spring parameters.

:param index1: Index of the point on object 1.
:param index2: Index of the point on object 2.
:param springStiffness: Stiffnes k of the spring (f = -k*x -d*v)
Expand All @@ -39,6 +40,7 @@ Create a linear spring from indices and spring parameters.
:param enabled: If set to false, no force will be calculated for this spring

:return: A linear spring of type Sofa.SofaDeformable.LinearSpring

)";

} // sofapython3::doc::SofaDeformable
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ void bindSpringForcefield(py::module& m) {

// create a python binding for the c++ class SpringForceField from SofaDeformable
// no init binding, because creation should be done via node.addObject("SpringForceField")
std::string type_name = sofa::helper::NameDecoder::getTypeName<SpringForceField>();
std::string type_name = SpringForceField::GetClass()->className+"_"+
DataType::Name();

py::class_<SpringForceField,
sofa::core::objectmodel::BaseObject,
py_shared_ptr<SpringForceField>> s (m, type_name.c_str(), sofapython3::doc::SofaDeformable::SpringForceFieldClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ namespace sofapython3

PYBIND11_MODULE(SofaDeformable, m)
{
m.doc() = "Implements linear springs between objects";

moduleAddLinearSpring(m);
moduleAddSpringForceField(m);
}
Expand Down
2 changes: 2 additions & 0 deletions bindings/Modules/src/SofaPython3/SofaGL/Module_SofaGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace sofapython3

PYBIND11_MODULE(SofaGL, m)
{
m.doc() = "Exposes the rendering API using OpenGL";

moduleAddDrawToolGL(m);
}

Expand Down
6 changes: 3 additions & 3 deletions bindings/Sofa/package/PyTypes/Vec3.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Vec3(numpy.ndarray):
def __new__(cls, *args):
""" Vec3 constructor expects zero, one or three arguments.

Examples:
Example:

>>> v = Vec3()
>>> print(v)
Expand Down Expand Up @@ -125,7 +125,7 @@ def normalize(self, *args):
def translate(self, *args):
""" Function translate of class Vec3 expects one or three arguments. Note that you can also use the '+' and '-' operators.

Examples:
Example:

>>> v = Vec3([0.,0.,0.])
>>> v.translate(1.)
Expand Down Expand Up @@ -209,7 +209,7 @@ def rotateFromAxisAngle(self, axis, angle):
def scale(self, *args):
""" Function scale of class Vec3 expects one or three arguments. Note that you can also use the '*' and '/' operators.

Examples:
Example:

>>> v = Vec3([1.,2.,3.])
>>> v.scale(2.)
Expand Down
7 changes: 2 additions & 5 deletions bindings/Sofa/package/PyTypes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
"""
Data types
-----------------------
----------

.. autosummary::
Sofa.Types.RGBAColor
Sofa.Types.Vec3
"""

from .Vec3 import *
from .RGBAColor import *
from .RGBAColor import *
41 changes: 22 additions & 19 deletions bindings/Sofa/package/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""
Package containing the binding for the core of Sofa
-------------------------------------------------
All SOFA key components supported by the SOFA consortium

Example of use:
Example:
.. code-block:: python

import Sofa.Core
Expand All @@ -17,14 +16,6 @@
Sofa.Simulation.init(n)
Sofa.Simulation.print(n)

Submodules:
.. autosummary::
:toctree: _autosummary

Sofa.Core
Sofa.Simulation
Sofa.Types
Sofa.Helper
"""

import sys
Expand Down Expand Up @@ -255,14 +246,18 @@ def getSofaFormattedStringFromException(e):

def sofaExceptHandler(type, value, tb):
global oldexcepthook
"""This exception handler, convert python exceptions & traceback into more classical sofa error messages of the form:
Message Description
Python Stack (most recent are at the end)
File file1.py line 4 ...
File file1.py line 10 ...
File file1.py line 40 ...
File file1.py line 23 ...
faulty line
"""This exception handler converts python exceptions & traceback into classical SOFA error messages

Message:

.. code-block:: text

Python Stack (most recent are at the end)
File file1.py line 4 ...
File file1.py line 10 ...
File file1.py line 40 ...
File file1.py line 23 ...

"""
h = type.__name__

Expand Down Expand Up @@ -294,18 +289,26 @@ def pyType2sofaType(v):


def msg_error(target, message):
"""API emitting error messages
"""
frameinfo = inspect.getframeinfo(inspect.currentframe().f_back)
Sofa.Helper.msg_error(target, message, frameinfo.filename, frameinfo.lineno)

def msg_info(target, message):
"""API emitting information messages
"""
frameinfo = inspect.getframeinfo(inspect.currentframe().f_back)
Sofa.Helper.msg_info(target, message, frameinfo.filename, frameinfo.lineno)

def msg_warning(target, message):
"""API emitting warning messages
"""
frameinfo = inspect.getframeinfo(inspect.currentframe().f_back)
Sofa.Helper.msg_warning(target, message, frameinfo.filename, frameinfo.lineno)

def msg_deprecated(target, message):
"""API emitting deprecation messages
"""
frameinfo = inspect.getframeinfo(inspect.currentframe().f_back)
Sofa.Helper.msg_deprecated(target, message, frameinfo.filename, frameinfo.lineno)

Expand Down
65 changes: 34 additions & 31 deletions bindings/Sofa/package/prefab.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,56 @@
"""
Prefabs are python templates for a SOFA scene
"""

import Sofa.Core
import inspect
import os


class Prefab(Sofa.Core.RawPrefab):
"""
Special Node to make reusable procedural objects in Sofa.
---------------------------------------------------------

Inherit from this class to create your own Prefab. What makes Prefab special is that they
have a set of special data named prefabParameters. When any of prefabParameter is changed the prefab
is completely recreated by calling the onParameterChanged method so the scene graph is always kept synchronized
with the parameter's content.
def __init__(self, *args, **kwargs):
"""
Prefabs are python templates for a SOFA scene

To specify the prefabParameters, it is possible to provide in the class a list of dictionaries containing the 3 required fields ("name", "type", "help")
and one optional field ("default").
They allow to simplify the design of a simulation by using pre-structured and reusable python script.
Inherit from this class to create your own Prefab. What makes Prefab special is that they
have a set of special data named prefabParameters. When any of prefabParameter is changed the prefab
is completely recreated by calling the onParameterChanged method so the scene graph is always kept synchronized
with the parameter's content.

The same syntax can be used to also add prefab's data.
To specify the prefabParameters, it is possible to provide in the class a list of dictionaries containing the 3 required fields ("name", "type", "help")
and one optional field ("default").

Example of use:
.. code-block:: python
The same syntax can be used to also add prefab's data.

import Sofa.Core
Example:
.. code-block:: python

class Foo(Sofa.Core.Prefab):
prefabParameters = [{ 'name': 'n', 'type': 'int', 'help': 'number of repetition, 'default': 1},
{'name': 'message', 'type': 'string', 'help': 'message to display', 'default': ''}]
import Sofa.Core

myAttribute = 0
class Foo(Sofa.Core.Prefab):
prefabParameters = [{ 'name': 'n', 'type': 'int', 'help': 'number of repetition, 'default': 1},
{'name': 'message', 'type': 'string', 'help': 'message to display', 'default': ''}]

def __init__(self, *a, *k):
Sofa.Core.Prefab.__init__(self, *a, **k)
myAttribute = 0

def init(self):
myAttribute += 1
for i in range(0, self.n.value):
print(self.message.value)
def __init__(self, *a, *k):
Sofa.Core.Prefab.__init__(self, *a, **k)

n = Sofa.Core.Node()
n.addChild(Foo(name="aFooPrefab", n=42, message="hello universe!"))
def init(self):
myAttribute += 1
for i in range(0, self.n.value):
print(self.message.value)

Prefab has protected the following additional keywords:
- "name": the name of the prefab instance
- "parent" and "parents": can't be used together, they set the context of the prefab,
thus allowing paths resolution for Prefab parameters whose arguments are passed as link paths (strings). parents (with an '-s') sets multi-node contexts
n = Sofa.Core.Node()
n.addChild(Foo(name="aFooPrefab", n=42, message="hello universe!"))

Prefab has protected the following additional keywords:
- "name" = the name of the prefab instance
- "parent" and "parents" = can't be used together, they set the context of the prefab, thus allowing paths resolution for Prefab parameters whose arguments are passed as link paths (strings). parents (with an '-s') sets multi-node contexts
"""

"""
def __init__(self, *args, **kwargs):
Sofa.Core.RawPrefab.__init__(self, *args, **kwargs)
frame = inspect.currentframe().f_back
frameinfo = inspect.getframeinfo(frame)
Expand Down
Loading
Loading