Skip to content

Latest commit

 

History

History
107 lines (61 loc) · 7.74 KB

File metadata and controls

107 lines (61 loc) · 7.74 KB
graph LR
    heartrate_core_file_table_context["heartrate.core.file_table_context"]
    heartrate_core_stacktrace["heartrate.core.stacktrace"]
    heartrate_core_frames_matching["heartrate.core.frames_matching"]
    heartrate_core_highlight_stack_frame["heartrate.core.highlight_stack_frame"]
    heartrate_core_highlight_python_and_ranges["heartrate.core.highlight_python_and_ranges"]
    heartrate_core_highlight_python["heartrate.core.highlight_python"]
    heartrate_core_highlight_ranges["heartrate.core.highlight_ranges"]
    heartrate_core_current_frame["heartrate.core.current_frame"]
    heartrate_core_file_table_context -- "calls" --> heartrate_core_frames_matching
    heartrate_core_file_table_context -- "calls" --> heartrate_core_highlight_python_and_ranges
    heartrate_core_stacktrace -- "calls" --> heartrate_core_current_frame
    heartrate_core_stacktrace -- "calls" --> heartrate_core_highlight_stack_frame
    heartrate_core_frames_matching -- "calls" --> heartrate_core_current_frame
    heartrate_core_highlight_stack_frame -- "calls" --> heartrate_core_highlight_python_and_ranges
    heartrate_core_highlight_python_and_ranges -- "calls" --> heartrate_core_highlight_python
    heartrate_core_highlight_python_and_ranges -- "calls" --> heartrate_core_highlight_ranges
Loading

CodeBoardingDemoContact

Details

The heartrate.core subsystem is designed to capture, process, and present real-time Python execution data, primarily focusing on stack traces and code highlighting for a web-based visualization. It acts as the backend for a dynamic code introspection tool. The core flow involves an API endpoint (stacktrace) that initiates the collection of raw stack frame data. This data is then filtered to focus on relevant user code, and each frame's code is meticulously highlighted, combining general Python syntax with specific execution point emphasis. The processed and structured data is finally exposed through another API endpoint (file_table_context) for consumption by a frontend visualization.

heartrate.core.file_table_context

This is the central component of the subsystem, acting as the primary data aggregator and the backend API endpoint. It orchestrates the transformation of raw execution data (including stack frames and highlighted code) into a structured format specifically designed for the web frontend's file table view. This function is the direct interface for the frontend to retrieve visualization data.

Related Classes/Methods:

heartrate.core.stacktrace

This component serves as an API endpoint (/stacktrace/) that dynamically generates and returns a JSON representation of the current Python call stack. It iterates through stack frames, extracts relevant information (filename, line number, function name), applies code highlighting to each frame using highlight_stack_frame, and filters out internal heartrate frames to provide a clean, user-focused stack trace for visualization.

Related Classes/Methods:

heartrate.core.frames_matching

Implements the logic for identifying and filtering stack frames based on specific criteria (e.g., excluding internal frames, focusing on user code). This ensures only relevant frames are processed and sent to the frontend, optimizing data for visualization.

Related Classes/Methods:

heartrate.core.highlight_stack_frame

Focuses on applying detailed code highlighting within individual stack frames. This involves integrating both general Python syntax highlighting and specific line range highlighting to visually emphasize execution points, crucial for the visualization aspect.

Related Classes/Methods:

heartrate.core.highlight_python_and_ranges

A utility function that combines general Python syntax highlighting with specific line range highlighting. It acts as an intermediary for applying complex highlighting rules, used by other components to enrich code snippets.

Related Classes/Methods:

heartrate.core.highlight_python

This foundational utility applies general Python syntax highlighting to a given code string using the pygments library. It is a core part of the visualization process, ensuring code snippets are presented with proper syntax coloring.

Related Classes/Methods:

heartrate.core.highlight_ranges

This utility identifies and highlights specific line ranges within a block of source code. It processes a list of stack frames to determine the exact code segments that were executing, marking them for visual emphasis. This is crucial for showing the active lines in the visualized stack trace.

Related Classes/Methods:

heartrate.core.current_frame

This foundational utility provides direct access to the current execution frame object. It is essential for navigating the call stack and extracting information about the current point of execution.

Related Classes/Methods: