seitime-frappe/frappe/website/purifycss.py
Rushabh Mehta c519122929 [docs] Build docs in an app (#3796)
* [docs] to be rendered in website

* [docs] generating-docs.md

* [fix] codacy

* [docs] minor updates

* [fix] routing
2017-07-28 11:43:16 +05:30

32 lines
894 B
Python

import frappe, re, os
def purifycss():
source = frappe.get_app_path('frappe_theme', 'public', 'less', 'frappe_theme.less')
target_apps = ['erpnext_com', 'frappe_io', 'translator', 'chart_of_accounts_builder', 'frappe_theme']
with open(source, 'r') as f:
src = f.read()
classes = []
for line in src.splitlines():
line = line.strip()
if not line:
continue
if line[0]=='@':
continue
classes.extend(re.findall('\.([^0-9][^ :&.{,(]*)', line))
classes = list(set(classes))
for app in target_apps:
for basepath, folders, files in os.walk(frappe.get_app_path(app)):
for fname in files:
if fname.endswith('.html') or fname.endswith('.md'):
#print 'checking {0}...'.format(fname)
with open(os.path.join(basepath, fname), 'r') as f:
src = f.read()
for c in classes:
if c in src:
classes.remove(c)
for c in sorted(classes):
print c