5050import tomli
5151
5252from snooty .diagnostics import Diagnostic , NestedProject , UnexpectedNodeType
53- from snooty .n import FileId
53+ from snooty .n import FileId , TocTreeDirectiveEntry
5454
5555from . import n , tinydocutils
5656
@@ -525,15 +525,17 @@ def deserialize(
525525 deserialized_children : List [n .Node ] = []
526526
527527 for child in node_value :
528+
528529 if not isinstance (child , dict ):
529530 continue
530531
531532 child_type : str = child .get ("type" , "" )
532533 child_node_type = cls .node_classes .get (child_type )
534+
533535 if child_node_type :
534536 if (
535537 child_node_type == n .Directive
536- and node .get ("name" ) == "toctree"
538+ and child .get ("name" ) == "toctree"
537539 ):
538540 child_node_type = n .TocTreeDirective
539541
@@ -547,6 +549,24 @@ def deserialize(
547549 filtered_fields [field .name ] = deserialized_children
548550 elif field .type == FileId and isinstance (node_value , str ):
549551 filtered_fields [field .name ] = field .type (node_value )
552+ elif field .name == "entries" :
553+ deserialized_entries : List [n .TocTreeDirectiveEntry ] = []
554+
555+ if isinstance (node_value , List ):
556+ for entry in node_value :
557+ if not isinstance (entry , dict ):
558+ continue
559+
560+ title = entry .get ("title" )
561+ slug = entry .get ("slug" )
562+
563+ if not title or not slug :
564+ continue
565+
566+ entryNode = TocTreeDirectiveEntry (title , None , slug , None )
567+ deserialized_entries .append (entryNode )
568+
569+ filtered_fields [field .name ] = deserialized_entries
550570 else :
551571 # Ideally, we validate that the data types of the fields match the data types of the JSON node,
552572 # but that requires a more verbose and time-consuming process. For now, we assume data types are correct.
0 commit comments