Pure helpers for the Shadix generator tooling.
Provides namespace rewriting, default namespace derivation, and default target directory derivation. Kept separate from Mix tasks so it is unit-testable without invoking Mix machinery.
Summary
Functions
Returns the default target directory for a given namespace.
Returns the default target namespace for the current Mix project.
Rewrites canonical Shadix.* module references in source to use namespace
as the new base.
Functions
Returns the default target directory for a given namespace.
Derived as lib/<underscored_namespace>.
iex> Shadix.Generator.default_dir("MyAppWeb.Components.UI")
"lib/my_app_web/components/ui"
@spec default_namespace() :: String.t()
Returns the default target namespace for the current Mix project.
Derived as <CamelizedApp>Web.Components.UI.
iex> Shadix.Generator.default_namespace()
"ShadixWeb.Components.UI"
Rewrites canonical Shadix.* module references in source to use namespace
as the new base.
Three ordered replacements are applied:
Shadix.Components→namespaceShadix.Cn→namespace <> ".Cn"Shadix.Form→namespace <> ".Form"
The order matters: Shadix.Components is replaced first so the substring
Shadix.Cn is never accidentally matched inside a Shadix.Components.* name.
iex> Shadix.Generator.rewrite_namespace("import Shadix.Cn", "Demo.UI")
"import Demo.UI.Cn"