From 067cd25017b4ecc195742e2400d798a13a110bef Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Tue, 26 Sep 2023 09:38:58 -0400 Subject: [PATCH] docs: update docs --- .../dsls/DSL:-AshCsv.DataLayer.cheatmd | 39 +++++++++++++++ .../tutorials/get-started-with-csv.md | 4 +- lib/ash_csv/data_layer.ex | 5 -- mix.exs | 47 ++++++++++++------- mix.lock | 7 +-- 5 files changed, 74 insertions(+), 28 deletions(-) create mode 100644 documentation/dsls/DSL:-AshCsv.DataLayer.cheatmd diff --git a/documentation/dsls/DSL:-AshCsv.DataLayer.cheatmd b/documentation/dsls/DSL:-AshCsv.DataLayer.cheatmd new file mode 100644 index 0000000..a5b36fa --- /dev/null +++ b/documentation/dsls/DSL:-AshCsv.DataLayer.cheatmd @@ -0,0 +1,39 @@ +# DSL: AshCsv.DataLayer + +The data layer implementation for AshCsv + + +## csv + + + + +### Examples +``` +csv do + file "priv/data/tags.csv" + create? true + header? true + separator '-' + columns [:id, :name] +end + +``` + + + + +### Options +| Name | Type | Default | Docs | +| --- | --- | --- | --- | +| `file`* | `String.t` | | The file to read the data from | +| `create?` | `boolean` | `false` | Whether or not the file should be created if it does not exist (this will only happen on writes) | +| `header?` | `boolean` | `false` | If the csv file has a header that should be skipped | +| `separator` | ``any`` | `44` | The separator to use, defaults to a comma. Pass in a character (not a string). | +| `columns` | ``any`` | | The order that the attributes appear in the columns of the CSV | + + + + + + diff --git a/documentation/tutorials/get-started-with-csv.md b/documentation/tutorials/get-started-with-csv.md index 259ff2b..31a727c 100644 --- a/documentation/tutorials/get-started-with-csv.md +++ b/documentation/tutorials/get-started-with-csv.md @@ -1,5 +1,5 @@ # Get Started with CSV -AshCsv is still relatively young, but offers basic support for storing and reading resources from csv files. +AshCsv offers basic support for storing and reading resources from csv files. -For information on how to configure it, see the DSL documentation. \ No newline at end of file +For information on how to configure it, see the [DSL documentation.](dsl-ashcsv-datalayer.html) diff --git a/lib/ash_csv/data_layer.ex b/lib/ash_csv/data_layer.ex index 8e275e6..4d91adb 100644 --- a/lib/ash_csv/data_layer.ex +++ b/lib/ash_csv/data_layer.ex @@ -115,11 +115,6 @@ defmodule AshCsv.DataLayer do @moduledoc """ The data layer implementation for AshCsv - - # Table of Contents - #{Spark.Dsl.Extension.doc_index(@sections)} - - #{Spark.Dsl.Extension.doc(@sections)} """ use Spark.Dsl.Extension, sections: @sections diff --git a/mix.exs b/mix.exs index 0a9f45f..55eb4cc 100644 --- a/mix.exs +++ b/mix.exs @@ -30,15 +30,16 @@ defmodule AshCsv.MixProject do defp elixirc_paths(_), do: ["lib"] defp extras() do - "documentation/**/*.md" + "documentation/**/*.{md,cheatmd,livemd}" |> Path.wildcard() |> Enum.map(fn path -> title = path |> Path.basename(".md") + |> Path.basename(".livemd") + |> Path.basename(".cheatmd") |> String.split(~r/[-_]/) - |> Enum.map(&String.capitalize/1) - |> Enum.join(" ") + |> Enum.map_join(" ", &capitalize/1) |> case do "F A Q" -> "FAQ" @@ -54,24 +55,27 @@ defmodule AshCsv.MixProject do end) end - defp groups_for_extras() do - "documentation/*" - |> Path.wildcard() - |> Enum.map(fn folder -> - name = - folder - |> Path.basename() - |> String.split(~r/[-_]/) - |> Enum.map(&String.capitalize/1) - |> Enum.join(" ") - - {name, folder |> Path.join("**") |> Path.wildcard()} + defp capitalize(string) do + string + |> String.split(" ") + |> Enum.map(fn string -> + [hd | tail] = String.graphemes(string) + String.capitalize(hd) <> Enum.join(tail) end) end + defp groups_for_extras() do + [ + Tutorials: ~r'documentation/tutorials', + "How To": ~r'documentation/how_to', + Topics: ~r'documentation/topics', + DSLs: ~r'documentation/dsls' + ] + end + defp docs do [ - main: "AshCsv", + main: "get-started-with-csv", source_ref: "v#{@version}", spark: [ extensions: [ @@ -144,8 +148,15 @@ defmodule AshCsv.MixProject do [ sobelow: "sobelow --skip", credo: "credo --strict", - docs: ["docs", "ash.replace_doc_links"], - "spark.formatter": "spark.formatter --extensions AshCsv.DataLayer" + docs: [ + "spark.cheat_sheets", + "docs", + "ash.replace_doc_links", + "spark.cheat_sheets_in_search" + ], + "spark.formatter": "spark.formatter --extensions AshCsv.DataLayer", + "spark.cheat_sheets": "spark.cheat_sheets --extensions AshCsv.DataLayer", + "spark.cheat_sheets_in_search": "spark.cheat_sheets_in_search --extensions AshCsv.DataLayer" ] end end diff --git a/mix.lock b/mix.lock index 938dae0..fc1329c 100644 --- a/mix.lock +++ b/mix.lock @@ -7,13 +7,13 @@ "csv": {:hex, :csv, "2.4.1", "50e32749953b6bf9818dbfed81cf1190e38cdf24f95891303108087486c5925e", [:mix], [{:parallel_stream, "~> 1.0.4", [hex: :parallel_stream, repo: "hexpm", optional: false]}], "hexpm", "54508938ac67e27966b10ef49606e3ad5995d665d7fc2688efb3eab1307c9079"}, "decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"}, "dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.10", "6603d7a603b9c18d3d20db69921527f82ef09990885ed7525003c7fe7dc86c56", [:mix], [], "hexpm", "8e2d5370b732385db2c9b22215c3f59c84ac7dda7ed7e544d7c459496ae519c0"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.36", "487ea8ef9bdc659f085e6e654f3c3feea1d36ac3943edf9d2ef6c98de9174c13", [:mix], [], "hexpm", "a524e395634bdcf60a616efe77fd79561bec2e930d8b82745df06ab4e844400a"}, "ecto": {:hex, :ecto, "3.10.3", "eb2ae2eecd210b4eb8bece1217b297ad4ff824b4384c0e3fdd28aaf96edd6135", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "44bec74e2364d491d70f7e42cd0d690922659d329f6465e89feb8a34e8cd3433"}, "elixir_make": {:hex, :elixir_make, "0.7.7", "7128c60c2476019ed978210c245badf08b03dbec4f24d05790ef791da11aa17c", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}], "hexpm", "5bc19fff950fad52bbe5f211b12db9ec82c6b34a9647da0c2224b8b8464c7e6c"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, "ets": {:hex, :ets, "0.9.0", "79c6a6c205436780486f72d84230c6cba2f8a9920456750ddd1e47389107d5fd", [:mix], [], "hexpm", "2861fdfb04bcaeff370f1a5904eec864f0a56dcfebe5921ea9aadf2a481c822b"}, "ex_check": {:hex, :ex_check, "0.12.0", "c0e2919ecc06afeaf62c52d64f3d91bd4bc7dd8deaac5f84becb6278888c967a", [:mix], [], "hexpm", "cfafa8ef97c2596d45a1f19b5794cb5c7f700f25d164d3c9f8d7ec17ee67cf42"}, - "ex_doc": {:hex, :ex_doc, "0.22.2", "03a2a58bdd2ba0d83d004507c4ee113b9c521956938298eba16e55cc4aba4a6c", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "cf60e1b3e2efe317095b6bb79651f83a2c1b3edcb4d319c421d7fcda8b3aff26"}, + "ex_doc": {:hex, :ex_doc, "0.30.6", "5f8b54854b240a2b55c9734c4b1d0dd7bdd41f71a095d42a70445c03cf05a281", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "bd48f2ddacf4e482c727f9293d9498e0881597eae6ddc3d9562bd7923375109f"}, "excoveralls": {:hex, :excoveralls, "0.13.1", "b9f1697f7c9e0cfe15d1a1d737fb169c398803ffcbc57e672aa007e9fd42864c", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "b4bb550e045def1b4d531a37fb766cbbe1307f7628bf8f0414168b3f52021cce"}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, "git_cli": {:hex, :git_cli, "0.3.0", "a5422f9b95c99483385b976f5d43f7e8233283a47cda13533d7c16131cb14df5", [:mix], [], "hexpm", "78cb952f4c86a41f4d3511f1d3ecb28edb268e3a7df278de2faa1bd4672eaf9b"}, @@ -21,8 +21,9 @@ "hackney": {:hex, :hackney, "1.18.1", "f48bf88f521f2a229fc7bae88cf4f85adc9cd9bcf23b5dc8eb6a1788c662c4f6", [:rebar3], [{:certifi, "~>2.9.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a4ecdaff44297e9b5894ae499e9a070ea1888c84afdd1fd9b7b2bc384950128e"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, "jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"}, - "makeup": {:hex, :makeup, "1.0.3", "e339e2f766d12e7260e6672dd4047405963c5ec99661abdc432e6ec67d29ef95", [:mix], [{:nimble_parsec, "~> 0.5", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "2e9b4996d11832947731f7608fed7ad2f9443011b3b479ae288011265cdd3dad"}, + "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, "makeup_elixir": {:hex, :makeup_elixir, "0.14.1", "4f0e96847c63c17841d42c08107405a005a2680eb9c7ccadfd757bd31dabccfb", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f2438b1a80eaec9ede832b5c41cd4f373b38fd7aa33e3b22d9db79e640cbde11"}, + "makeup_erlang": {:hex, :makeup_erlang, "0.1.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, "nimble_options": {:hex, :nimble_options, "1.0.2", "92098a74df0072ff37d0c12ace58574d26880e522c22801437151a159392270e", [:mix], [], "hexpm", "fd12a8db2021036ce12a309f26f564ec367373265b53e25403f0ee697380f1b8"},