docs: work on docs structure

This commit is contained in:
Zach Daniel 2022-06-05 12:13:29 -04:00
parent 0d7eac7829
commit ae65d09373
11 changed files with 55 additions and 78 deletions

View file

@ -78,26 +78,57 @@ defmodule Ash.DocIndex.AshDocIndex do
end
@impl true
@spec code_modules :: list(module())
@spec code_modules :: %{String.t() => list(module)}
def code_modules do
[
Ash.Resource.Info,
Ash.Api,
Ash.Type,
Ash.Error,
Ash.CiString,
Ash.Changeset,
Ash.Query,
Ash.Filter,
Ash.Sort,
Ash.Resource.Change,
Ash.Resource.Change.Builtins,
Ash.Calculation,
Ash.CodeInterface,
Ash.Dsl.Entity,
Ash.Dsl.Extension,
Ash.Dsl.Section,
ASh.Dsl.Transformer
]
%{
"Resources" => [
Ash.Api,
Ash.Resource.Info,
Ash.Resource.Change,
Ash.Resource.Change.Builtins,
Ash.Calculation,
Ash.Resource.Calculation.Builtins,
Ash.CodeInterface,
Ash.Changeset,
Ash.Query
],
"Utilities" => [
Ash.Filter,
Ash.Sort
],
"Errors" => [
Ash.Error
],
"Types" => [
Ash.Type,
Ash.Type.Enum,
Ash.Type.Atom,
Ash.Type.Binary,
Ash.Type.Boolean,
Ash.Type.CiString,
Ash.CiString,
Ash.Type.Date,
Ash.Type.Decimal,
Ash.Type.DurationName,
Ash.Type.Float,
Ash.Type.Function,
Ash.Type.Integer,
Ash.Type.Map,
Ash.Type.NaiveDatetime,
Ash.Type.String,
Ash.Type.Term,
Ash.Type.Time,
Ash.Type.UUID,
Ash.Type.UrlEncodedBinary,
Ash.Type.UtcDatetime,
Ash.Type.UtcDatetimeUsec
],
"DSLs and Extensions" => [
Ash.Dsl.Entity,
Ash.Dsl.Extension,
Ash.Dsl.Section,
ASh.Dsl.Transformer
]
}
end
end

View file

@ -21,7 +21,7 @@ defmodule Ash.DocIndex do
@callback extensions() :: list(extension())
@callback for_library() :: String.t()
@callback guides() :: list(guide())
@callback code_modules() :: list(module())
@callback code_modules() :: %{String.t() => list(module())}
defmacro __using__(opts) do
quote bind_quoted: [guides_from: opts[:guides_from]] do
@ -53,62 +53,6 @@ defmodule Ash.DocIndex do
end
end
def ensure_documented!(doc_index) do
Enum.each(doc_index.extensions(), fn extension ->
Enum.each(extension.module().sections(), &do_ensure_documented!/1)
end)
end
defp do_ensure_documented!(
section_or_entity,
trail \\ []
)
defp do_ensure_documented!(
%Ash.Dsl.Section{name: name, schema: schema, entities: entities, sections: sections},
trail
) do
case Enum.find(schema, fn {_key, opts} ->
!opts[:links]
end) do
{key, _opts} ->
opt =
trail
|> Enum.reverse([key])
|> Enum.join(".")
raise "#{opt} is not documented (must contain links)!"
_ ->
:ok
end
Enum.each(entities, &do_ensure_documented!(&1, [name | trail]))
Enum.each(sections, &do_ensure_documented!(&1, [name | trail]))
end
defp do_ensure_documented!(
%Ash.Dsl.Entity{name: name, schema: schema, entities: entities},
trail
) do
case Enum.find(schema, fn {_key, opts} ->
!opts[:links]
end) do
{key, _opts} ->
opt =
trail
|> Enum.reverse([key])
|> Enum.join(".")
raise "#{opt} is not documented (must contain links)!"
_ ->
:ok
end
Enum.each(entities, &do_ensure_documented!(elem(&1, 1), [name | trail]))
end
def to_name(string) do
string
|> String.split(~r/[-_]/, trim: true)

View file

@ -4,6 +4,8 @@ defmodule Ash.Resource.Dsl do
describe: """
Declares an attribute on the resource
For more information, see `{{link:ash:guide:attributes.md}}`
Type can be either a built in type (see `Ash.Type`) for more, or a module
implementing the `Ash.Type` behaviour.

View file

@ -86,7 +86,7 @@ defmodule Ash.MixProject do
"old_documentation/topics/compile_times.md": [
title: "Compile Times"
],
"documentation/explanation/policies.md": [
"documentation/topics/policies.md": [
title: "Policies"
]
],