mirror of
https://github.com/DJSundog/NopSCADlib.git
synced 2024-11-23 15:23:51 -05:00
Merge branch 'martinbudden-tests_script'
This commit is contained in:
commit
51c649cc53
17
libtest.scad
17
libtest.scad
@ -17,6 +17,23 @@
|
|||||||
// If not, see <https://www.gnu.org/licenses/>.
|
// If not, see <https://www.gnu.org/licenses/>.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
//!# NopSCADlib
|
||||||
|
//! An ever expanding library of parts modelled in OpenSCAD useful for 3D printers and enclosures for electronics, etc.
|
||||||
|
//!
|
||||||
|
//! It contains lots of vitamins (the RepRap term for non-printed parts), some general purpose printed parts and some utilities.
|
||||||
|
//! There are also Python scripts to generate Bills of Materials (BOMs),
|
||||||
|
//! STL files for all the printed parts, DXF files for CNC routed parts in a project and a manual containing assembly
|
||||||
|
//! instructions and exploded views by scraping markdown embedded in OpenSCAD comments, [see scripts](scripts/readme.md).
|
||||||
|
//!
|
||||||
|
//! A simple example project can be found [here](examples/MainsBreakOutBox/readme.md).
|
||||||
|
//!
|
||||||
|
//! For more examples of what it can make see the [gallery](gallery/readme.md).
|
||||||
|
//!
|
||||||
|
//! The license is GNU General Public License v3.0, see [COPYING](COPYING).
|
||||||
|
//!
|
||||||
|
//! See [usage](docs/usage.md) for requirements, installation instructions and a usage guide.
|
||||||
|
//!
|
||||||
|
//! <img src="libtest.png" width="100%"/>
|
||||||
//
|
//
|
||||||
// This file shows all the parts in the library.
|
// This file shows all the parts in the library.
|
||||||
//
|
//
|
||||||
|
10
readme.md
10
readme.md
@ -1,10 +1,12 @@
|
|||||||
# NopSCADlib
|
# NopSCADlib
|
||||||
An ever expanding library of parts modelled in OpenSCAD useful for 3D printers and enclosures for electronics, etc.
|
An ever expanding library of parts modelled in OpenSCAD useful for 3D printers and enclosures for electronics, etc.
|
||||||
|
|
||||||
It contains lots of vitamins (the RepRap term for non-printed parts), some general purpose printed parts and
|
It contains lots of vitamins (the RepRap term for non-printed parts), some general purpose printed parts and some utilities.
|
||||||
some utilities. There are also Python scripts to generate Bills of Materials (BOMs),
|
There are also Python scripts to generate Bills of Materials (BOMs),
|
||||||
STL files for all the printed parts, DXF files for CNC routed parts in a project and a manual containing assembly
|
STL files for all the printed parts, DXF files for CNC routed parts in a project and a manual containing assembly
|
||||||
instructions and exploded views by scraping markdown embedded in OpenSCAD comments, [see scripts](scripts/readme.md). A simple example project can be found [here](examples/MainsBreakOutBox/readme.md).
|
instructions and exploded views by scraping markdown embedded in OpenSCAD comments, [see scripts](scripts/readme.md).
|
||||||
|
|
||||||
|
A simple example project can be found [here](examples/MainsBreakOutBox/readme.md).
|
||||||
|
|
||||||
For more examples of what it can make see the [gallery](gallery/readme.md).
|
For more examples of what it can make see the [gallery](gallery/readme.md).
|
||||||
|
|
||||||
|
@ -97,7 +97,6 @@ def tests(tests):
|
|||||||
for dir in [deps_dir, png_dir, bom_dir]:
|
for dir in [deps_dir, png_dir, bom_dir]:
|
||||||
if not os.path.isdir(dir):
|
if not os.path.isdir(dir):
|
||||||
os.makedirs(dir)
|
os.makedirs(dir)
|
||||||
doc_name = "readme.md"
|
|
||||||
index = {}
|
index = {}
|
||||||
bodies = {}
|
bodies = {}
|
||||||
done = []
|
done = []
|
||||||
@ -108,19 +107,33 @@ def tests(tests):
|
|||||||
#
|
#
|
||||||
png_name = "libtest.png"
|
png_name = "libtest.png"
|
||||||
scad_name = "libtest.scad"
|
scad_name = "libtest.scad"
|
||||||
if not os.path.isfile(png_name):
|
if os.path.isfile(scad_name):
|
||||||
openscad.run(colour_scheme, "--projection=p", "--imgsize=%d,%d" % (w, h), "--camera=0,0,0,50,0,340,500", "--autocenter", "--viewall", "-o", png_name, scad_name);
|
libtest = True
|
||||||
do_cmd(["magick", png_name, "-trim", "-resize", "1280", "-bordercolor", background, "-border", "10", png_name])
|
lib_blurb = scrape_blurb(scad_name)
|
||||||
|
if not os.path.isfile(png_name):
|
||||||
|
openscad.run(colour_scheme, "--projection=p", "--imgsize=%d,%d" % (w, h), "--camera=0,0,0,50,0,340,500", "--autocenter", "--viewall", "-o", png_name, scad_name);
|
||||||
|
do_cmd(["magick", png_name, "-trim", "-resize", "1280", "-bordercolor", background, "-border", "10", png_name])
|
||||||
|
else:
|
||||||
|
#
|
||||||
|
# Project tests so just a title
|
||||||
|
#
|
||||||
|
libtest = False
|
||||||
|
project = ' '.join(word[0].upper() + word[1:] for word in os.path.basename(os.getcwd()).split('_'))
|
||||||
|
lib_blurb = '#' + project + ' Tests\n'
|
||||||
|
|
||||||
|
doc_base_name = "readme" if libtest else "tests"
|
||||||
|
doc_name = doc_base_name + ".md"
|
||||||
#
|
#
|
||||||
# List of individual part files
|
# List of individual part files
|
||||||
#
|
#
|
||||||
scads = [i for i in sorted(os.listdir(scad_dir), key = lambda s: s.lower()) if i[-5:] == ".scad"]
|
|
||||||
|
|
||||||
|
scads = [i for i in sorted(os.listdir(scad_dir), key = lambda s: s.lower()) if i[-5:] == ".scad"]
|
||||||
|
types = []
|
||||||
for scad in scads:
|
for scad in scads:
|
||||||
base_name = scad[:-5]
|
base_name = scad[:-5]
|
||||||
if not tests or base_name in tests:
|
if not tests or base_name in tests:
|
||||||
done.append(base_name)
|
done.append(base_name)
|
||||||
print(base_name)
|
print('\n'+base_name)
|
||||||
cap_name = base_name[0].capitalize() + base_name[1:]
|
cap_name = base_name[0].capitalize() + base_name[1:]
|
||||||
base_name = base_name.lower()
|
base_name = base_name.lower()
|
||||||
scad_name = scad_dir + '/' + scad
|
scad_name = scad_dir + '/' + scad
|
||||||
@ -132,12 +145,15 @@ def tests(tests):
|
|||||||
if is_plural(base_name) and os.path.isfile(vits_name):
|
if is_plural(base_name) and os.path.isfile(vits_name):
|
||||||
objects_name = vits_name
|
objects_name = vits_name
|
||||||
|
|
||||||
locations = [
|
locations = []
|
||||||
('vitamins/' + depluralise(base_name) + '.scad', 'Vitamins'),
|
if os.path.isdir('vitamins'):
|
||||||
('printed/' + base_name + '.scad', 'Printed'),
|
locations.append(('vitamins/' + depluralise(base_name) + '.scad', 'Vitamins'))
|
||||||
('utils/' + base_name + '.scad', 'Utilities'),
|
if os.path.isdir('printed'):
|
||||||
('utils/core/' + base_name + '.scad', 'Core Utilities'),
|
locations.append(('printed/' + base_name + '.scad', 'Printed'))
|
||||||
]
|
if os.path.isdir('utils'):
|
||||||
|
locations.append(('utils/' + base_name + '.scad', 'Utilities'))
|
||||||
|
if libtest and os.path.isdir('utils/core'):
|
||||||
|
locations.append(('utils/core/' + base_name + '.scad', 'Core Utilities'))
|
||||||
|
|
||||||
for name, type in locations:
|
for name, type in locations:
|
||||||
if os.path.isfile(name):
|
if os.path.isfile(name):
|
||||||
@ -147,14 +163,17 @@ def tests(tests):
|
|||||||
print("Can't find implementation!")
|
print("Can't find implementation!")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
vsplit = "AJR" + chr(ord('Z') + 1)
|
if libtest:
|
||||||
vtype = locations[0][1]
|
vsplit = "AJR" + chr(ord('Z') + 1)
|
||||||
types = [vtype + ' ' + vsplit[i] + '-' + chr(ord(vsplit[i + 1]) - 1) for i in range(len(vsplit) - 1)] + [loc[1] for loc in locations[1 :]]
|
vtype = locations[0][1]
|
||||||
if type == vtype:
|
types = [vtype + ' ' + vsplit[i] + '-' + chr(ord(vsplit[i + 1]) - 1) for i in range(len(vsplit) - 1)] + [loc[1] for loc in locations[1 :]]
|
||||||
for i in range(1, len(vsplit)):
|
if type == vtype:
|
||||||
if cap_name[0] < vsplit[i]:
|
for i in range(1, len(vsplit)):
|
||||||
type = types[i - 1]
|
if cap_name[0] < vsplit[i]:
|
||||||
break
|
type = types[i - 1]
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
types = [loc[1] for loc in locations]
|
||||||
|
|
||||||
for t in types:
|
for t in types:
|
||||||
if not t in bodies:
|
if not t in bodies:
|
||||||
@ -250,24 +269,7 @@ def tests(tests):
|
|||||||
usage()
|
usage()
|
||||||
|
|
||||||
with open(doc_name, "wt") as doc_file:
|
with open(doc_name, "wt") as doc_file:
|
||||||
print('# NopSCADlib', file = doc_file)
|
print(lib_blurb, file = doc_file)
|
||||||
print('''\
|
|
||||||
An ever expanding library of parts modelled in OpenSCAD useful for 3D printers and enclosures for electronics, etc.
|
|
||||||
|
|
||||||
It contains lots of vitamins (the RepRap term for non-printed parts), some general purpose printed parts and
|
|
||||||
some utilities. There are also Python scripts to generate Bills of Materials (BOMs),
|
|
||||||
STL files for all the printed parts, DXF files for CNC routed parts in a project and a manual containing assembly
|
|
||||||
instructions and exploded views by scraping markdown embedded in OpenSCAD comments, [see scripts](scripts/readme.md). A simple example project can be found [here](examples/MainsBreakOutBox/readme.md).
|
|
||||||
|
|
||||||
For more examples of what it can make see the [gallery](gallery/readme.md).
|
|
||||||
|
|
||||||
The license is GNU General Public License v3.0, see [COPYING](COPYING).
|
|
||||||
|
|
||||||
See [usage](docs/usage.md) for requirements, installation instructions and a usage guide.
|
|
||||||
|
|
||||||
<img src="libtest.png" width="100%"/>\n
|
|
||||||
''', file = doc_file)
|
|
||||||
|
|
||||||
print('## Table of Contents<a name="top"/>', file = doc_file)
|
print('## Table of Contents<a name="top"/>', file = doc_file)
|
||||||
print('<table><tr>', file = doc_file)
|
print('<table><tr>', file = doc_file)
|
||||||
n = 0
|
n = 0
|
||||||
@ -288,10 +290,10 @@ See [usage](docs/usage.md) for requirements, installation instructions and a usa
|
|||||||
for type in types:
|
for type in types:
|
||||||
for line in bodies[type]:
|
for line in bodies[type]:
|
||||||
print(line, file = doc_file)
|
print(line, file = doc_file)
|
||||||
with open("readme.html", "wt") as html_file:
|
with open(doc_base_name + ".html", "wt") as html_file:
|
||||||
do_cmd("python -m markdown -x tables readme.md".split(), html_file)
|
do_cmd(("python -m markdown -x tables " + doc_name).split(), html_file)
|
||||||
times.print_times()
|
times.print_times()
|
||||||
do_cmd('codespell -L od readme.md'.split())
|
do_cmd(('codespell -L od ' + doc_name).split())
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
for arg in sys.argv[1:]:
|
for arg in sys.argv[1:]:
|
||||||
|
Loading…
Reference in New Issue
Block a user