Skip to content

Commit 1f6cdab

Browse files
committed
documentation
1 parent 139ab8e commit 1f6cdab

File tree

16 files changed

+98
-34
lines changed

16 files changed

+98
-34
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# -- General configuration ---------------------------------------------------
1515
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
1616

17-
extensions = []
17+
extensions = ['sphinx.ext.autodoc']
1818

1919
templates_path = ['_templates']
2020
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

docs/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,11 @@ Solid Node documentation
88
why-solid-node
99
quickstart
1010
using-solid-node
11+
api-reference
1112
status-and-roadmap
1213
contributing
14+
15+
Indices and tables
16+
==================
17+
* :ref:`genindex`
18+
* :ref:`search`

docs/status-and-roadmap.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
Project status
66
==============
77

8-
This project has been developed and maintained by a single person so far, and as it is, it's pretty usable. It can already solve real bottlenecks in mechanical project development. It's still a bit far from 1.0 version, but the **current node API should not change** until there.
8+
This project has been developed and maintained by a single person so far, and as it is, it's pretty usable. It can already solve real bottlenecks in mechanical project development. It's still a bit far from 1.0 version, but the **current node API should not change** until there, so you're invited to use it in your next 3D printable Free Software project.
99

1010
Roadmap
1111
=======
1212

13-
* Improve the web viewer with workplanes, rulers, camera angles, animation control, etc
14-
* A "dist" command that packs the project into a distributable with source and builds
15-
* A "publish" command that creates a static website with docstrings, viewer, source and build downloads
13+
* A command to pack the project into a distributable with source and builds
14+
* Improve the web viewer with workplanes, rulers, camera angles, animation control, a test runner
15+
* A command to create a static website with docstrings, the viewer, source and build downloads
16+
* A FlexibleNode class to create objects that change shape over time, with keyframes for animation
17+
* A OpenJScadNode class to support OpenJScad.
1618
* Separate the watcher and builder internal processes to recover from errors

docs/why-solid-node.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Why Solid Node
33

44
When designing a mechanical project with Free Software, there are some technologies available that allow parametric design, using source code to create solid structures. There's OpenScad, which uses it's own scripting language, and on top of it there is Solid Python, which allows modelling for OpenScad using Python language. Python also has CadQuery, which is more powerful and flexible for complex designs, but has a steeper learning curve. When picking which technology to use, one should consider the libraries available, and a complex project might need to assemble pieces that come from different libraries. Openscad has a native animation system that allows developing projects with moving parts, but it soon gets very slow as project grows.
55

6-
Solid Node come as a framework to join all these underlying technologies together. It's inspired by a web development culture, which uses frameworks like Django, React and Angular, that monitors filesystem for changes and shows the result automatically. Solid Node proposes an architecture that allows building of pieces as they change, being able to handle a lot of moving parts.
6+
Solid Node come as a framework to join all these underlying technologies together and solve performance bottlenecks. It's inspired by a web development culture, which uses frameworks like Django, React and Angular, that monitors filesystem for changes and shows results automatically. Solid Node proposes an architecture that allows building of pieces as they change, being able to handle a lot of moving parts.
77

8-
Solid Node also provides testing capabilities. Mechanical projects can generate a lot of garbage from experimentation, and this can be substantially reduced by being able to logically test connections between components before producing anything.
8+
Solid Node also provides testing capabilities. Prototyping can take a lot of time and generate a lot of garbage, and this can be substantially reduced by being able to logically test connections between components before producing anything.
99

1010
Solid Node is Free Software, released under the AGPLv3. This mean that any project using it is bound to the AGPLv3. As digital manufacturing technologies, like 3D printing, become popular, distribution of source code can greatly increase goods lifetime and reduce waste generation. Free Software modeling and source code distribution should become an industry standard, and this project is one more step towards that.

solid_node/core/builder.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(self, path):
2525
self.observer = Observer()
2626

2727
def start(self):
28+
"""Start the rendering process and wait for a file to change, then exits"""
2829
task = self._start()
2930
self.loop = asyncio.get_event_loop()
3031
self.loop.run_until_complete(task)
@@ -69,16 +70,10 @@ async def _start(self):
6970
await self.file_changed
7071
sys.exit(0)
7172

72-
async def execute_refactor(self, request):
73-
try:
74-
request.refactor()
75-
sys.exit(0)
76-
except Exception as e:
77-
error_message = traceback.format_exc()
78-
logger.error(error_message)
79-
await self.report_error(f"Could not execute refactor\n\n{error_message}")
80-
8173
async def generate_stl(self):
74+
"""Trigger the stl generation on the root node, that will recursively render
75+
stls in all nodes. If in the middle a STL is built, the builder process
76+
exits to be restarted."""
8277
try:
8378
self.node.trigger_stl()
8479
return
@@ -97,7 +92,21 @@ async def report_error(self, error_message):
9792
sys.exit(0)
9893

