Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# *******************************************************************************
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

# GitHub CODEOWNERS file is a simple way to automate review system on github,
# by automatically assigning owners to a pull request based on which files
# were modified. All directories should have a proper codeowner
# Syntax: https://help.github.com/articles/about-codeowners/

/plantuml/ @castler @hoe-jo @LittleHuba @limdor @ramceb
/bazel/rules/rules_score/ @castler @hoe-jo @LittleHuba @limdor @ramceb
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ copyright_checker(
"python_basics",
"starpls",
"tools",
"plantuml",

# Add other directories/files you want to check
],
Expand Down
63 changes: 63 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,69 @@ bazel_dep(name = "rules_multitool", version = "1.9.0")
bazel_dep(name = "score_rust_policies", version = "0.0.2")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2")
bazel_dep(name = "flatbuffers", version = "25.9.23")

###############################################################################
# Rust Toolchain
###############################################################################
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(edition = "2021")
use_repo(rust, "rust_toolchains")

register_toolchains("@rust_toolchains//:all")

###############################################################################
# Rust Crates (crate_universe)
###############################################################################
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
crate.spec(
package = "pest",
version = "2.8.3",
)
crate.spec(
package = "pest_derive",
version = "2.8.3",
)
crate.spec(
features = ["derive"],
package = "clap",
version = "4.5.0",
)
crate.spec(
package = "thiserror",
version = "1.0.44",
)
crate.spec(
package = "log",
version = "0.4",
)
crate.spec(
package = "env_logger",
version = "0.10",
)
crate.spec(
features = ["derive"],
package = "serde",
version = "1.0",
)
crate.spec(
package = "serde_json",
version = "1.0",
)
crate.spec(
package = "serde_yaml",
version = "0.9",
)
crate.spec(
package = "once_cell",
version = "1.19",
)
crate.spec(
package = "flatbuffers",
version = "25.9.23",
)
crate.from_specs()
use_repo(crate, "crates")

###############################################################################
# Python Toolchain
Expand Down
10 changes: 10 additions & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,13 @@ SPDX-License-Identifier = "Apache-2.0"
path = ["dash/org.eclipse.dash.licenses-1.1.0.jar"]
SPDX-FileCopyrightText = "2020 Eclipse Foundation"
SPDX-License-Identifier = "EPL-2.0"

[[annotations]]
path = ["plantuml/**/*.json"]
SPDX-FileCopyrightText = "Copyright (c) 2026 Contributors to the Eclipse Foundation"
SPDX-License-Identifier = "Apache-2.0"

[[annotations]]
path = ["plantuml/**/*.svg"]
SPDX-FileCopyrightText = "Copyright (c) 2026 Contributors to the Eclipse Foundation"
SPDX-License-Identifier = "Apache-2.0"
17 changes: 17 additions & 0 deletions plantuml/parser/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
alias(
name = "parser",
actual = "//plantuml/parser/puml_cli:puml_cli",
visibility = ["//visibility:public"],
)
89 changes: 89 additions & 0 deletions plantuml/parser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!--
Copyright (c) 2026 Contributors to the Eclipse Foundation

See the NOTICE file(s) distributed with this work for additional
information regarding copyright ownership.

This program and the accompanying materials are made available under the
terms of the Apache License Version 2.0 which is available at
https://www.apache.org/licenses/LICENSE-2.0

SPDX-License-Identifier: Apache-2.0
-->

# PlantUML Parser

The PlantUML Parser is a multi-file parser that processes PlantUML diagram files and converts them into structured data for traceability and architectural analysis. It handles preprocessing of include directives, supports multiple diagram types (Class, Sequence, Component), and generates FlatBuffers binary output for further downstream processing.

---

## What It Does

The parser takes `.puml` source files as input and produces:

- **FlatBuffers binary** (`.fbs.bin`) — primary structured output for downstream consumers
- **LOBSTER traceability JSON** (`.lobster`) — for component diagrams, enables traceability linking via the LOBSTER toolchain
- **Debug JSON** — raw and resolved ASTs when `--log-level debug` or higher is set


Rust-based parser that produces an AST for the following PlantUML diagram types:

- Class Diagram
- Sequence Diagram
- Component Diagram

Outputs are `.fbs.bin` FlatBuffers binaries (diagram AST) and optionally `.lobster`
traceability files (for component diagrams).

## Usage

### Build:
```
bazel build //tools/plantuml/parser
```

### Run:
```
bazel run //tools/plantuml/parser -- [OPTIONS]
```

Options:

| Option | Description | Default |
|--------|-------------|---------|
| `--file <FILE>...` | One or more PUML files to parse (repeatable) | — |
| `--folders <DIR>` | Folder containing PUML files | — |
| `--log-level <error\|warn\|info\|debug\|trace>` | Logging verbosity | `warn` |
| `--diagram-type <component\|class\|sequence\|none>` | Diagram type hint | `none` |
| `--fbs-output-dir <DIR>` | Output directory for `.fbs.bin` FlatBuffers files | none (no output) |
| `--lobster-output-dir <DIR>` | Output directory for `.lobster` traceability files | none (no output) |

At least one of `--file` or `--folders` is required.

Example:
```
bazel run //tools/plantuml/parser -- \
--file $PWD/tools/plantuml/parser/integration_test/component_diagram/simple_component.puml \
--log-level trace \
--diagram-type component \
--fbs-output-dir $PWD/tools/plantuml/parser
```
## Architecture

The parser is organized into separate crate modules per diagram type:

```
puml_parser/
├── src/
│ ├── class_diagram/ # Class diagram parser (pest grammar → AST)
│ ├── component_diagram/ # Component diagram parser
│ ├── sequence_diagram/ # Sequence diagram parser (two-stage: syntax → logic)
│ └── ... # Shared utilities (parser_core, puml_utils)
puml_cli/ # CLI entry point (clap-based)
```

Each diagram parser uses [pest](https://pest.rs/) PEG grammars to tokenize PlantUML input,
then builds a typed AST. The CLI (`puml_cli`) dispatches to the appropriate parser based on
`--diagram-type` or auto-detection.

For the detailed design and users Guide, see [README](docs/README.md).
Loading
Loading