Numbat also offers a few customization options, mostly to help with mapping data other than source code.
Warning
These features can only be viewable with NumbatUI, Quarkslab fork of Sourcetrail, which is currently work in progress and really unstable.
Custom node types
Non-source code data might not fit in any of the existing node types, so we can use the set_node_type function to change them to types that are more adapted.
The existing node types are: annotationbuilt-in typeclassenumenum constantfieldfilefunctionglobal variableinterfacemacromethodmodulenamespacepackagestructsymboltypetype parametertypedefunion
Here, for example, the typedef node type is changed to symlink and Symlinks will be displayed in the overview instead of Typedefs.
fromnumbatimportSourcetrailDBfrompathlibimportPathdb=SourcetrailDB.open(Path('my_database'),clear=True)# add nodesclass_id=db.record_class(prefix="class",name="MyType",postfix="():",hover_display="example class used for demonstration")field_id=db.record_field(name="my_member",parent_id=class_id)meth_id=db.record_method(name="my_method",parent_id=class_id)db.commit()db.close()
Custom commands
We can also use the set_custom_command method to set a user-defined command for each node that can be executed in the node's context menu.
A list is used for the command and its arguments, and a brief description can be provided separately.
fromnumbatimportSourcetrailDBfrompathlibimportPathdb=SourcetrailDB.open(Path('my_database'),clear=True)# record filefile_id=db.record_file(Path('file.py'))db.record_file_language(file_id,'python')# add nodesclass_id=db.record_class(prefix="class",name="MyType",postfix="():")field_id=db.record_field(name="my_member",parent_id=class_id)meth_id=db.record_method(name="my_method",parent_id=class_id)# set commanddb.set_custom_command(file_id,["open",str(Path("file.py").absolute())],"Open in external window")db.commit()db.close()
File sideloading
Finally, we can link a file to any node using the associate_file_to_node method. This makes it so that the full content of the file can be displayed when selecting the node, without storing the content directly in the database nor creating an additional node for the file.\
The sideloaded file is stored in the [project_name]_files/ directory next to the database.