Add extension errors that stop the build

This commit is contained in:
Richard Berger
2019-11-24 19:49:59 -07:00
parent 7d289063b4
commit 4c13001a6f

View File

@ -4,6 +4,7 @@ from docutils.nodes import Element, Node
from typing import Any, Dict, List
from sphinx import addnodes
from sphinx.util import logging
from sphinx.errors import SphinxError
class TableFromList(SphinxDirective):
has_content = True
@ -22,8 +23,12 @@ class TableFromList(SphinxDirective):
if len(node.children) != 1 or not isinstance(node.children[0],
nodes.bullet_list):
reporter = self.state.document.reporter
return [reporter.warning('.. table_from_list content is not a list', line=self.lineno)]
raise SphinxError('table_from_list content is not a list')
fulllist = node.children[0]
if (len(fulllist) % ncolumns) != 0:
raise SphinxError('number of list elements not a multiple of column number')
table = nodes.table()
tgroup = nodes.tgroup(cols=ncolumns)
table += tgroup