From 20a21a5d9a162d39a8fe62da8168c88d9434bab0 Mon Sep 17 00:00:00 2001 From: Garth Minette Date: Tue, 5 Jan 2021 01:48:29 -0800 Subject: [PATCH] Corrected image generation doubled-commoncode bug. --- scripts/docs_gen.py | 31 ++++++++++++++++++++++--------- version.scad | 2 +- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/scripts/docs_gen.py b/scripts/docs_gen.py index 9476f7b..640be43 100755 --- a/scripts/docs_gen.py +++ b/scripts/docs_gen.py @@ -120,7 +120,6 @@ def run_openscad_script(libfile, infile, imgfile, imgsize=(320,240), eye=None, s class ImageProcessing(object): def __init__(self): self.examples = [] - self.commoncode = [] self.imgroot = "" self.keep_scripts = False self.force = False @@ -132,9 +131,6 @@ class ImageProcessing(object): def add_image(self, libfile, imgfile, code, extype): self.examples.append((libfile, imgfile, code, extype)) - def set_commoncode(self, code): - self.commoncode = code - def process_examples(self, imgroot, force=False, test_only=False): self.imgroot = imgroot self.force = force @@ -172,8 +168,6 @@ class ImageProcessing(object): return script = "" - for line in self.commoncode: - script += line+"\n" for line in code: script += line+"\n" @@ -547,7 +541,17 @@ class LeafNode(object): ("fig%d" % fignum), "gif" if "Spin" in extype else "png" ) - imgprc.add_image(fileroot+".scad", imgfile, excode, extype) + icode = [] + for line in libnode.includes: + icode.append(line) + for line in libnode.commoncode: + icode.append(line) + for line in excode: + if line.strip().startswith("--"): + icode.append(line.strip()[2:]) + else: + icode.append(line) + imgprc.add_image(fileroot+".scad", imgfile, icode, extype) out.append(extitle) out.append("") out.append( @@ -768,7 +772,17 @@ class Section(object): ) ) out.append("") - imgprc.add_image(fileroot+".scad", imgfile, figcode, figtype) + icode = [] + for line in libnode.includes: + icode.append(line) + for line in libnode.commoncode: + icode.append(line) + for line in figcode: + if line.strip().startswith("--"): + icode.append(line.strip()[2:]) + else: + icode.append(line) + imgprc.add_image(fileroot+".scad", imgfile, icode, figtype) in_block = False for node in self.leaf_nodes: out += node.gen_md(fileroot, imgroot, libnode, self) @@ -849,7 +863,6 @@ class LibFile(object): return lines def gen_md(self, fileroot, imgroot): - imgprc.set_commoncode(self.includes + self.commoncode) out = [] if self.name: out.append("# Library File " + mkdn_esc(self.name)) diff --git a/version.scad b/version.scad index c50e9ce..21e74c9 100644 --- a/version.scad +++ b/version.scad @@ -6,7 +6,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,506]; +BOSL_VERSION = [2,0,507]; // Section: BOSL Library Version Functions