Clarity.Config (Clarity v0.4.0)
View SourceCentralized configuration management for Clarity.
This module provides a single source of truth for all Clarity configuration settings, handling both global application settings and per-application extension configurations.
Global Configuration Settings
These settings are configured on the :clarity application:
Application Filtering (:introspector_applications)
Controls which applications are introspected to improve performance:
# Include only specific applications
config :clarity, :introspector_applications, [:my_app, :phoenix, :ecto]When :introspector_applications is:
- A list of atoms - Only these applications will be introspected (include mode)
nilor not set - All applications except OTP/Elixir standard libraries will be introspected
This affects which application vertices are created and which code reload events are processed.
Editor Configuration (:editor)
Controls how files are opened from Clarity. Supports both local editor commands and URL mode:
# Local editor with template variables
config :clarity, :editor, "code --goto __FILE__:__LINE__:__COLUMN__"
config :clarity, :editor, "subl __FILE__:__LINE__"
# URL mode for browser-based editing (use atom in config)
config :clarity, :editor, :url# Environment variables (use string since atoms aren't available)
export CLARITY_EDITOR="code --goto __FILE__:__LINE__:__COLUMN__"
export CLARITY_EDITOR="__URL__" # URL mode via environment variable
Configuration Priority: (highest to lowest)
config :clarity, editor: ...CLARITY_EDITORenvironment variableELIXIR_EDITORenvironment variableEDITORenvironment variable
Template Variables: (case-insensitive)
__FILE__- replaced with the file path__LINE__- replaced with the line number__COLUMN__- replaced with the column number
Security Warning
Editor configuration executes system commands based on user configuration.
Ensure configured commands are safe and trusted. For untrusted environments,
use URL mode (:url or "__URL__").
Default Perspective Lens (:default_perspective_lens)
Sets the initial lens when starting a perspective:
config :clarity, :default_perspective_lens, "debug"Cache Path (:cache_path)
Sets the directory where the graph cache is stored:
config :clarity, :cache_path, "/custom/cache/path"Defaults to Application.app_dir(:clarity, "priv/cache") if not configured.
Auto Start (:auto_start?)
Controls whether Clarity automatically starts introspection on application startup:
config :clarity, :auto_start?, falseWhen true (default), Clarity loads the cache and starts introspection immediately on startup.
When false, Clarity defers initialization until the first call to Clarity.get/1 or
Clarity.introspect(:full). This is useful for:
- Faster application startup in development
- Avoiding unnecessary introspection in test environment
- Manual control over when introspection begins
Note: When auto-start is disabled, incremental rebuild calls (triggered by code reloading) are silently ignored until initialization is triggered.
Per-Application Extension Settings
These settings are configured on individual applications:
Lensmaker Registration (:clarity_perspective_lensmakers)
Applications can register lensmakers for the perspective system:
config :my_app, :clarity_perspective_lensmakers, [
MyApp.SecurityLensmaker,
MyApp.CustomExtension
]Custom Introspector Registration (:clarity_introspectors)
Applications can register custom introspectors:
config :my_app, :clarity_introspectors, [
MyApp.MyCustomIntrospector
]Content Provider Registration (:clarity_content_providers)
Applications can register custom content providers:
config :my_app, :clarity_content_providers, [
MyApp.CustomContent,
MyApp.InteractiveContent
]
Summary
Functions
Checks if an application should be processed based on :introspector_applications configuration.
Checks if a module should be processed based on :introspector_applications configuration.
Functions
@spec should_process_app?(Application.app()) :: boolean()
Checks if an application should be processed based on :introspector_applications configuration.
Checks if a module should be processed based on :introspector_applications configuration.
Returns false if the module doesn't belong to any application.