def purge_sublist(app, env, docname):
    """Clear out cached data when each document (file) is parsed.

    TODO: make this not a linear search?
    """
    if not hasattr(env, 'substitute_all_subs'):
        return
    all_subs = env.substitute_all_subs
    for id_ in list(all_subs.keys()):
        if all_subs[id_]['docname'] == docname:
            del all_subs[id_]
