def purge_needs(app, env, docname):
    """
    Gets executed, if a doc file needs to be purged/ read in again.
    So this code delete all found needs for the given docname.
    """
    if not hasattr(env, 'needs_all_needs'):
        return
    env.needs_all_needs = {key: need for key, need in env.needs_all_needs.items() if need['docname'] != docname}
Gets executed, if a doc file needs to be purged/ read in again.
    So this code delete all found needs for the given docname.