Skip to main content

factorio_codegen/generator/
comment.rs

1use crate::LuaGenerator;
2
3impl LuaGenerator {
4    /// Generate a parameter type comment
5    pub(crate) fn parameter_type_comment(&self, source_type: Option<&str>) -> String {
6        if self.debug_level_at_least(1) {
7            source_type.map_or_else(String::new, |ty| format!(" --[[ {ty} ]]"))
8        } else {
9            String::new()
10        }
11    }
12
13    /// Generate a variable type comment
14    pub(crate) fn variable_type_comment(&self, source_type: Option<&str>) -> String {
15        if self.debug_level_at_least(1) {
16            source_type.map_or_else(String::new, |ty| format!(" --[[ {ty} ]]"))
17        } else {
18            String::new()
19        }
20    }
21
22    /// Generate a function return command
23    pub(crate) fn function_return_comment(&self, return_type: Option<&str>) -> String {
24        if self.debug_level_at_least(1) {
25            return_type.map_or_else(String::new, |ty| format!(" --[[ -> {ty} ]]"))
26        } else {
27            String::new()
28        }
29    }
30}