Skip to content

Commit 379ade4

Browse files
chore(docs): initial commit (#204)
* chore(docs): initial commit * feat(docs): poc for codegen * docs: troubleshooting * feat(docs): finish codegen * fix: docs * fix: diagnostics in docs * fix: docs * fix: docs * fix: lint * feat: integrate docs codegen into ci * Update docs/codegen/src/utils.rs Co-authored-by: Julian Domke <68325451+juleswritescode@users.noreply.github.com> * chore: merge main * chore: lint fix * chore: lint fix --------- Co-authored-by: Julian Domke <68325451+juleswritescode@users.noreply.github.com>
1 parent 6933732 commit 379ade4

File tree

35 files changed

+1486
-38
lines changed

35 files changed

+1486
-38
lines changed

.github/workflows/pull_request.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ jobs:
181181
run: cargo run -p xtask_codegen -- analyser
182182
- name: Run the configuration codegen
183183
run: cargo run -p xtask_codegen -- configuration
184+
- name: Run the docs codegen
185+
run: cargo run -p docs_codegen
184186
- name: Check for git diff
185187
run: |
186188
if [[ $(git status --porcelain) ]]; then

Cargo.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["crates/*", "lib/*", "xtask/codegen", "xtask/rules_check"]
2+
members = ["crates/*", "lib/*", "xtask/codegen", "xtask/rules_check", "docs/codegen"]
33
resolver = "2"
44

55
[workspace.package]
@@ -28,6 +28,7 @@ pg_query = "6.0.0"
2828
proc-macro2 = "1.0.66"
2929
quote = "1.0.33"
3030
rayon = "1.10.0"
31+
regex = "1.11.1"
3132
rustc-hash = "2.0.0"
3233
schemars = { version = "0.8.21", features = ["indexmap2", "smallvec"] }
3334
serde = "1.0.195"
@@ -80,6 +81,8 @@ pglt_workspace = { path = "./crates/pglt_workspace", version = "0.0
8081

8182
pglt_test_macros = { path = "./crates/pglt_test_macros" }
8283
pglt_test_utils = { path = "./crates/pglt_test_utils" }
83-
# parser = { path = "./crates/parser", version = "0.0.0" }
84-
# sql_parser = { path = "./crates/sql_parser", version = "0.0.0" }
85-
# sql_parser_codegen = { path = "./crates/sql_parser_codegen", version = "0.0.0" }
84+
85+
docs_codegen = { path = "./docs/codegen", version = "0.0.0" }
86+
87+
[profile.dev.package]
88+
insta.opt-level = 3

crates/pglt_analyser/tests/rules_tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn rule_test(full_path: &'static str, _: &str, _: &str) {
2323
};
2424

2525
let query =
26-
read_to_string(full_path).expect(format!("Failed to read file: {} ", full_path).as_str());
26+
read_to_string(full_path).unwrap_or_else(|_| panic!("Failed to read file: {} ", full_path));
2727

2828
let ast = pglt_query_ext::parse(&query).expect("failed to parse SQL");
2929
let options = AnalyserOptions::default();
@@ -51,7 +51,6 @@ fn rule_test(full_path: &'static str, _: &str, _: &str) {
5151
fn parse_test_path(path: &Path) -> (String, String, String) {
5252
let mut comps: Vec<&str> = path
5353
.components()
54-
.into_iter()
5554
.map(|c| c.as_os_str().to_str().unwrap())
5655
.collect();
5756

crates/pglt_cli/src/cli_options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub struct CliOptions {
4848
#[bpaf(long("no-errors-on-unmatched"), switch)]
4949
pub no_errors_on_unmatched: bool,
5050

51-
/// Tell PGLSP to exit with an error code if some diagnostics emit warnings.
51+
/// Tell PgLT to exit with an error code if some diagnostics emit warnings.
5252
#[bpaf(long("error-on-warnings"), switch)]
5353
pub error_on_warnings: bool,
5454

@@ -86,7 +86,7 @@ pub struct CliOptions {
8686
fallback(Severity::default()),
8787
display_fallback
8888
)]
89-
/// The level of diagnostics to show. In order, from the lowest to the most important: info, warn, error. Passing `--diagnostic-level=error` will cause PGLSP to print only diagnostics that contain only errors.
89+
/// The level of diagnostics to show. In order, from the lowest to the most important: info, warn, error. Passing `--diagnostic-level=error` will cause PgLT to print only diagnostics that contain only errors.
9090
pub diagnostic_level: Severity,
9191
}
9292

crates/pglt_cli/src/commands/daemon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ fn setup_tracing_subscriber(log_path: Option<PathBuf>, log_file_name_prefix: Opt
230230
}
231231

232232
pub fn default_pglt_log_path() -> PathBuf {
233-
match env::var_os("PGLSP_LOG_PATH") {
233+
match env::var_os("PGLT_LOG_PATH") {
234234
Some(directory) => PathBuf::from(directory),
235235
None => pglt_fs::ensure_cache_dir().join("pglt-logs"),
236236
}

crates/pglt_cli/src/commands/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub enum PgltCommand {
7272
Start {
7373
/// Allows to change the prefix applied to the file name of the logs.
7474
#[bpaf(
75-
env("PGLSP_LOG_PREFIX_NAME"),
75+
env("PGLT_LOG_PREFIX_NAME"),
7676
long("log-prefix-name"),
7777
argument("STRING"),
7878
hide_usage,
@@ -83,7 +83,7 @@ pub enum PgltCommand {
8383

8484
/// Allows to change the folder where logs are stored.
8585
#[bpaf(
86-
env("PGLSP_LOG_PATH"),
86+
env("PGLT_LOG_PATH"),
8787
long("log-path"),
8888
argument("PATH"),
8989
hide_usage,
@@ -92,7 +92,7 @@ pub enum PgltCommand {
9292
log_path: PathBuf,
9393
/// Allows to set a custom file path to the configuration file,
9494
/// or a custom directory path to find `pglt.toml`
95-
#[bpaf(env("PGLSP_LOG_PREFIX_NAME"), long("config-path"), argument("PATH"))]
95+
#[bpaf(env("PGLT_LOG_PREFIX_NAME"), long("config-path"), argument("PATH"))]
9696
config_path: Option<PathBuf>,
9797
},
9898

@@ -109,7 +109,7 @@ pub enum PgltCommand {
109109
LspProxy {
110110
/// Allows to change the prefix applied to the file name of the logs.
111111
#[bpaf(
112-
env("PGLSP_LOG_PREFIX_NAME"),
112+
env("PGLT_LOG_PREFIX_NAME"),
113113
long("log-prefix-name"),
114114
argument("STRING"),
115115
hide_usage,
@@ -119,7 +119,7 @@ pub enum PgltCommand {
119119
log_prefix_name: String,
120120
/// Allows to change the folder where logs are stored.
121121
#[bpaf(
122-
env("PGLSP_LOG_PATH"),
122+
env("PGLT_LOG_PATH"),
123123
long("log-path"),
124124
argument("PATH"),
125125
hide_usage,
@@ -128,7 +128,7 @@ pub enum PgltCommand {
128128
log_path: PathBuf,
129129
/// Allows to set a custom file path to the configuration file,
130130
/// or a custom directory path to find `pglt.toml`
131-
#[bpaf(env("PGLSP_CONFIG_PATH"), long("config-path"), argument("PATH"))]
131+
#[bpaf(env("PGLT_CONFIG_PATH"), long("config-path"), argument("PATH"))]
132132
config_path: Option<PathBuf>,
133133
/// Bogus argument to make the command work with vscode-languageclient
134134
#[bpaf(long("stdio"), hide, hide_usage, switch)]
@@ -143,7 +143,7 @@ pub enum PgltCommand {
143143
RunServer {
144144
/// Allows to change the prefix applied to the file name of the logs.
145145
#[bpaf(
146-
env("PGLSP_LOG_PREFIX_NAME"),
146+
env("PGLT_LOG_PREFIX_NAME"),
147147
long("log-prefix-name"),
148148
argument("STRING"),
149149
hide_usage,
@@ -153,7 +153,7 @@ pub enum PgltCommand {
153153
log_prefix_name: String,
154154
/// Allows to change the folder where logs are stored.
155155
#[bpaf(
156-
env("PGLSP_LOG_PATH"),
156+
env("PGLT_LOG_PATH"),
157157
long("log-path"),
158158
argument("PATH"),
159159
hide_usage,
@@ -165,7 +165,7 @@ pub enum PgltCommand {
165165
stop_on_disconnect: bool,
166166
/// Allows to set a custom file path to the configuration file,
167167
/// or a custom directory path to find `pglt.toml`
168-
#[bpaf(env("PGLSP_CONFIG_PATH"), long("config-path"), argument("PATH"))]
168+
#[bpaf(env("PGLT_CONFIG_PATH"), long("config-path"), argument("PATH"))]
169169
config_path: Option<PathBuf>,
170170
},
171171
#[bpaf(command("__print_socket"), hide)]

crates/pglt_cli/src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn command_name() -> String {
1515
.unwrap_or_else(|| String::from("pglt"))
1616
}
1717

18-
/// A diagnostic that is emitted when running PGLSP via CLI.
18+
/// A diagnostic that is emitted when running PgLT via CLI.
1919
///
2020
/// When displaying the diagnostic,
2121
#[derive(Debug, Diagnostic)]

crates/pglt_cli/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub use panic::setup_panic_handler;
3232
pub use reporter::{DiagnosticsPayload, Reporter, ReporterVisitor, TraversalSummary};
3333
pub use service::{open_transport, SocketTransport};
3434

35-
pub(crate) const VERSION: &str = match option_env!("PGLSP_VERSION") {
35+
pub(crate) const VERSION: &str = match option_env!("PGLT_VERSION") {
3636
Some(version) => version,
3737
None => env!("CARGO_PKG_VERSION"),
3838
};

crates/pglt_configuration/src/analyser/linter/rules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl std::str::FromStr for RuleGroup {
4646
#[cfg_attr(feature = "schema", derive(JsonSchema))]
4747
#[serde(rename_all = "camelCase", deny_unknown_fields)]
4848
pub struct Rules {
49-
#[doc = r" It enables the lint rules recommended by PGLSP. `true` by default."]
49+
#[doc = r" It enables the lint rules recommended by PgLT. `true` by default."]
5050
#[serde(skip_serializing_if = "Option::is_none")]
5151
pub recommended: Option<bool>,
5252
#[doc = r" It enables ALL rules. The rules that belong to `nursery` won't be enabled."]

0 commit comments

Comments
 (0)