Implement proper clear_doc method for IPDomain

This commit replaces the dummy clear_doc method in
jandd.sphinxext.ip.IPDomain with a proper implementation that clears
document related items from the domain data dictionary.
This commit is contained in:
Jan Dittberner 2016-05-05 11:34:27 +02:00
parent 0dafa28150
commit 01c31e9263
2 changed files with 17 additions and 1 deletions

View file

@ -32,6 +32,7 @@ Changes
----------------------
* fix handling of invalid IP address/range values
* implement a proper clear_doc method for the ip domain
0.2.0 - 2016-05-04
------------------

View file

@ -191,7 +191,22 @@ class IPDomain(Domain):
}
def clear_doc(self, docname):
pass
to_remove = []
for key, value in self.data['v4range'].items():
if docname == value[0]:
to_remove.append(key)
for key in to_remove:
del self.data['v4range'][key]
to_remove = []
for key, value in self.data['v6range'].items():
if docname == value[0]:
to_remove.append(key)
for key in to_remove:
del self.data['v6range'][key]
self.data['ips'] = [
item for item in self.data['ips'] if item['docname'] != docname
]
def resolve_xref(self, env, fromdocname, builder, typ, target, node,
contnode):