Skip to content

Commit

Permalink
Small doc fixes (#1749)
Browse files Browse the repository at this point in the history
* Use export iso save

* Reference correct method

* Add path to docs/conf.py

* Typo fix

* use path.Path

* Path related fixes

* Get rid of pathlib

* Path fixes

* Another path related fix
  • Loading branch information
adam-urbanczyk authored Jan 23, 2025
1 parent d1e4cb6 commit f13f607
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
version: 2

sphinx:
# Path to your Sphinx configuration file.
configuration: doc/conf.py


build:
os: "ubuntu-20.04"
tools:
Expand Down
4 changes: 2 additions & 2 deletions doc/assy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ STEP can be loaded in all CAD tool, e.g. in FreeCAD and the XML be used in other
.. code-block:: python
:linenos:
door.save("door.step")
door.save("door.xml")
door.export("door.step")
door.export("door.xml")
.. image:: _static/door_assy_freecad.png


Expand Down
6 changes: 3 additions & 3 deletions doc/importexport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ preserve the color information from the assembly.
Default
--------

CadQuery assemblies have a :meth:`Assembly.save` method which can write an assembly to a STEP file. An example assembly
CadQuery assemblies have a :meth:`Assembly.export` method which can write an assembly to a STEP file. An example assembly
export with all defaults is shown below.

.. code-block:: python
Expand Down Expand Up @@ -192,7 +192,7 @@ Naming
-------

It is also possible to set the name of the top level assembly object in the STEP file with either the DEFAULT or FUSED methods.
This is done by setting the name property of the assembly before calling :meth:`Assembly.save`.
This is done by setting the name property of the assembly before calling :meth:`Assembly.export`.

.. code-block:: python
Expand All @@ -210,7 +210,7 @@ Exporting Assemblies to glTF

It is possible to export CadQuery assemblies to glTF format. glTF is a mesh-based format useful for viewing models on the web. Whether the resulting glTF file is binary (.glb) or text (.gltf) is set by the file extension.

CadQuery assemblies have a :meth:`Assembly.save` method which can write an assembly to a glTF file. An example assembly
CadQuery assemblies have a :meth:`Assembly.export` method which can write an assembly to a glTF file. An example assembly
export with all defaults is shown below. To export to a binary glTF file, change the extension to ``glb``.

.. code-block:: python
Expand Down
15 changes: 8 additions & 7 deletions tests/test_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from itertools import product
from math import degrees
import copy
from pathlib import Path, PurePath
from path import Path
from pathlib import PurePath
import re
from pytest import approx

Expand Down Expand Up @@ -38,7 +39,7 @@

@pytest.fixture(scope="function")
def tmpdir(tmp_path_factory):
return tmp_path_factory.mktemp("assembly")
return Path(tmp_path_factory.mktemp("assembly"))


@pytest.fixture
Expand Down Expand Up @@ -623,7 +624,7 @@ def test_step_export(nested_assy, tmp_path_factory):
],
)
def test_step_export_loc(assy_fixture, expected, request, tmpdir):
stepfile = Path(tmpdir, assy_fixture).with_suffix(".step")
stepfile = (Path(tmpdir) / assy_fixture).with_suffix(".step")
if not stepfile.exists():
assy = request.getfixturevalue(assy_fixture)
assy.save(str(stepfile))
Expand Down Expand Up @@ -797,7 +798,7 @@ def test_save_gltf_boxes2(boxes2_assy, tmpdir, capfd):
RWGltf_CafWriter skipped node '<name>' without triangulation data
"""

boxes2_assy.save(str(Path(tmpdir, "boxes2_assy.glb")), "GLTF")
boxes2_assy.save(str(Path(tmpdir) / "boxes2_assy.glb"), "GLTF")

output = capfd.readouterr()
assert output.out == ""
Expand Down Expand Up @@ -1037,7 +1038,7 @@ def check_nodes(doc, expected, is_STEP=False):
check_nodes(doc, expected)

# repeat color check again - after STEP export round trip
stepfile = Path(tmpdir, assy_fixture).with_suffix(".step")
stepfile = (Path(tmpdir) / assy_fixture).with_suffix(".step")
if not stepfile.exists():
assy.save(str(stepfile))
doc = read_step(stepfile)
Expand Down Expand Up @@ -1168,7 +1169,7 @@ def check_nodes(doc, expected):
check_nodes(doc, expected)

# repeat color check again - after STEP export round trip
stepfile = Path(tmpdir, f"{assy_fixture}_fused").with_suffix(".step")
stepfile = (Path(tmpdir) / f"{assy_fixture}_fused").with_suffix(".step")
if not stepfile.exists():
assy.save(str(stepfile), mode=cq.exporters.assembly.ExportModes.FUSED)
doc = read_step(stepfile)
Expand Down Expand Up @@ -1699,7 +1700,7 @@ def test_step_export_filesize(tmpdir):
assy.add(
part, name=f"part{j}", loc=cq.Location(x=j * 1), color=copy.copy(color)
)
stepfile = Path(tmpdir, f"assy_step_filesize{i}.step")
stepfile = Path(tmpdir) / f"assy_step_filesize{i}.step"
assy.export(str(stepfile))
filesize[i] = stepfile.stat().st_size

Expand Down
10 changes: 7 additions & 3 deletions tests/test_exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# core modules
import os
import io
from pathlib import Path
from path import Path
import re
import sys
import math
Expand Down Expand Up @@ -833,7 +833,7 @@ def test_assy_vtk_rotation(tmpdir):
v0, name="v0", loc=Location(Vector(0, 0, 0), Vector(1, 0, 0), 90),
)

fwrl = Path(tmpdir, "v0.wrl")
fwrl = Path(tmpdir) / "v0.wrl"
assert not fwrl.exists()
assy.save(str(fwrl), "VRML")
assert fwrl.exists()
Expand Down Expand Up @@ -914,7 +914,11 @@ def test_dxf_text(tmpdir, testdatadir):
.faces("<Y")
.workplane()
.text(
",,", 10, -1, True, fontPath=str(Path(testdatadir, "OpenSans-Regular.ttf")),
",,",
10,
-1,
True,
fontPath=str(Path(testdatadir) / "OpenSans-Regular.ttf"),
)
)

Expand Down

0 comments on commit f13f607

Please sign in to comment.