| Crates.io | pinout |
| lib.rs | pinout |
| version | 0.1.0 |
| created_at | 2025-09-29 13:46:11.306586+00 |
| updated_at | 2025-09-29 13:46:11.306586+00 |
| description | A Rust library and command-line tool for generating beautiful pinout diagrams in SVG format from CSV descriptions |
| homepage | https://github.com/orhanbalci/pinout |
| repository | https://github.com/orhanbalci/pinout |
| max_upload_size | |
| id | 1859555 |
| size | 851,369 |
A Rust library and command-line tool for generating beautiful pinout diagrams in SVG format from CSV descriptions. This tool is designed specifically for creating graphical pinout datasheets for microcontrollers, development boards, and electronic components.
git clone https://github.com/orhanbalci/pinout
cd pinout
cargo build --release
Add this to your Cargo.toml:
[dependencies]
pinout = "0.1.0"
my_pinout.csv):LABELS,DEFAULT,TYPE,GROUP,Pin,Function
BORDER COLOR,black
FILL COLOR,white,lightblue,yellow
FONT,Arial
FONT SIZE,10
TYPE,IO,blue,1
TYPE,Input,green,1
TYPE,Output,red,1
GROUP,IO,lightblue,0.5
GROUP,Input,lightgreen,0.5
GROUP,Output,lightyellow,0.5
PAGE,A4-L
DPI,150
DRAW
ANCHOR,50,100
PINSET,LEFT,PACKED,CENTER,CENTER,25,60,80,10,5,2
PIN,1,VCC,Output,Output,3.3V Power
PIN,2,GND,Output,Output,Ground
PIN,3,D2,IO,IO,Digital Pin
PIN,4,A0,Input,Input,Analog Input
cargo run --example main my_pinout.csv my_pinout.svg
my_pinout.svg in any web browser or vector graphics editor.Generate an SVG pinout diagram from a CSV file:
cargo run --example main input.csv output.svg
Options:
--overwrite / -o: Overwrite existing SVG files--help / -h: Show help informationIf no output file is specified, the tool will create an SVG file with the same name as the input CSV file.
use pinout::parser::csv::parse_csv_file;
use pinout::renderer::svg::generate_svg;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Parse CSV file into commands
let commands = parse_csv_file("pinout.csv")?;
// Generate SVG from commands
generate_svg(&commands, "output.svg")?;
Ok(())
}
The CSV format uses a two-phase approach for defining pinout diagrams:
Defines themes, styling, and configuration that applies to the entire diagram.
Contains the actual drawing commands. Triggered by the DRAW command.
# Setup Phase - Define themes and styles
LABELS,DEFAULT,TYPE,GROUP,Pin Name,Function 1,Function 2
BORDER COLOR,black
FILL COLOR,white,white,white,lightblue,yellow
FONT,Arial
FONT SIZE,12
# Define pin types and groups
TYPE,IO,blue,1
TYPE,Input,green,1
TYPE,Output,red,1
GROUP,IO,lightblue,0.5
GROUP,Input,lightgreen,0.5
GROUP,Output,lightyellow,0.5
# Draw Phase - Start rendering
DRAW
ANCHOR,50,100
PINSET,LEFT,PACKED,CENTER,CENTER,20,80,100,10,5,2
PIN,1,VDD,Output,,3.3V Power
PIN,2,GND,Output,,Ground
# ... more pins
LABELS - Define pin labels and column structureBORDER COLOR - Set border colors for different pin typesFILL COLOR - Set fill colors for pin boxesFONT - Define font familiesFONT SIZE - Set font sizesFONT COLOR - Set text colorsOPACITY - Set transparency levelsBORDER WIDTH - Border line thicknessBORDER OPACITY - Border transparencyTYPE - Define pin types (IO, Input, Output)WIRE - Define wire types and colorsGROUP - Define pin groups with custom stylingBOX - Define box themes and dimensionsPAGE - Set page size ("A3-L", "A4-P", etc.)DPI - Set resolution for renderingANCHOR - Set drawing origin pointPINSET - Start a new set of pins with layout parametersPIN - Add individual pins with labels and propertiesPINTEXT - Add text labels to pinsIMAGE - Embed raster imagesICON - Add SVG iconsBOX - Draw styled boxesMESSAGE - Add text messagesTEXT - Add styled text elementsThe repository includes example CSV files demonstrating different features:
See ESP32-MAXIO.csv for a complete example showing:
# Define pin types with colors
TYPE,IO,black,1
TYPE,Input,blue,1
TYPE,Output,red,1
# Define groups with custom styling
GROUP,Power,black,0
GROUP,Analog,green,0.5
# Use in pin definitions
PIN,1,VCC,Output,Power,3.3V Supply
PIN,2,A0,Input,Analog,Analog Input 0
Command - Enumeration of all supported CSV commandsPhase - Setup or Draw phase indicatorPinType - IO, Input, Output pin classificationsWireType - Digital, PWM, Analog wire typesSide - Left, Right, Top, Bottom positioningparse_csv_file(path) - Parse CSV file into command listDocument - Higher-level document representation with validationgenerate_svg(commands, output_path) - Render commands to SVG fileSvgRenderer - Low-level SVG rendering engine with theming supportThe library provides comprehensive error handling:
ParserError - CSV parsing and validation errorsRenderError - SVG generation and file I/O errorsgit checkout -b feature/amazing-feature)cargo test)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License.
svg crate for vector graphics generationcsv crateimage crate