Skip to content

Commit

Permalink
fix: generate DSL documentation without a colon in the file name
Browse files Browse the repository at this point in the history
this breaks on windows
  • Loading branch information
zachdaniel committed Oct 17, 2024
1 parent 7f99d22 commit 471c277
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
21 changes: 20 additions & 1 deletion lib/mix/tasks/spark.cheat_sheets.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,31 @@ defmodule Mix.Tasks.Spark.CheatSheets do
File.rm_rf!("documentation/dsls")
end

Application.ensure_all_started(:rewrite)

Igniter.new()
|> Igniter.update_elixir_file("mix.exs", fn zipper ->
Igniter.Code.Common.update_all_matches(zipper, &Igniter.Code.String.string?/1, fn zipper ->
Igniter.Code.String.update_string(zipper, fn
"DSL:-" <> rest ->
{:ok, "DSL-" <> rest}

"documentation/dsls/DSL:-" <> rest ->
{:ok, "documentation/dsls/DSL-" <> rest}

other ->
{:ok, other}
end)
end)
end)
|> Igniter.do_or_dry_run(yes: true)

for extension <- extensions do
cheat_sheet = Spark.CheatSheet.cheat_sheet(extension)
File.mkdir_p!("documentation/dsls")
extension_name = Spark.Mix.Helpers.extension_name(extension, opts)

filename = "documentation/dsls/DSL:-#{extension_name}.md"
filename = "documentation/dsls/DSL-#{extension_name}.md"

if opts[:check] do
if File.exists?(filename) && String.trim(File.read!(filename)) == String.trim(cheat_sheet) do
Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ defmodule Spark.MixProject do
{:sourceror, "~> 1.2"},
# in 3.x, make this dependency optional
{:jason, "~> 1.4"},
{:igniter, "~> 0.2 and >= 0.3.36"},
# {:igniter, "~> 0.2 and >= 0.3.36"},
{:igniter, path: "../igniter", override: true},
# Dev/Test dependencies
{:benchee, "~> 1.3", only: [:dev, :test]},
{:eflame, "~> 1.0", only: [:dev, :test], runtime: false},
Expand Down

0 comments on commit 471c277

Please sign in to comment.