Expand description
AST types for nginx configuration files.
This module defines the tree structure produced by crate::parse_string and
crate::parse_config. The AST preserves whitespace, comments, and blank lines
so that source code can be reconstructed via Config::to_source — this enables
autofix functionality without destroying formatting.
§AST Structure
Config
└─ items: Vec<ConfigItem>
├─ Directive
│ ├─ name ("server", "listen", …)
│ ├─ args (Vec<Argument>)
│ └─ block (Option<Block>)
│ └─ items (Vec<ConfigItem>, recursive)
├─ Comment ("# …")
└─ BlankLine§Example
use nginx_lint_parser::parse_string;
let config = parse_string("worker_processes auto;").unwrap();
let dir = config.directives().next().unwrap();
assert_eq!(dir.name, "worker_processes");
assert_eq!(dir.first_arg(), Some("auto"));Structs§
- AllDirectives
- Depth-first iterator over all directives in a config, recursing into blocks.
- Argument
- A single argument to a directive.
- Blank
Line - A blank line (may contain only whitespace)
- Block
- A brace-delimited block (
{ … }). - Comment
- A comment (# …)
- Config
- Root node of a parsed nginx configuration file.
- Directive
- A directive — either a simple directive (
listen 80;) or a block directive (server { … }). - Position
- A position (line, column, byte offset) in the source text.
- Span
- A half-open source range defined by a start and end
Position.
Enums§
- Argument
Value - The kind and value of a directive argument.
- Config
Item - An item in the configuration (directive, comment, or blank line).