@@ -73,6 +73,16 @@ def remove_redundant_stuff(main_directory: str) -> None:
7373
7474
7575def process_one_file (file_name : str ) -> None :
76+ """
77+ Process a file through multiple steps including preprocessing, rendering,
78+ transforming into images, generating annotations, and handling exceptions.
79+
80+ Args:
81+ file_name (str): The path to the main .tex file to be processed.
82+
83+ Returns:
84+ None
85+ """
7686 main_directory = os .path .dirname (file_name )
7787 log .info (f"[VRDU] file: { file_name } , start processing." )
7888
@@ -84,32 +94,37 @@ def process_one_file(file_name: str) -> None:
8494 log .info (f"[VRDU] file: { file_name } , paper has been processed" )
8595 return
8696
97+ # remove redundant files
8798 output_directory = os .path .join (main_directory , "output" )
8899 if os .path .exists (output_directory ):
89100 shutil .rmtree (output_directory )
90101
91- # make a copy of the original tex file
102+ # make a copy of the original tex file to avoid polluting the original tex file
92103 original_tex = os .path .join (main_directory , "paper_original.tex" )
93104 shutil .copyfile (file_name , original_tex )
94105
95106 cwd = os .getcwd ()
96107
97108 try :
98- # change the working directory to the main directory
109+ # change the working directory to the main directory of the paper
99110 os .chdir (main_directory )
111+
112+ # step 1: preprocess the paper
100113 preprocess .run (original_tex )
101114
102- # run rendering
115+ # step 2.1: run rendering
103116 vrdu_renderer = renderer .Renderer ()
104117 vrdu_renderer .render (original_tex )
105118
106119 # compile into PDFs, and then convert into images
107120 log .info (
108121 f"[VRDU] file: { original_tex } , start transforming into images, this may take a while..."
109122 )
123+
124+ # step 2.2: compling tex into PDFs
110125 transform_tex_to_images (main_directory )
111126
112- # generate annotations
127+ # Step 3: generate annotations
113128 log .info (
114129 f"[VRDU] file: { original_tex } , start generating annotations, this may take a while..."
115130 )
@@ -119,6 +134,7 @@ def process_one_file(file_name: str) -> None:
119134 vrdu_order_annotation = order .OrderAnnotation (original_tex )
120135 vrdu_order_annotation .annotate ()
121136
137+ # generate quality report for simple debugging
122138 generate_quality_report (main_directory )
123139
124140 log .info (f"[VRDU] file: { original_tex } , successfully processed." )
0 commit comments