summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan van der Walt <stefanv@berkeley.edu>2018-03-21 17:26:56 -0700
committerStefan van der Walt <stefanv@berkeley.edu>2018-03-21 17:26:56 -0700
commitd6730eeed940706ce1c103b1d021c282513be0ed (patch)
treecd0f05b7b393736aa52c7c984cabfbc95df78cb8
parentad014b9e8774e2aa9713a80ed0756ab0bcbb8ae8 (diff)
downloadnumpy-d6730eeed940706ce1c103b1d021c282513be0ed.tar.gz
Add consistency check for superseded NEPs
A superseded NEP should have a Replaced-By header. The replacing NEP should have a Replaces header. They should point to one another.
-rw-r--r--doc/neps/tools/build_index.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/doc/neps/tools/build_index.py b/doc/neps/tools/build_index.py
index bb11cba8a..134773065 100644
--- a/doc/neps/tools/build_index.py
+++ b/doc/neps/tools/build_index.py
@@ -21,7 +21,7 @@ def nep_metadata():
sources = sorted(glob.glob(r'nep-*.rst'))
sources = [s for s in sources if not s in ignore]
- meta_re = r':([a-zA-Z]*): (.*)'
+ meta_re = r':([a-zA-Z\-]*): (.*)'
neps = {}
print('Loading metadata for:')
@@ -40,8 +40,44 @@ def nep_metadata():
tags['Title'] = lines[1].strip()
tags['Filename'] = source
+
+ if tags['Status'] in ('Accepted', 'Rejected', 'Withdrawn'):
+ if not 'Resolution' in tags:
+ raise RuntimeError(
+ f'NEP {nr} is Accepted/Rejected/Withdrawn but '
+ 'has no Resolution tag'
+ )
+
neps[nr] = tags
+ # Now that we have all of the NEP metadata, do some global consistency
+ # checks
+
+ for nr, tags in neps.items():
+ if tags['Status'] == 'Superseded':
+ if not 'Replaced-By' in tags:
+ raise RuntimeError(
+ f'NEP {nr} has been Superseded, but has no Replaced-By tag'
+ )
+
+ replaced_by = int(tags['Replaced-By'])
+ replacement_nep = neps[replaced_by]
+
+ if not int(replacement_nep['Replaces']) == nr:
+ raise RuntimeError(
+ f'NEP {nr} is superseded by {replaced_by}, but that NEP has a '
+ f"Replaces tag of `{replacement_nep['Replaces']}`."
+ )
+
+ if 'Replaces' in tags:
+ replaced_nep = int(tags['Replaces'])
+ replaced_nep_tags = neps[replaced_nep]
+ if not replaced_nep_tags['Status'] == 'Superseded':
+ raise RuntimeError(
+ f'NEP {nr} replaces {replaced_nep}, but that NEP has not '
+ f'been set to Superseded'
+ )
+
return {'neps': neps}