# igormaj/syntaxcoloring architecture

> Architecture diagram of the GitHub repository igormaj/syntaxcoloring, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/igormaj/syntaxcoloring
- Repository: https://github.com/igormaj/syntaxcoloring

## Overview

##### Project type and purpose
- This is an open-source Python CLI tool and library (“gen_coloring”) whose job is to generate syntax-coloring artifacts (TextMate grammars, VSCode extensions, etc.) from grammar definitions.
- Key indicators:
– Top-level scripts: `generate_vsc_plugin.py` and `gen_coloring/coloring_entry_point.py` (CLI entry points)
– Directories named `grammar`, `templates`, `static` (scaffolding for output)
– Generator modules: `plugin_generator.py`, `textmate_generator.py`

##### File structure
- Top-level files:
– `setup.py`: packaging and entry-point definition
– `generate_vsc_plugin.py`: standalone script to scaffold a VSCode plugin
- Main package directory: `gen_coloring/`
– `coloring_entry_point.py`: CLI front door, parses args, directs workflow
– `input/command_arguments.py`: handles CLI args parsing
– `obj_preprocessors.py`: transforms input models or ASTs before generation
– `grammar/`: `.tx` grammar definitions (for textX or custom parser)
– `generators/`: two main generators:
- `plugin_generator.py` (builds full VSCode extension from templates + static assets)
- `textmate_generator.py` (generates TextMate grammar JSON)
– `templates/`: Jinja2 and JSON templates for statements, modules, etc.
– `static/`: boilerplate files for VSCode extension (package.json, language-configuration.json, README, etc.)
– `utils.py`: shared helper routines

##### README (empty in this case)
- No further text, so we rely entirely on file naming and structure.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CLI Layer
    subgraph "CLI Layer"
        A["Generate VSCode Plugin Script"]:::pythonModule
        B["CLI Entry Point"]:::pythonModule
    end

    %% Core Engine
    subgraph "Core Engine"
        C["Argument Parser"]:::pythonModule
        D["Object Preprocessor"]:::pythonModule
        K["Utility Helpers"]:::pythonModule
    end

    %% Grammar Definitions
    E["Grammar Definitions"]:::directory

    %% Generators
    subgraph "Generators"
        F["TextMate Grammar Generator"]:::pythonModule
        G["VSCode Plugin Generator"]:::pythonModule
    end

    %% Resources
    H["Templates"]:::template
    I["Static Assets"]:::static

    %% Output & Packaging
    J["Output Artifacts"]:::data
    L["Packaging (setup.py)"]:::pythonModule
    M["Example Inputs/Outputs"]:::directory

    %% External Dependencies
    subgraph "External Dependencies"
        X["textX Parser"]:::external
        Y["VSCode Marketplace Format"]:::external
    end

    %% Flow
    A -->|"invoke"| B
    B -->|"parse args"| C
    C -->|"build model"| D
    D -->|"preprocess AST"| E
    E -->|"load grammars"| X
    D --> F
    D --> G
    F -->|"use templates"| H
    G -->|"use templates & static"| H
    G -->|"use static assets"| I
    F --> J
    G --> J
    B --> L
    B --> K
    J --> Y
    B --> M

    %% Click Events
    click A "https://github.com/igormaj/syntaxcoloring/blob/master/generate_vsc_plugin.py"
    click B "https://github.com/igormaj/syntaxcoloring/blob/master/gen_coloring/coloring_entry_point.py"
    click C "https://github.com/igormaj/syntaxcoloring/blob/master/gen_coloring/input/command_arguments.py"
    click D "https://github.com/igormaj/syntaxcoloring/blob/master/gen_coloring/obj_preprocessors.py"
    click E "https://github.com/igormaj/syntaxcoloring/tree/master/gen_coloring/grammar/"
    click F "https://github.com/igormaj/syntaxcoloring/blob/master/gen_coloring/generators/textmate_generator.py"
    click G "https://github.com/igormaj/syntaxcoloring/blob/master/gen_coloring/generators/plugin_generator.py"
    click H "https://github.com/igormaj/syntaxcoloring/tree/master/gen_coloring/templates/"
    click I "https://github.com/igormaj/syntaxcoloring/tree/master/gen_coloring/static/"
    click K "https://github.com/igormaj/syntaxcoloring/blob/master/gen_coloring/utils.py"
    click L "https://github.com/igormaj/syntaxcoloring/blob/master/setup.py"
    click M "https://github.com/igormaj/syntaxcoloring/tree/master/examples/"

    %% Styles
    classDef pythonModule fill:#D6EAF8,stroke:#1B4F72,color:#1B2631;
    classDef directory fill:#D5F5E3,stroke:#196F3D,color:#1D8348;
    classDef template fill:#E8F8F5,stroke:#1ABC9C,color:#117A65;
    classDef static fill:#FEF9E7,stroke:#B7950B,color:#7D6608;
    classDef data fill:#FDEDEC,stroke:#C0392B,color:#7B241C;
    classDef external fill:#F4ECF7,stroke:#6C3483,color:#4A235A;
```
