gdbus-codegen: Allow '@since: UNRELEASED' in documentation comments

Previously, this would not work, as it would result in comparing the
order of a string and an integer. Make it work, and make 'UNRELEASED'
compare higher than other versions so it's always treated as the latest
version.

'UNRELEASED' is commonly used by maintainers to highlight new API while
it's being prototyped, until they know which version it will actually
be released in. At the time of release, they replace all 'UNRELEASED'
strings in git with the new version number.

An example of this usage is here:
d380ac6a2a (9208ee267cb05db1afd3a5c323d71e51db489447_7619_7656)

https://bugzilla.gnome.org/show_bug.cgi?id=769995
This commit is contained in:
Philip Withnall 2016-08-16 17:46:30 +02:00
parent 6d1178b2d9
commit 15b315b472

View File

@ -96,7 +96,13 @@ def lookup_brief_docs(annotations):
return s
def version_cmp_key(key):
# If the 'since' version is empty put a 0 in its place as this will
# If the 'since' version is 'UNRELEASED', compare higher than anything else
# If it is empty put a 0 in its place as this will
# allow LooseVersion to work and will always compare lower.
v = key[0] if key[0] else '0'
if key[0] == 'UNRELEASED':
v = '9999'
elif key[0]:
v = str(key[0])
else:
v = '0'
return (distutils.version.LooseVersion(v), key[1])