Merge branch 'release/0.2.1'

* release/0.2.1:
  Set release date in change log
  Implement proper clear_doc method for IPDomain
  Make sure that values are IP addresses/ranges
  Add test data that breaks IP address parsing
  Bump version
This commit is contained in:
Jan Dittberner 2016-05-05 11:38:56 +02:00
commit 639571f8ea
5 changed files with 39 additions and 3 deletions

1
.gitignore vendored
View file

@ -8,3 +8,4 @@ dist/
.coverage
htmlcov/
build/
_build/

View file

@ -28,6 +28,12 @@ Contributors
Changes
=======
0.2.1 - 2016-05-05
------------------
* 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

@ -23,7 +23,7 @@ from sphinx.locale import l_
from sphinx.roles import XRefRole
from sphinx.util.nodes import make_refnode
__version__ = '0.2.0'
__version__ = '0.2.1'
def ip_object_anchor(typ, path):
@ -52,6 +52,17 @@ class IPXRefRole(XRefRole):
super(IPXRefRole, self).__init__(
innernodeclass=innernodeclass, **kwargs)
def __call__(self, typ, rawtext, text, lineno, inliner,
options={}, content=[]):
try:
Network(text)
except ValueError as e:
env = inliner.document.settings.env
env.warn(env.docname, "invalid ip address/range %s" % text, lineno)
return [nodes.literal(text, text), []]
return super(IPXRefRole, self).__call__(
typ, rawtext, text, lineno, inliner, options, content)
def process_link(self, env, refnode, has_explicit_title, title, target):
domaindata = env.domaindata['ip']
domaindata[self.method][target] = (target, refnode)
@ -180,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):

View file

@ -2,7 +2,7 @@
from setuptools import setup, find_packages
version = '0.2.0'
version = '0.2.1'
with open('README.rst') as readme:
description = readme.read() + "\n\n"

View file

@ -6,3 +6,6 @@ This page contains IP addresses :ip:v4:`127.0.0.1`, :ip:v4:`192.168.0.1` and
There is also :ip:v6range:`2001:dada:b001::/64` and
:ip:v4range:`172.16.0.0/24`.
The extension should also handle malformed things like :ip:v4:`<IP>`,
:ip:v6:`<IP6>`, :ip:v4range:`<IPR>` and :ip:v6range:`<IPR6>` properly.