9994
def on_modified(self, event):
95+
"""Called when a file is modified, sets the result of the awaiting future
96+
for the process to exit"""
10097
if event.is_directory:
10198
return
10299
logging.info(f'{event.src_path} changed, reloading')
103100
self.loop.call_soon_threadsafe(self.file_changed.set_result, True)
101+
102+
async def execute_refactor(self, request):
103+
"""Experimental: refactor requests are special exceptions injected in scope
104+
that trigger the builder to refactor nodes. Make sure you commit your changes
105+
before using it."""
106+
try:
107+
request.refactor()
108+
sys.exit(0)
109+
except Exception as e:
110+
error_message = traceback.format_exc()
111+
logger.error(error_message)
112+
await self.report_error(f"Could not execute refactor\n\n{error_message}")

solid_node/node/adapters/cadquery.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class CadQueryNode(LeafNode, metaclass=CheckCQEditor):
2424
namespace = 'cadquery.cq'
2525

2626
def as_scad(self, rendered):
27+
"""Export the model to STL and returns a scad code to render it"""
2728
cq.exporters.export(rendered, self.stl_file, 'STL')
2829
os.utime(self.stl_file, (time.time(), self.mtime))
2930
return import_stl(self.local_stl)

solid_node/node/adapters/openscad.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import os
2-
import re
32
import tempfile
43
import inspect
5-
from subprocess import Popen
64
from solid2 import scad_render, import_scad
75
from solid2.core.parse_scad import get_scad_file_as_dict
86
from solid2.core.utils import resolve_scad_filename
@@ -17,6 +15,16 @@ class OpenScadNode(LeafNode):
1715
namespace = 'solid2.core.object_factory'
1816

1917
def __init__(self, source, *args, name=None, **kwargs):
18+
"""Receives a source code and arguments, imports an OpenScad module from
19+
the source and renders it using *args and **kwargs
20+
The OpenScad code must implement a module with same name as file
21+
22+
Args:
23+
source (str): The .scad source code, in the same folder as the python file
24+
*args: will be passed as arguments to the OpenScad module
25+
name keyword argument: the name of this node, defaul to name of the class
26+
**kwargs: will be passed as keyword arguments to the openscad module
27+
"""
2028
frame = inspect.currentframe().f_back
2129
caller = frame.f_globals.get('__file__')
2230
basedir = os.path.dirname(caller)
@@ -30,9 +38,11 @@ def __init__(self, source, *args, name=None, **kwargs):
3038
super().__init__(*args, name=name, **kwargs)
3139

3240
def get_source_file(self):
41+
"""Gets the openscad source code path"""
3342
return self.openscad_source
3443

3544
def render(self):
45+
"""Imports the OpenScad source code and renders into a solid2 object"""
3646
filename = resolve_scad_filename(self.openscad_source)
3747
scad = get_scad_file_as_dict(filename)
3848
try:
@@ -43,10 +53,12 @@ def render(self):
4353
return rendered
4454

4555
def as_scad(self, rendered):
56+
"""Returns the rendered argument (do nothing)"""
4657
return rendered
4758

4859
@property
4960
def scad_code(self):
61+
"""The contents of the code, plus a module call"""
5062
rendered = scad_render(self.model)
5163
module_call = rendered.strip().split('\n')[-1]
5264
return f'{self.openscad_code}\n\n{module_call}'

solid_node/node/adapters/solid2.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ class Solid2Node(LeafNode):
1818
namespace = 'solid2'
1919

2020
def as_scad(self, rendered):
21+
"""Doesn't do anything, as solid2 objects are already OpenScad objects"""
2122
return rendered
2223

2324
def as_number(self, n):
25+
"""Receives a solid2 function result and calculates its number.
26+
uses an openscad process internally to do the calculation."""
2427
if type(n).__module__.startswith('solid2'):
2528
# This is very clumsy, but it works. Trimesh cannot load
2629
# translated / rotated mesh, and transforming meshes after loading

solid_node/node/assembly.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
class AssemblyNode(InternalNode):
66
"""
77
Represents a collection of components that can be moved relative to each other.
8-
This is an internal node that can contain instances of LeafNode or other internal nodes.
8+
This is an internal node that can contain instances of LeafNode or other
9+
internal nodes.
910
The render method of this class returns a list of its child nodes.
1011
"""
1112

solid_node/node/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class AbstractBaseNode:
4141
children = tuple()
4242

4343
# Set to false to render scad directly instead of stls
44+
# Only works in openscad viewer
4445
optimize = True
4546

4647
def __init__(self, *args, name=None, **kwargs):
@@ -111,6 +112,7 @@ def __init__(self, *args, name=None, **kwargs):
111112
self._make_build_dirs()
112113

113114
def get_source_file(self):
115+
"""Finds the source file of this node"""
114116
return inspect.getfile(self.__class__)
115117

116118
@property

0 commit comments

Comments
 (0)