From fdcee70dc8e41cf9b7f47231eed46978fcd7569e Mon Sep 17 00:00:00 2001 From: Flavio Calva Date: Tue, 14 Dec 2021 19:57:04 +0100 Subject: [PATCH] docs --- lib/build/docs.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/build/docs.py b/lib/build/docs.py index 83f4351..9b5aeeb 100644 --- a/lib/build/docs.py +++ b/lib/build/docs.py @@ -4,6 +4,7 @@ from os.path import exists from shutil import rmtree, make_archive from lib.build.build import InsideDir from pathlib import Path +from re import match, findall, sub from glob import glob @@ -16,6 +17,24 @@ def bld_docs(): rmtree('docs', ignore_errors=True) Path('docs').mkdir(exist_ok=True) [rename(fname, 'docs/' + fname) for fname in glob('*.html')] + for fname in glob('docs/*.html'): + out_lines = [] + with open(fname) as fhtml: + lines = fhtml.readlines() + for line in lines: + occurs = findall('"#[0-9A-Fa-f]{6}"', line) + new_line = line + for occur in occurs: + red = int(occur[2:4], 16) / 255 + green = int(occur[4:6], 16) / 255 + blue = int(occur[6:8], 16) / 255 + new_col = .2989 * red + .5870 * green + .1140 * blue + new_col = hex(int(round(new_col * 255)))[2:] + new_col = '"#%s%s%s"' % (new_col, new_col, new_col) + new_line = sub('"#[0-9A-Fa-f]{6}"', new_col, new_line) + out_lines += [new_line] + with open(fname, 'w') as fhtml: + fhtml.write(''.join(out_lines)) Path('build').mkdir(exist_ok=True) rmtree('build/docs', ignore_errors=True) rename('docs', 'build/docs') -- 2.30.2