Skip to content

Basic parsing

Basic parsing that heavily relies on treesitter queries and node navigation.

I.e. This is the low level parsing that extracts basic information. More specific parsing can then use the basic information data structures from here to make more specific data structures.

ClassInfoBuilder

decorators cached property

Extract decorators from a class node.

docstring cached property

Extract the docstring from a class node.

full_content cached property

init cached property

Extract the initialization func/method from a class node.

lang = lang instance-attribute

language = TS_LANGS[lang] instance-attribute

line_nums cached property

methods cached property

Extract the methods from a class node.

name cached property

Extract the name from a class node.

node = class_node instance-attribute

signature cached property

Extract the signature from a class node.

superclasses cached property

Extract the superclasses from a class node.

__init__(lang, class_node)

build()

FuncInfoBuilder

code_body cached property

Extract the body from a function node.

decorators cached property

Extract decorators from a function node.

docstring cached property

Extract the docstring from a function node.

full_content cached property

lang = lang instance-attribute

language = TS_LANGS[lang] instance-attribute

line_nums cached property

name cached property

Extract the name from a function node.

node = func_node instance-attribute

return_type cached property

Extract the return type from a function node.

signature cached property

Extract the signature from a function node.

__init__(lang, func_node)

build()

get_class_infos(which_lang, node)

Get all class infos from a node (e.g. a file root_node).

get_function_infos(which_lang, node)

Get all function infos from a node (e.g. a file root_node).

get_import_infos(lang, node)

Extract all imports from a treesitter node (e.g. a file root_node).

Note 2024-11-24 -- This relies heavily on the treesitter query for python. Might have been easier to do a more basic search for possible import statements and then handle them in python instead. But now that it's done, it should be faster this way. For future language implementations, might be easier to work with import nodes in python.

get_text_from_node(node, default='')

Get the text from a node, or the default if it's not found.

parse_file(contents, lang)

Parse a file and return all the information.