mirror of
https://github.com/CopterExpress/clover.git
synced 2026-05-26 11:43:25 +00:00
gitbook: add automated checking for unused assets, remove unused assets
This commit is contained in:
22
check_unused_assets.py
Executable file
22
check_unused_assets.py
Executable 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)
|
||||
Reference in New Issue
Block a user