44//! - [`ast`] : parse SQL into an AST using [`sqlparser`]
55//! - [`comments`] : extract and model comments and spans
66
7- use crate :: { ast:: ParsedSqlFileSet , comments:: Comments , docs:: SqlDocs , files:: SqlFileSet } ;
7+ use crate :: { ast:: ParsedSqlFileSet , comments:: Comments , docs:: SqlFileDoc , files:: SqlFileSet } ;
88pub use error:: DocError ;
99use std:: path:: { Path , PathBuf } ;
1010pub mod ast;
1111pub mod comments;
1212pub mod docs;
1313pub mod error;
1414pub mod files;
15+ mod sql_doc;
16+ pub use sql_doc:: SqlDoc ;
1517
16- /// Primary Entry point. Returns a tuple of [`PathBuf`] and [`SqlDocs `].
18+ /// Primary Entry point. Returns a tuple of [`PathBuf`] and [`SqlFileDoc `].
1719///
1820/// # Parameters:
1921/// - `dir`: the [`Path`] to recursively parse `.sql` files. Allows for coercion
@@ -33,7 +35,7 @@ pub mod files;
3335pub fn generate_docs_from_dir < P : AsRef < Path > , S : AsRef < str > > (
3436 dir : P ,
3537 deny_list : & [ S ] ,
36- ) -> Result < Vec < ( PathBuf , SqlDocs ) > , DocError > {
38+ ) -> Result < Vec < ( PathBuf , SqlFileDoc ) > , DocError > {
3739 // Convert deny list to a `Vec<String>`
3840 let deny_vec: Vec < String > = deny_list. iter ( ) . map ( |file| file. as_ref ( ) . to_string ( ) ) . collect ( ) ;
3941 // verify whether deny_list is empty and return correct `Option`
@@ -43,17 +45,17 @@ pub fn generate_docs_from_dir<P: AsRef<Path>, S: AsRef<str>>(
4345 // parse all files sql
4446 let parsed_files = ParsedSqlFileSet :: parse_all ( file_set) ?;
4547 let mut sql_docs = Vec :: new ( ) ;
46- // iterate on each file and generate the `SqlDocs ` and associate with the `Path`
48+ // iterate on each file and generate the `SqlFileDoc ` and associate with the `Path`
4749 for file in parsed_files. files ( ) {
4850 let comments = Comments :: parse_all_comments_from_file ( file) ?;
49- let docs = SqlDocs :: from_parsed_file ( file, & comments) ?;
51+ let docs = SqlFileDoc :: from_parsed_file ( file, & comments) ?;
5052 let path = file. file ( ) . path ( ) . to_path_buf ( ) ;
5153 sql_docs. push ( ( path, docs) ) ;
5254 }
5355 Ok ( sql_docs)
5456}
5557
56- /// Secondary Entry point. Returns a tuple of [`PathBuf`] and [`SqlDocs `].
58+ /// Secondary Entry point. Returns a tuple of [`PathBuf`] and [`SqlFileDoc `].
5759/// Useful when no deny list is needed
5860///
5961/// # Parameters:
@@ -71,7 +73,7 @@ pub fn generate_docs_from_dir<P: AsRef<Path>, S: AsRef<str>>(
7173/// ```
7274pub fn generate_docs_from_dir_no_deny < P : AsRef < Path > > (
7375 dir : P ,
74- ) -> Result < Vec < ( PathBuf , SqlDocs ) > , DocError > {
76+ ) -> Result < Vec < ( PathBuf , SqlFileDoc ) > , DocError > {
7577 generate_docs_from_dir :: < P , & str > ( dir, & [ ] )
7678}
7779
@@ -109,7 +111,7 @@ mod tests {
109111 let parsed_doc_table_doc = parsed_doc. tables ( ) [ i]
110112 . doc ( )
111113 . as_ref ( )
112- . map_or_else ( || panic ! ( "unable to find SqlDocs table doc" ) , |val| val) ;
114+ . map_or_else ( || panic ! ( "unable to find SqlFileDoc table doc" ) , |val| val) ;
113115 assert_eq ! ( parsed_doc_table_doc, table_comments[ i] ) ;
114116 }
115117 let user_columns = [ "id" , "username" , "email" , "created_at" ] ;
0 commit comments