Manifest_Function
Manifest_Function ¶
CodeEngineManifest_Function
dataclass
¶
CodeEngineManifest_Function(
ast_fn: FunctionDef,
name: str,
display_name: str,
description: str,
is_private: bool,
editor_start_index: int,
has_return: bool,
output: CodeEngineManifest_Argument,
editor_end_index: int = None,
content: str = None,
input_args: list[CodeEngineManifest_Argument] = list(),
_target_from_api: dict = None,
)
from_ast_function_def
classmethod
¶
from_ast_function_def(
ast_fn: FunctionDef, original_module_string
) -> CodeEngineManifest_Function
Create a complete function description as a CodeEngineManifest_Function object.
Combines all extracted function metadata into a structured FunctionMetadata dataclass instance that includes the function name, parameters, return type, docstring, and editor positioning information required for code engine integration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function_node
|
FunctionDef
|
The AST node representing the function to describe |
required |
Returns:
| Name | Type | Description |
|---|---|---|
FunctionMetadata |
CodeEngineManifest_Function
|
Complete function metadata object containing: - name (str): Original function name - displayName (str): Human-readable function name - description (str): Function docstring - inputs (list[Dict]): Parameter descriptions - output (Dict): Return value description - variables (Dict): Variable descriptions (copy of inputs) - isPrivate (bool): Whether function is private (based on underscore prefix) - editorStartIndex (int): Character position in source file - hasReturn (bool): Whether function has return type annotation |
Note
The isPrivate field is determined by checking if the function name starts with an underscore, following Python naming conventions.
Source code in src/crew_dcs/classes/DomoCodeEngine/Manifest_Function.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
to_dict ¶
to_dict() -> dict
Serialize the function metadata and arguments to a manifest-compatible dictionary.
Source code in src/crew_dcs/classes/DomoCodeEngine/Manifest_Function.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
calculate_character_index_of_line_number ¶
calculate_character_index_of_line_number(
line_num: int, full_text: str
) -> int
Calculate the character index at the start of a given line (0-based) in the source file. Args: line_num (int): The line number (0-based) where the function starts. full_text (str): The full text of the file. Returns: int: Character position from the beginning of the file (0-based).
Source code in src/crew_dcs/classes/DomoCodeEngine/Manifest_Function.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
extract_function_docstring ¶
extract_function_docstring(
function_node: FunctionDef,
) -> str
Extract the docstring from a function AST node if present.
Identifies and extracts the first string literal in a function body, which by Python convention serves as the function's documentation. Only extracts docstrings that are the first statement in the function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function_node
|
FunctionDef
|
The function AST node to examine |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The function's docstring with whitespace stripped, or empty string if none found |
Note
Follows Python docstring conventions where the first statement in a function body, if it's a string literal, is considered the docstring. Multi-line docstrings are preserved but leading/trailing whitespace is removed.
Source code in src/crew_dcs/classes/DomoCodeEngine/Manifest_Function.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
extract_return_type_annotation ¶
extract_return_type_annotation(
function_node: FunctionDef,
) -> str
Extract return type annotation from a function AST node.
Converts the function's return type annotation from AST format back to a string representation for type analysis and schema mapping.
Note
Only works with Python 3.9+ that has ast.unparse(). For older versions, returns empty string if return annotation exists but cannot be parsed.
Source code in src/crew_dcs/classes/DomoCodeEngine/Manifest_Function.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |