gitbook: add automated checking for unused assets, remove unused assets

This commit is contained in:
Oleg Kalachev
2019-08-11 18:19:04 +03:00
parent fb3d8c9747
commit a926c0b93d
15 changed files with 26 additions and 565 deletions

22
check_unused_assets.py Executable file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env python3
import os
import sys
import subprocess
EXCLUDE = ('clever4-front-white.png', '.DS_Store', 'travis-instruction-8.png')
code = 0
os.chdir('./docs')
for root, dirs, files in os.walk('assets'):
for f in files:
if f not in EXCLUDE:
path = os.path.join(root, f)
try:
subprocess.check_output(['grep', '-F', '-r', path, './ru', './en'])
except subprocess.CalledProcessError:
print('\x1b[1;31mAssets file {} is not used\x1b[0m'.format(path))
code = 1
sys.exit(code)