1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-08-01 13:10:11 +02:00

Project blurb can now be split with into sections with markdown horizonal rules

made with asterisks.
If an image is include in the first section the default image is supressed.
This commit is contained in:
Chris Palmer
2020-12-28 20:49:37 +00:00
parent 31bfa3b268
commit 8d22940506
3 changed files with 26 additions and 127 deletions

View File

@@ -35,6 +35,7 @@ import json
import blurb
import bom
import shutil
import re
from colorama import Fore
def is_assembly(s):
@@ -217,12 +218,21 @@ def views(target, do_assemblies = None):
if not main_file:
raise Exception("can't find source for main_assembly")
text = blurb.scrape_blurb(source_dir + '/' + main_file)
blurbs = blurb.split_blurb(text)
if len(text):
print(text, file = doc_file, end = '')
print(blurbs[0], file = doc_file)
else:
if print_mode:
print(Fore.MAGENTA + "Missing project description" + Fore.WHITE)
print('![Main Assembly](assemblies/%s.png)\n' % flat_bom[-1]["name"].replace('_assembly', '_assembled'), file = doc_file)
#
# Only add the image if the first blurb section doesn't contain one.
#
got_image = False
for line in blurbs[0].split('\n'):
if re.match(r'.*\!\[.*\]\(.*\).*', line):
got_image = True
if not got_image:
print('![Main Assembly](assemblies/%s.png)\n' % flat_bom[-1]["name"].replace('_assembly', '_assembled'), file = doc_file)
eop(print_mode, doc_file, first = True)
#
# Build TOC
@@ -234,6 +244,8 @@ def views(target, do_assemblies = None):
cap_name = titalise(name)
print('1. [%s](#%s)' % (cap_name, name), file = doc_file)
print(file = doc_file)
if len(blurbs) > 1:
print(blurbs[1], file = doc_file)
eop(print_mode, doc_file)
#
# Global BOM
@@ -283,6 +295,8 @@ def views(target, do_assemblies = None):
print("| %s | %s |" % (pad(grand_total, 2, 1), pad('Total %s count' % headings[t], 2)), file = doc_file)
print(file = doc_file)
if len(blurbs) > 2:
print(blurbs[2], file = doc_file)
eop(print_mode, doc_file)
#
# Assembly instructions