Skip to content

Commit b90ab40

Browse files
authored
Merge pull request #38 from RedMser/class-docs
Add class documentation
2 parents 596884c + 7799004 commit b90ab40

File tree

7 files changed

+103
-43
lines changed

7 files changed

+103
-43
lines changed

rust/Cargo.lock

Lines changed: 46 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/src/fluent/editor_plugin.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ use godot::{classes::{EditorPlugin, IEditorPlugin}, prelude::*};
22

33
use super::FluentExportPlugin;
44

5+
/// Editor plugin to register tools for Fluent Translations. For internal use only.
56
#[derive(GodotClass)]
6-
#[class(tool, editor_plugin, init, base=EditorPlugin)]
7+
#[class(tool, init, base=EditorPlugin)]
78
pub struct FluentEditorPlugin {
89
export_plugin: Option<Gd<FluentExportPlugin>>,
910
base: Base<EditorPlugin>,

rust/src/fluent/export_plugin.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ use super::strip_comments;
66
const EXPORT_OPTION_PREFIX: &str = "fluent/";
77
const EXPORT_OPTION_STRIP_COMMENTS: &str = constcat!(EXPORT_OPTION_PREFIX, "strip_comments");
88

9+
/// Export plugin to handle post-processing options for Fluent Translations. For internal use only.
910
#[derive(GodotClass)]
10-
#[class(base=EditorExportPlugin)]
11+
#[class(tool, base=EditorExportPlugin)]
1112
pub struct FluentExportPlugin {
1213
base: Base<EditorExportPlugin>,
1314
}
@@ -20,7 +21,7 @@ impl IEditorExportPlugin for FluentExportPlugin {
2021
}
2122
}
2223

23-
fn get_export_options(&self, _platform: Gd<EditorExportPlatform>) -> Array<Dictionary> {
24+
fn get_export_options(&self, _platform: Option<Gd<EditorExportPlatform>>) -> Array<Dictionary> {
2425
array![dict! {
2526
"option": dict! {
2627
"name": GString::from(EXPORT_OPTION_STRIP_COMMENTS),
@@ -44,4 +45,17 @@ impl IEditorExportPlugin for FluentExportPlugin {
4445
self.base_mut().add_file(path, binary, false);
4546
}
4647
}
48+
49+
fn customize_resource(&mut self, _resource: Gd<Resource>, _path: GString) -> Option<Gd<Resource>> {
50+
None
51+
}
52+
fn customize_scene(&mut self, _scene: Gd<Node>, _path: GString) -> Option<Gd<Node>> {
53+
None
54+
}
55+
fn get_customization_configuration_hash(&self) -> u64 {
56+
0
57+
}
58+
fn get_name(&self) -> GString {
59+
"FluentExportPlugin".into()
60+
}
4761
}

rust/src/fluent/generator.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ use godot::global::Error as GdErr;
1111

1212
use super::{project_settings::{INVALID_MESSAGE_HANDLING_SKIP, PROJECT_SETTING_GENERATOR_INVALID_MESSAGE_HANDLING, PROJECT_SETTING_GENERATOR_LOCALES, PROJECT_SETTING_GENERATOR_PATTERNS}, FluentPackedSceneTranslationParser, FluentTranslationParser};
1313

14+
/// Allows generating Fluent Translation List (FTL) files by extracting keys.
15+
///
16+
/// For now, this class only supports [PackedScene] files and is completely loaded via Project Settings configuration.
17+
/// It may be updated in the future to receive a proper API and editor integration.
1418
#[derive(GodotClass)]
1519
#[class(no_init)]
1620
pub struct FluentGenerator {
@@ -26,6 +30,7 @@ pub type MessageGeneration = HashMap<String, String>;
2630

2731
#[godot_api]
2832
impl FluentGenerator {
33+
/// Create a new [FluentGenerator] instance using the Project Settings for configuration.
2934
#[func]
3035
pub fn create() -> Gd<Self> {
3136
let project_settings = ProjectSettings::singleton();
@@ -46,6 +51,9 @@ impl FluentGenerator {
4651
})
4752
}
4853

54+
/// Generate Fluent Translation List (FTL) files, creating or updating files as necessary.
55+
/// If a message is already translated, it will not be updated.
56+
/// Deleted keys are currently left untouched and must be manually purged.
4957
#[func]
5058
pub fn generate(&self) {
5159
// Collect source files and batched write operations.

rust/src/fluent/global.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use godot::classes::ResourceLoader;
33

44
use super::ResourceFormatLoaderFluent;
55

6+
/// Singleton for handling Fluent Translation. For internal use only.
67
#[derive(GodotClass)]
78
#[class(base=Object, init)]
89
pub struct FluentI18nSingleton {

rust/src/fluent/importer.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ use godot::global::Error as GdErr;
66

77
use super::{locale::{compute_locale, compute_message_pattern}, project_settings::*, TranslationFluent};
88

9+
/// Loads Fluent Translation List (FTL) files.
10+
///
11+
/// This loader is already registered and does usually not need to be manually used. Use [method @GDScript.load] on a `.ftl` file instead.
912
#[derive(GodotClass)]
1013
#[class(base=ResourceFormatLoader)]
1114
pub struct ResourceFormatLoaderFluent {

0 commit comments

Comments
 (0)