@@ -14,6 +14,10 @@ use super::Module;
1414mod libraries;
1515mod time;
1616
17+ /// Creates a sccope for a Rhai script
18+ ///
19+ /// # Errors
20+ /// [`Error::Version`] if the version is not a valid semver version
1721pub fn scope ( ctx : & Context , vfs : bool ) -> Result < Scope , Error > {
1822 let mut scope = Scope :: new ( ) ;
1923 scope. push_constant ( "HEMTT_VERSION" , env ! ( "CARGO_PKG_VERSION" ) ) ;
@@ -69,6 +73,15 @@ impl Default for Hooks {
6973}
7074
7175impl Hooks {
76+ /// Run a folder of hooks
77+ ///
78+ /// # Errors
79+ /// [`Error::ScriptNotFound`] if the script does not exist
80+ /// [`Error::HookFatal`] if the script calls `fatal`
81+ /// [`Error::Rhai`] if the script is invalid
82+ ///
83+ /// # Panics
84+ /// If a file path is not a valid [`OsStr`] (UTF-8)
7285 pub fn run_folder ( self , ctx : & Context , name : & str , vfs : bool ) -> Result < ( ) , Error > {
7386 if !self . 0 {
7487 return Ok ( ( ) ) ;
@@ -110,6 +123,15 @@ impl Hooks {
110123 Ok ( ( ) )
111124 }
112125
126+ /// Run a script
127+ ///
128+ /// # Errors
129+ /// [`Error::ScriptNotFound`] if the script does not exist
130+ /// [`Error::HookFatal`] if the script calls `fatal`
131+ /// [`Error::Rhai`] if the script is invalid
132+ ///
133+ /// # Panics
134+ /// If a file path is not a valid [`OsStr`] (UTF-8)
113135 pub fn run_file ( ctx : & Context , name : & str ) -> Result < ( ) , Error > {
114136 let mut path = ctx. hemtt_folder ( ) . join ( "scripts" ) . join ( name) ;
115137 path. set_extension ( "rhai" ) ;
0 commit comments