feat(dom): Add support for generic drawer outputs.
Some checks failed
Testing / pytest (push) Successful in 23s
Testing / mypy (push) Failing after 28s
Testing / style-formatting (push) Failing after 24s
Testing / style-sorted-imports (push) Successful in 18s
Testing / stability-extra-test (push) Successful in 24s

This commit is contained in:
Sergio Martínez Portela 2025-02-09 14:11:52 +01:00
parent c0fc78fe33
commit df178d08d8
2 changed files with 16 additions and 0 deletions

View File

@ -24,6 +24,14 @@ class ResultsDrawerNode(DrawerNode):
return "<Results: {}>".format(len(self.children)) return "<Results: {}>".format(len(self.children))
class GenericDrawerNode(DrawerNode):
def __init__(self, drawer_name):
self.drawer_name = drawer_name
def __repr__(self):
return "<Drawer(): {}>".format(self.drawer_name, len(self.children))
class PropertyNode: class PropertyNode:
def __init__(self, key, value): def __init__(self, key, value):
self.key = key self.key = key

View File

@ -122,6 +122,7 @@ NON_FINISHED_GROUPS = (
dom.ListGroupNode, dom.ListGroupNode,
dom.ResultsDrawerNode, dom.ResultsDrawerNode,
dom.PropertyDrawerNode, dom.PropertyDrawerNode,
dom.GenericDrawerNode,
) )
FREE_GROUPS = (dom.CodeBlock,) FREE_GROUPS = (dom.CodeBlock,)
@ -636,6 +637,13 @@ class Headline:
assert current_node is None assert current_node is None
current_node = dom.ResultsDrawerNode() current_node = dom.ResultsDrawerNode()
# TODO: Allow indentation of these blocks inside others
indentation_tree = [current_node]
tree.append(current_node)
elif content.strip().startswith(':') and content.strip().endswith(':'):
assert current_node is None
current_node = dom.GenericDrawerNode(content.strip().strip(':'))
# TODO: Allow indentation of these blocks inside others # TODO: Allow indentation of these blocks inside others
indentation_tree = [current_node] indentation_tree = [current_node]
tree.append(current_node) tree.append(current_node)