@@ -4004,6 +4004,29 @@ def format_python_docstring(func_name, doc_info, args_info):
40044004 lines .extend (wrapped_return )
40054005 lines .append ('' )
40064006
4007+ # Add source reference if available
4008+ if doc_info .get ('source_file' ) and doc_info .get ('source_line' ):
4009+ source_file = doc_info ['source_file' ]
4010+ source_line = doc_info ['source_line' ]
4011+
4012+ # Make path relative to LVGL directory for cleaner display
4013+ if '/lvgl/src/' in source_file :
4014+ relative_path = source_file .split ('/lvgl/' , 1 )[1 ]
4015+ elif '/lvgl/' in source_file :
4016+ relative_path = source_file .split ('/lvgl/' , 1 )[1 ]
4017+ else :
4018+ relative_path = os .path .basename (source_file )
4019+
4020+ # Clean up any remaining path artifacts
4021+ if relative_path .startswith ('gen/../lvgl/' ):
4022+ relative_path = relative_path [12 :] # Remove 'gen/../lvgl/'
4023+ elif relative_path .startswith ('../lvgl/' ):
4024+ relative_path = relative_path [8 :] # Remove '../lvgl/'
4025+
4026+ if lines :
4027+ lines .append ('' )
4028+ lines .append (f'Source: { relative_path } :{ source_line } ' )
4029+
40074030 if lines and lines [- 1 ] == '' :
40084031 lines .pop () # Remove trailing empty line
40094032
@@ -4102,6 +4125,9 @@ def process_file_for_docs(file_path):
41024125 comment_text = '\n ' .join (comment_lines )
41034126 doc_info = parse_doxygen_comment (comment_text )
41044127 if doc_info :
4128+ # Add source file information
4129+ doc_info ['source_file' ] = file_path
4130+ doc_info ['source_line' ] = i + 1 # Line numbers are 1-based
41054131 func_docs [func_name ] = doc_info
41064132
41074133 i += 1
0 commit comments