1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// SPDX-FileCopyrightText: Copyright 2026 Puneet Matharu
//
// SPDX-License-Identifier: MIT OR Apache-2.0
//! `cmakefmt` is a fast, configurable CMake formatter.
//!
//! # Quick start
//!
//! Format a CMake source string with the default configuration:
//!
//! ```
//! use cmakefmt::{format_source, Config};
//!
//! let cmake = "CMAKE_MINIMUM_REQUIRED(VERSION 3.20)\n";
//! let formatted = format_source(cmake, &Config::default()).unwrap();
//! assert_eq!(formatted, "cmake_minimum_required(VERSION 3.20)\n");
//! ```
//!
//! To customise formatting, modify [`Config`] fields before passing it in:
//!
//! ```
//! use cmakefmt::{format_source, Config, CaseStyle};
//!
//! let mut config = Config::default();
//! config.line_width = 100;
//! config.command_case = CaseStyle::Upper;
//!
//! let cmake = "target_link_libraries(mylib PUBLIC dep1)\n";
//! let formatted = format_source(cmake, &config).unwrap();
//! assert_eq!(formatted, "TARGET_LINK_LIBRARIES(mylib PUBLIC dep1)\n");
//! ```
//!
//! # Organisation
//!
//! | Module | Purpose |
//! |--------|---------|
//! | [`config`] | Runtime configuration types and config-file loading |
//! | [`error`] | Error and result types |
//! | [`formatter`] | Source-to-source formatting pipeline |
//! | [`parser`] | CMake parser and AST definitions |
//! | [`spec`] | Built-in and user-extensible command registry |
//!
//! # Entry points (re-exported at the crate root)
//!
//! | Item | Purpose |
//! |------|---------|
//! | [`format_source`] / [`format_source_with_registry`] | Format a source string |
//! | [`format_parsed_file`] | Format an already-parsed [`parser::ast::File`] |
//! | [`format_source_with_debug`] / [`format_source_with_registry_debug`] | Format + collect debug decision log |
//! | [`Config`], [`CommandConfig`], [`PerCommandConfig`] | Runtime configuration |
//! | [`CaseStyle`], [`DangleAlign`], [`LineEnding`], [`FractionalTabPolicy`] | Config enums |
//! | [`CommandRegistry`] | Built-in + user-override command specs |
//! | [`Error`], [`Result`], [`IoResultExt`] | Crate-level error types and the path-context adapter for `io::Result` |
//!
//! # Features
//!
//! | Feature | Default | Purpose |
//! |---------|---------|---------|
//! | `cli` | ✔ | Enables the `cmakefmt` binary plus CLI-oriented public API (`convert_legacy_config_files`, `default_config_template_for`, `generate_json_schema`, `render_effective_config`, `DumpConfigFormat`). Implies `lsp`. |
//! | `lsp` | ✔ (via `cli`) | Compiles the `lsp::run` Language Server Protocol entry point. |
//!
//! The crate also has a separate target path: when compiled for
//! `wasm32`, `wasm::format` and friends are exposed via
//! `wasm-bindgen` for the browser playground.
/// Runtime formatter configuration and config-file loading.
/// Shared error types used across parsing, config loading, and formatting.
/// Source-to-source formatting pipeline.
/// CMake parser and AST definitions.
/// Semantic-level normalisation (strip comments, line endings,
/// keyword casing) used by `--verify` and the idempotency tests.
/// Built-in and user-extensible command specification registry.
// Recursive CMake file-discovery helpers used by the CLI. Not part of the
// library embedding API; hidden from generated documentation.
// AST / parse-tree dumping helpers used by the `dump` subcommand.
// LSP server — only compiled when the `lsp` feature is enabled.
// WASM entry point — only compiled for wasm32 targets.
// ── Configuration ────────────────────────────────────────────────────────────
pub use ;
pub use default_config_template;
pub use ;
// ── Errors ───────────────────────────────────────────────────────────────────
pub use ;
// ── Formatting ───────────────────────────────────────────────────────────────
pub use ;
// ── Registry ─────────────────────────────────────────────────────────────────
pub use CommandRegistry;