DouDou
Upload data2/instruction_generation/prompts/function_extract.txt with huggingface_hub
f83ae37 verified
You are a professional code analysis tool. Please analyze the following code file and extract file-level dependencies and all function information.
Project Context:
{project_context}
Code file path: {file_path}
Programming language: {language}
Below is the code file content:
```{language}
{code_content}
```
Requirements:
1. Extract file-level dependencies: Find all import/include/use/require statements, list external packages, modules, and libraries (only external dependencies, excluding relative imports within the same project)
2. Extract all functions:
- Function name
- Function start line number and end line number (1-indexed, inclusive)
- Complete function body (including function definition and body)
- Function documentation comment start and end line numbers (if any)
3. For nested functions, also extract them (each independent function should be one record)
4. If the code file is not function-structured (e.g., scripts, configuration files, etc.), the dependency list can be empty, and the functions list can also be empty
Please output the result according to the following JSON Schema (must use JSON, do not include any other text):
{{
"language": "Programming language (e.g., python, cpp, java, etc.)",
"file_path": "Relative file path",
"dependencies": ["dependency1", "dependency2", ...],
"functions": [
{{
"function_name": "function name",
"function_start_line": start_line_number,
"function_end_line": end_line_number,
"function_body": "complete function code body",
"doc_start_line": documentation start line number (if any, otherwise null),
"doc_end_line": documentation end line number (if any, otherwise null)
}},
...
]
}}
Note:
- Output only the JSON object, do not include any prefix or suffix text
- Line numbers must be accurate for subsequent code extraction
- function_body should be the complete function code (from def/function/... to the end of the function)
- If the file is too large to analyze completely, please note this in comments