@@ -10,57 +10,34 @@ use crate::{
1010 files:: SqlFileSet ,
1111} ;
1212
13+ /// Structure for Sql Documentation, built from [`TableDoc`] and
1314pub struct SqlDoc {
14- // e.g. all tables across all files
15- tables : Vec < TableDoc > , // or a map keyed by (schema, name)
16- // optionally: keep per- file docs too
15+ /// Holds the [`Vec`] of all tables found in all specified files.
16+ tables : Vec < TableDoc > ,
17+ /// Holds the [`Vec`] of each file's [`PathBuf`] and the original file's [`SqlFileDoc`]
1718 files : Vec < ( PathBuf , SqlFileDoc ) > ,
1819}
1920
21+
22+ /// Builder structure for the [`SqlDoc`]
2023pub struct SqlDocBuilder {
21- source : SqlFileDocource ,
24+ /// The source for implementing the [`SqlDoc`] to be built
25+ source : SqlFileDocSource ,
26+ /// The list of files to be ignored for parsing purposes.
2227 deny : Vec < String > ,
2328}
2429
25- enum SqlFileDocource {
30+ /// Enum for specifying a file doc source as a `directory` or a specific `file`
31+ enum SqlFileDocSource {
2632 Dir ( PathBuf ) ,
2733 File ( PathBuf ) ,
2834}
2935
3036impl SqlDoc {
31- pub fn from_dir < P : AsRef < Path > > ( root : P ) -> SqlDocBuilder {
32- SqlDocBuilder {
33- source : SqlFileDocource :: Dir ( root. as_ref ( ) . to_path_buf ( ) ) ,
34- deny : Vec :: new ( ) ,
35- }
36- }
3737
38- pub fn from_path < P : AsRef < Path > > ( path : P ) -> SqlDocBuilder {
39- SqlDocBuilder {
40- source : SqlFileDocource :: File ( path. as_ref ( ) . to_path_buf ( ) ) ,
41- deny : Vec :: new ( ) ,
42- }
43- }
4438
45- // later:
46- // pub fn table(&self, name: &str) -> Result<&TableDoc, DocError> { ... }
47- // pub fn table_with_schema(&self, schema: &str, name: &str) -> Result<&TableDoc, DocError> { ... }
4839}
4940
5041impl SqlDocBuilder {
51- pub fn deny < S : AsRef < str > > ( mut self , pattern : S ) -> Self {
52- self . deny . push ( pattern. as_ref ( ) . to_string ( ) ) ;
53- self
54- }
5542
56- pub fn build ( self ) -> Result < SqlDoc , DocError > {
57- match self . source {
58- SqlFileDocource :: Dir ( root) => {
59- // Use your existing directory logic here
60- }
61- SqlFileDocource :: File ( path) => {
62- // Same plumbing but for a single file
63- }
64- }
65- }
6643}
0 commit comments