You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assert_eq!(docs.tables().first().expect("hardcoded value").columns().first().expect("hardcoded value").doc(), Some("Primary key for each user"));
61
+
// Or extract recursively from a directory
62
+
// let docs = SqlDoc::from_dir(&base).build()?;
63
+
64
+
// Retrieve a specific table
65
+
letusers=docs.table("users")?;
66
+
67
+
// Table name
68
+
assert_eq!(users.name(), "users");
69
+
// Optional table-level documentation
70
+
assert_eq!(users.doc(), Some("Table storing user accounts"));
71
+
// Path to the source file
72
+
assert_eq!(users.path(), &Some(example));
73
+
64
74
let_=fs::remove_dir_all(&base);
65
75
Ok(())
66
76
}
67
77
```
68
-
## Use cases
78
+
## Primary Interface (Main API)
79
+
80
+
These are the primary entry points most users will interact with:
81
+
82
+
*[`SqlDoc::from_path`](https://docs.rs/sql-docs/latest/sql_docs/sql_doc/struct.SqlDoc.html#method.from_path) Build documentation from a single `.sql` file.
83
+
*[`SqlDoc::from_dir`](https://docs.rs/sql-docs/latest/sql_docs/sql_doc/struct.SqlDoc.html#method.from_dir) Recursively scan a directory for `.sql` files and build documentation.
84
+
*[`SqlDocBuilder::build`](https://docs.rs/sql-docs/latest/sql_docs/sql_doc/struct.SqlDocBuilder.html#method.build) Finalize the builder and produce a [`SqlDoc`].
85
+
*[`SqlDocBuilder::deny`](https://docs.rs/sql-docs/latest/sql_docs/sql_doc/struct.SqlDocBuilder.html#method.deny) Exclude specific files by full path.
86
+
*[`SqlDocBuilder::flatten_multiline`](https://docs.rs/sql-docs/latest/sql_docs/sql_doc/struct.SqlDocBuilder.html#method.flatten_multiline) Flatten multiline comments into a single line.
87
+
88
+
## Use Cases
69
89
70
90
This crate is designed for generating documentation from SQL schemas by attaching comments to:
71
-
- Tables
72
-
- Columns
73
91
74
-
using only comments that immediately precede the items they describe.
92
+
* Tables
93
+
* Columns
94
+
95
+
using **only comments that immediately precede** the items they describe.
96
+
97
+
This makes it well-suited for:
98
+
99
+
* Auto-generating Markdown or HTML documentation
100
+
* Building database schema explorers
101
+
* Enforcing documentation rules in CI
102
+
* Static analysis of SQL schemas
103
+
104
+
## Design Notes
75
105
76
-
This makes it ideal for:
77
-
- Auto-generating Markdown or HTML documentation
78
-
- Building database schema explorers
79
-
- Enforcing documentation rules in CI
106
+
* Inline and interstitial comments are intentionally ignored.
107
+
* Comment attachment is line-based and deterministic.
0 commit comments