Skip to content

Commit 725d590

Browse files
committed
added docs skeleton
1 parent ee6207c commit 725d590

2 files changed

Lines changed: 39 additions & 3 deletions

File tree

src/ast.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ impl ParsedSqlFileSet {
8383

8484
#[cfg(test)]
8585
mod tests {
86-
use super::*;
8786
use std::{env, fs};
87+
88+
use super::*;
8889
use crate::files::{SqlFile, SqlFileSet};
8990

9091
#[test]

src/docs.rs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ pub struct ColumnDoc {
88
name: String,
99
doc: Option<String>,
1010
}
11+
impl ColumnDoc {
12+
/// Getter for the `name` field
13+
#[must_use]
14+
pub fn name(&self) -> &str {
15+
&self.name
16+
}
17+
18+
/// Getter for the field `doc`
19+
#[must_use]
20+
pub fn doc(&self) -> &Option<String> {
21+
&self.doc
22+
}
23+
}
1124

1225
/// Structure for containing the `name` of the `Table`, an [`Option`] for the
1326
/// comment as a [`String`], and a `Vec` of [`ColumnDoc`] contained in the table
@@ -17,6 +30,27 @@ pub struct TableDoc {
1730
columns: Vec<ColumnDoc>,
1831
}
1932

33+
impl TableDoc {
34+
35+
/// Getter for the `name` field
36+
#[must_use]
37+
pub fn name(&self) -> &str {
38+
&self.name
39+
}
40+
41+
/// Getter for the `doc` field
42+
#[must_use]
43+
pub fn doc(&self) -> &Option<String> {
44+
&self.doc
45+
}
46+
47+
/// Getter for the `columns` field
48+
#[must_use]
49+
pub fn columns(&self) -> &[ColumnDoc] {
50+
&self.columns
51+
}
52+
}
53+
2054
/// Structure for containing the docs for every `Table` in an `.sql` file as a
2155
/// `Vec` of [`TableDoc`]
2256
pub struct SqlDocs {
@@ -26,11 +60,12 @@ pub struct SqlDocs {
2660
impl SqlDocs {
2761
/// Create a new instance of [`SqlDocs`]
2862
#[must_use]
29-
pub fn new(tables: Vec<TableDoc>) -> Self {
63+
pub const fn new(tables: Vec<TableDoc>) -> Self {
3064
Self { tables }
3165
}
3266

33-
/// Builds documentation for sql file by attaching leading comments to tables and columns
67+
/// Builds documentation for sql file by attaching leading comments to
68+
/// tables and columns
3469
#[must_use]
3570
pub fn from_parsed_file(file: &ParsedSqlFile, comments: &Comments) -> Self {
3671
todo!()

0 commit comments

Comments
 (0)