Extracted from qwan-tracker
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
defmodule Microprints do
|
||||
@moduledoc """
|
||||
Microprints — compact visual representations of source code files.
|
||||
|
||||
A microprint is a compact visual fingerprint where each line of code becomes
|
||||
a colored stripe based on its syntax elements (function definitions, strings,
|
||||
comments, etc.).
|
||||
|
||||
## Installation
|
||||
|
||||
Add to your `mix.exs`:
|
||||
|
||||
```elixir
|
||||
def deps do
|
||||
[
|
||||
{:microprints, "~> 0.1", only: :dev}
|
||||
]
|
||||
end
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Generate a microprint
|
||||
|
||||
Microprints.generate("path/to/file.ex")
|
||||
# => {:ok, %{lines: [...], line_count: 42}}
|
||||
|
||||
### Get color for a syntax type
|
||||
|
||||
Microprints.color_for(:function_def)
|
||||
# => "#EF4444"
|
||||
|
||||
### Get the color legend
|
||||
|
||||
Microprints.color_legend()
|
||||
# => [{"Function", "#EF4444"}, {"Module", "#EC4899"}, ...]
|
||||
|
||||
## Components
|
||||
|
||||
The `MicroprintComponent` module provides Phoenix LiveView components for
|
||||
rendering microprint visualizations as SVG.
|
||||
|
||||
The `MicroprintCache` module provides ETS-based caching with LiveReload
|
||||
support for automatic cache invalidation.
|
||||
|
||||
## Examples
|
||||
|
||||
See the test suite for more usage examples.
|
||||
"""
|
||||
|
||||
alias Microprints.Microprint
|
||||
|
||||
@doc """
|
||||
Delegates to `Microprint.generate/1`.
|
||||
"""
|
||||
@spec generate(String.t()) :: {:ok, Microprint.microprint()} | {:error, term()}
|
||||
def generate(path), do: Microprint.generate(path)
|
||||
|
||||
@doc """
|
||||
Delegates to `Microprint.color_for/1`.
|
||||
"""
|
||||
@spec color_for(atom()) :: String.t()
|
||||
def color_for(type), do: Microprint.color_for(type)
|
||||
|
||||
@doc """
|
||||
Delegates to `Microprint.color_legend/0`.
|
||||
"""
|
||||
@spec color_legend() :: [{String.t(), String.t()}]
|
||||
def color_legend(), do: Microprint.color_legend()
|
||||
end
|
||||
Reference in New Issue
Block a user