Skip to content

Commit

Permalink
Sphinx extension remove unused code (#1227)
Browse files Browse the repository at this point in the history
* Sphinx extension remove unused code

* Change channel order

---------

Co-authored-by: AU <adam-urbanczyk@users.noreply.github.com>
  • Loading branch information
sethfischer and adam-urbanczyk authored Jun 16, 2023
1 parent 7143ead commit 665815b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
25 changes: 3 additions & 22 deletions cadquery/cq_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@
import traceback

from json import dumps
from pathlib import Path
from uuid import uuid1 as uuid
from textwrap import indent

from cadquery import exporters, Assembly, Compound, Color, Sketch
from cadquery import cqgi
from cadquery.occ_impl.assembly import toJSON
from cadquery.occ_impl.jupyter_tools import (
TEMPLATE_RENDER,
DEFAULT_COLOR,
)
from cadquery.occ_impl.jupyter_tools import DEFAULT_COLOR
from docutils.parsers.rst import directives, Directive

template = """
Expand All @@ -30,7 +24,6 @@
</div>
"""
template_content_indent = " "

rendering_code = """
const RENDERERS = {};
Expand Down Expand Up @@ -216,10 +209,8 @@ class cq_directive(Directive):

has_content = True
required_arguments = 0
optional_arguments = 2
optional_arguments = 0
option_spec = {
"height": directives.length_or_unitless,
"width": directives.length_or_percentage_or_unitless,
"align": directives.unchanged,
}

Expand Down Expand Up @@ -278,7 +269,7 @@ class cq_directive_vtk(Directive):

has_content = True
required_arguments = 0
optional_arguments = 2
optional_arguments = 0
option_spec = {
"height": directives.length_or_unitless,
"width": directives.length_or_percentage_or_unitless,
Expand All @@ -291,9 +282,6 @@ def run(self):
options = self.options
content = self.content
state_machine = self.state_machine
env = self.state.document.settings.env
build_path = Path(env.app.builder.outdir)
out_path = build_path / "_static"

# only consider inline snippets
plot_code = "\n".join(content)
Expand Down Expand Up @@ -321,21 +309,14 @@ def run(self):
traceback.print_exc()
assy = Assembly(Compound.makeText("CQGI error", 10, 5))

# save vtkjs to static
fname = Path(str(uuid()))
exporters.assembly.exportVTKJS(assy, out_path / fname)
fname = str(fname) + ".zip"

# add the output
lines = []

data = dumps(toJSON(assy))

lines.extend(
template_vtk.format(
code=indent(TEMPLATE_RENDER.format(), " "),
data=data,
ratio="null",
element="document.currentScript.parentNode",
txt_align=options.get("align", "left"),
width=options.get("width", "100%"),
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: cadquery
channels:
- cadquery
- conda-forge
- cadquery
dependencies:
- python>=3.8
- ipython
Expand Down

0 comments on commit 665815b

Please sign in to comment.