mirror of
https://github.com/zulip/zulip.git
synced 2026-06-24 21:08:25 +08:00
This speeds up build_pygments_data from 6 seconds to 0.5 seconds. Signed-off-by: Anders Kaseorg <anders@zulip.com>
24 lines
672 B
Python
Executable File
24 lines
672 B
Python
Executable File
#!/usr/bin/env python3
|
|
import json
|
|
import os
|
|
|
|
from pygments.lexers import get_all_lexers
|
|
|
|
ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../')
|
|
DATA_PATH = os.path.join(ZULIP_PATH, 'tools', 'setup', 'lang.json')
|
|
OUT_PATH = os.path.join(ZULIP_PATH, 'static', 'generated', 'pygments_data.json')
|
|
|
|
with open(DATA_PATH) as f:
|
|
langs = json.load(f)
|
|
|
|
lexers = get_all_lexers()
|
|
for longname, aliases, filename_patterns, mimetypes in lexers:
|
|
for alias in aliases:
|
|
langs[alias] = {
|
|
'priority': langs.get(alias, 0),
|
|
'pretty_name': longname,
|
|
}
|
|
|
|
with open(OUT_PATH, 'w') as f:
|
|
json.dump({"langs": langs}, f)
|