'Remove all traces of a source file in the inventory.'

def clear_doc(self, docname):

    if (docname in self.all_docs):
        self.all_docs.pop(docname, None)
        self.metadata.pop(docname, None)
        self.dependencies.pop(docname, None)
        self.titles.pop(docname, None)
        self.longtitles.pop(docname, None)
        self.tocs.pop(docname, None)
        self.toc_secnumbers.pop(docname, None)
        self.toc_num_entries.pop(docname, None)
        self.toctree_includes.pop(docname, None)
        self.filemodules.pop(docname, None)
        self.indexentries.pop(docname, None)
        self.glob_toctrees.discard(docname)
        self.numbered_toctrees.discard(docname)
        self.images.purge_doc(docname)
        self.dlfiles.purge_doc(docname)
        for (subfn, fnset) in self.files_to_rebuild.items():
            fnset.discard(docname)
            if (not fnset):
                del self.files_to_rebuild[subfn]
        for (fullname, (fn, _)) in self.descrefs.items():
            if (fn == docname):
                del self.descrefs[fullname]
        for (modname, (fn, _, _, _)) in self.modules.items():
            if (fn == docname):
                del self.modules[modname]
        for (labelname, (fn, _, _)) in self.labels.items():
            if (fn == docname):
                del self.labels[labelname]
        for (key, (fn, _)) in self.reftargets.items():
            if (fn == docname):
                del self.reftargets[key]
        for (key, (fn, _)) in self.progoptions.items():
            if (fn == docname):
                del self.progoptions[key]
        for (version, changes) in self.versionchanges.items():
            new = [change for change in changes if (change[1] != docname)]
            changes[:] = new
