in source/ext/extref.py [0:0]
def check_using_notebook_names(conf_path, src_dir):
"""
Calculate count of using for each notebook name from JSON configuration file.
"""
import json
with open(conf_path, 'r') as f:
nb_names = json.load(f).keys()
nb_counts = {nb_name: 0 for nb_name in nb_names}
for root, dirs, files in os.walk(src_dir):
for file in files:
if os.path.splitext(file)[1] != ".rst":
continue
with open(os.path.join(root, file), 'r', errors='ignore') as f:
data = f.read()
for nb_name in nb_names:
nb_counts[nb_name] += data.count(" extref:: {0}".format(nb_name))
for nb_name, count in sorted(nb_counts.items(), key=lambda p: p[1], reverse=True):
print(nb_name, count)