From 4efb10986336d758c85007ab1f0b2fd8c5f490aa Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Fri, 10 May 2019 04:02:58 -0700 Subject: [PATCH] Tweaked doce generation. --- constants.scad | 6 +++--- edges.scad | 30 +++++++++++++++--------------- scripts/docs_gen.py | 11 +++++++++-- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/constants.scad b/constants.scad index 04c93f1..7ca0418 100644 --- a/constants.scad +++ b/constants.scad @@ -56,19 +56,19 @@ TOP = [ 0, 0, 1]; // Constant: ALLPOS // Description: Vector pointing right, back, and up. [1,1,1] // Example(3D): Usage with `anchor` -// cuboid(20, anchor=ALLPOS); +// cuboid(20, anchor=ALLPOS); ALLPOS = [ 1, 1, 1]; // Vector pointing X+,Y+,Z+. // Constant: ALLNEG // Description: Vector pointing left, forwards, and down. [-1,-1,-1] // Example(3D): Usage with `anchor` -// cuboid(20, anchor=ALLNEG); +// cuboid(20, anchor=ALLNEG); ALLNEG = [-1, -1, -1]; // Vector pointing X-,Y-,Z-. // Constant: CENTER // Description: Zero vector. Centered. [0,0,0] // Example(3D): Usage with `anchor` -// cuboid(20, anchor=CENTER); +// cuboid(20, anchor=CENTER); CENTER = [ 0, 0, 0]; // Centered zero vector. diff --git a/edges.scad b/edges.scad index 9326f3f..ed4983a 100644 --- a/edges.scad +++ b/edges.scad @@ -29,18 +29,18 @@ function is_edge_array(v) = is_list(v) && is_vector(v[0]) && len(v)==3 && len(v[ // Usage: // edge(v); // Description: -// Takes an edge set descriptor and returns the EDGE array representing those edges. +// Takes an edge set descriptor and returns the edges array representing those edges. // This function is useful for modules that take `edges` arguments, like `cuboid()`. // An edge set descriptor can be any of: -// - A raw EDGE array. +// - A raw edges array. // - A vector pointing towards an edge, indicating just that edge. // - A vector pointing towards a face, indicating all edges surrounding that face. // - A vector pointing towards a corner, indicating all edges that meet at that corner. -// - The string "X", indicating all X axis aligned edges. -// - The string "Y", indicating all Y axis aligned edges. -// - The string "Z", indicating all Y axis aligned edges. -// - The string "ALL", indicating all edges. -// - The string "NONE", indicating no edges at all. +// - The string `"X"`, indicating all X axis aligned edges. +// - The string `"Y"`, indicating all Y axis aligned edges. +// - The string `"Z"`, indicating all Y axis aligned edges. +// - The string `"ALL"`, indicating all edges. +// - The string `"NONE"`, indicating no edges at all. function edge_set(v) = is_edge_array(v)? v : [ for (ax=[0:2]) [ @@ -87,21 +87,21 @@ function normalize_edges(v) = [for (ax=v) [for (edge=ax) edge>0? 1 : 0]]; // edges(v) // edges(v, except) // Description: -// Takes a list of edge set descriptors, and returns a normalized EDGE array +// Takes a list of edge set descriptors, and returns a normalized edges array // that represents all those given edges. If the `except` argument is given // a list of edge set descriptors, then all those edges will be removed -// from the returned EDGE array. If either argument only has a single edge +// from the returned edges array. If either argument only has a single edge // set descriptor, you do not have to pass it in a list. // Each edge set descriptor can be any of: -// - A raw EDGE array. +// - A raw edges array. // - A vector pointing towards an edge. // - A vector pointing towards a face, indicating all edges surrounding that face. // - A vector pointing towards a corner, indicating all edges touching that corner. -// - The string "X", indicating all X axis aligned edges. -// - The string "Y", indicating all Y axis aligned edges. -// - The string "Z", indicating all Y axis aligned edges. -// - The string "ALL", indicating all edges. -// - The string "NONE", indicating no edges at all. +// - The string `"X"`, indicating all X axis aligned edges. +// - The string `"Y"`, indicating all Y axis aligned edges. +// - The string `"Z"`, indicating all Y axis aligned edges. +// - The string `"ALL"`, indicating all edges. +// - The string `"NONE"`, indicating no edges at all. // Example: Just the front-top edge // edges(FRONT+TOP) // Example: All edges surrounding either the front or top faces diff --git a/scripts/docs_gen.py b/scripts/docs_gen.py index 540883b..3c178db 100755 --- a/scripts/docs_gen.py +++ b/scripts/docs_gen.py @@ -52,10 +52,17 @@ def mkdn_esc(txt): def get_comment_block(lines, prefix, blanks=1): out = [] blankcnt = 0 + indent = 0 while lines: - if not lines[0].startswith(prefix + " "): + if not lines[0].startswith(prefix+" "): break - line = lines.pop(0)[len(prefix)+1:] + line = lines.pop(0)[len(prefix):] + if not indent: + while line.startswith(" "): + line = line[1:] + indent += 1 + else: + line = line[indent:] if line == "": blankcnt += 1 if blankcnt >= blanks: