Make new python documentation checks optional

* Older sphinx versions don't have an easy 'objects' property so we just drop
  this check. As long as it happens on CI builds that's the main thing.
This commit is contained in:
baldurk
2020-12-10 10:05:10 +00:00
parent afc9fc8f1e
commit ea2410fe9f
+8 -2
View File
@@ -410,7 +410,11 @@ def build_finished(app, exception):
from sphinx.errors import SphinxError
# Get list of documented/indexed python objects
objs = app.env.get_domain('py').objects
pydomain = app.env.get_domain('py')
if not hasattr(pydomain, 'objects'):
print("WARNING: Sphinx version is too old to check objects validity. Upgrade to at least Sphinx 2.1.0")
return
objs = pydomain.objects
# Enumerate the namespaced objects in both modules
items = []
@@ -424,13 +428,15 @@ def build_finished(app, exception):
items = set(filter(lambda i: re.search('__|SWIG|ResourceId_Null|rdcfixedarray_of|rdcarray_of|Structured.*List', i) is None, items))
# Remove any documented/indexed python objects
items -= set(app.env.get_domain('py').objects.keys())
items -= set(objs.keys())
# Print an error if any remain
if len(items) > 0:
items = sorted(list(items))
raise SphinxError("These {} global classes/functions are not included in the documentation index:\n* {}".format(len(items), '\n* '.join(items)))
print("All python objects are linked in the documentation.")
def setup(app):
app.connect('autodoc-skip-member', maybe_skip_member)
app.connect('build-finished', build_finished)