@@ -20,45 +20,29 @@ pub trait Mode {
2020 fn run ( self ) -> anyhow:: Result < ExitCode > ;
2121}
2222
23- /// The intercept mode we are only capturing the build commands.
23+ /// The intercept mode we are only capturing the build commands
24+ /// and write it into the output file.
2425pub struct Intercept {
2526 command : args:: BuildCommand ,
2627 output : args:: BuildEvents ,
2728 config : config:: Intercept ,
2829}
2930
30- /// The semantic mode we are deduct the semantic meaning of the
31- /// executed commands from the build process.
32- pub struct Semantic {
33- event_source : EventFileReader ,
34- semantic_recognition : Recognition ,
35- semantic_transform : Transformation ,
36- output_writer : OutputWriter ,
37- }
38-
39- /// The all model is combining the intercept and semantic modes.
40- pub struct All {
41- command : args:: BuildCommand ,
42- intercept_config : config:: Intercept ,
43- semantic_recognition : Recognition ,
44- semantic_transform : Transformation ,
45- output_writer : OutputWriter ,
46- }
47-
4831impl Intercept {
32+ /// Create a new intercept mode instance.
4933 pub fn new (
50- input : args:: BuildCommand ,
34+ command : args:: BuildCommand ,
5135 output : args:: BuildEvents ,
5236 config : config:: Intercept ,
5337 ) -> Self {
5438 Self {
55- command : input ,
39+ command,
5640 output,
5741 config,
5842 }
5943 }
6044
61- /// Write the envelopes into the output file.
45+ /// Consume events and write them into the output file.
6246 fn write_to_file (
6347 output_file_name : String ,
6448 envelopes : impl IntoIterator < Item = Envelope > ,
@@ -76,6 +60,11 @@ impl Intercept {
7660}
7761
7862impl Mode for Intercept {
63+ /// Run the intercept mode by setting up the collector service and
64+ /// the intercept environment. The build command is executed in the
65+ /// intercept environment.
66+ ///
67+ /// The exit code is based on the result of the build command.
7968 fn run ( self ) -> anyhow:: Result < ExitCode > {
8069 let output_file_name = self . output . file_name . clone ( ) ;
8170 let service = CollectorService :: new ( move |envelopes| {
@@ -93,7 +82,17 @@ impl Mode for Intercept {
9382 }
9483}
9584
85+ /// The semantic mode we are deduct the semantic meaning of the
86+ /// executed commands from the build process.
87+ pub struct Semantic {
88+ event_source : EventFileReader ,
89+ semantic_recognition : Recognition ,
90+ semantic_transform : Transformation ,
91+ output_writer : OutputWriter ,
92+ }
93+
9694impl Semantic {
95+ /// Create a new semantic mode instance.
9796 pub fn new (
9897 event_source : EventFileReader ,
9998 semantic_recognition : Recognition ,
@@ -110,6 +109,11 @@ impl Semantic {
110109}
111110
112111impl Mode for Semantic {
112+ /// Run the semantic mode by generating the compilation database entries
113+ /// from the event source. The entries are then processed by the semantic
114+ /// recognition and transformation. The result is written to the output file.
115+ ///
116+ /// The exit code is based on the result of the output writer.
113117 fn run ( self ) -> anyhow:: Result < ExitCode > {
114118 // Set up the pipeline of compilation database entries.
115119 let entries = self
@@ -126,7 +130,17 @@ impl Mode for Semantic {
126130 }
127131}
128132
133+ /// The all model is combining the intercept and semantic modes.
134+ pub struct All {
135+ command : args:: BuildCommand ,
136+ intercept_config : config:: Intercept ,
137+ semantic_recognition : Recognition ,
138+ semantic_transform : Transformation ,
139+ output_writer : OutputWriter ,
140+ }
141+
129142impl All {
143+ /// Create a new all mode instance.
130144 pub fn new (
131145 command : args:: BuildCommand ,
132146 intercept_config : config:: Intercept ,
@@ -143,6 +157,8 @@ impl All {
143157 }
144158 }
145159
160+ /// Consumer the envelopes for analysis and write the result to the output file.
161+ /// This implements the pipeline of the semantic analysis. Same as the `Semantic` mode.
146162 fn consume_for_analysis (
147163 semantic_recognition : Recognition ,
148164 semantic_transform : Transformation ,
@@ -160,6 +176,12 @@ impl All {
160176}
161177
162178impl Mode for All {
179+ /// Run the all mode by setting up the collector service and the intercept environment.
180+ /// The build command is executed in the intercept environment. The collected events are
181+ /// then processed by the semantic recognition and transformation. The result is written
182+ /// to the output file.
183+ ///
184+ /// The exit code is based on the result of the build command.
163185 fn run ( self ) -> anyhow:: Result < ExitCode > {
164186 let semantic_recognition = self . semantic_recognition ;
165187 let semantic_transform = self . semantic_transform ;
0 commit comments