EditorConfig (EditorConfig v0.1.0)

Copy Markdown View Source

Resolves EditorConfig properties for files.

This package targets EditorConfig specification 0.17.2.

Summary

Functions

Parses one .editorconfig file.

Resolves EditorConfig properties for path.

Resolves properties and includes contributing config file/section sources.

Returns the EditorConfig specification version targeted by this package.

Returns the package version.

Functions

parse(binary, opts \\ [])

@spec parse(
  binary(),
  keyword()
) :: {:ok, EditorConfig.File.t()} | {:error, term()}

Parses one .editorconfig file.

Examples

iex> {:ok, file} = EditorConfig.parse("[*]\nindent_style = space\n")
iex> hd(file.sections).properties
%{"indent_style" => "space"}

properties(path, opts \\ [])

@spec properties(
  Path.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Resolves EditorConfig properties for path.

Examples

iex> fs = EditorConfig.FileSystem.Memory.new(%{
...>   "/project/.editorconfig" => "root = true\n[*]\nindent_style = space\n"
...> })
iex> EditorConfig.properties("/project/file.ex", fs: fs)
{:ok, %{"indent_style" => "space"}}

properties_with_sources(path, opts \\ [])

@spec properties_with_sources(
  Path.t(),
  keyword()
) :: {:ok, map(), list()} | {:error, term()}

Resolves properties and includes contributing config file/section sources.

Examples

iex> fs = EditorConfig.FileSystem.Memory.new(%{
...>   "/project/.editorconfig" => "root = true\n[*]\nindent_style = space\n"
...> })
iex> EditorConfig.properties_with_sources("/project/file.ex", fs: fs)
{:ok, %{"indent_style" => "space"}, [{"/project/.editorconfig", "*"}]}

spec_version()

@spec spec_version() :: String.t()

Returns the EditorConfig specification version targeted by this package.

Examples

iex> EditorConfig.spec_version()
"0.17.2"

version()

@spec version() :: String.t()

Returns the package version.

Examples

iex> EditorConfig.version()
"0.1.0"