NLdoc.Spec (NLdoc.Spec v3.1.1)
View SourceThis module defines the Ecto schema for the NLdoc spec objects.
Summary
Functions
Recursively find the first spec object to match the given predicate, or return the given default value.
Returns the version of the NLdoc API spec that the NLdoc.Spec
library implements.
Types
@type blockquote_child() :: NLdoc.Spec.DefinitionList.t() | NLdoc.Spec.Heading.t() | NLdoc.Spec.Image.t() | NLdoc.Spec.OrderedList.t() | NLdoc.Spec.Paragraph.t() | NLdoc.Spec.Preformatted.t() | NLdoc.Spec.Table.t() | NLdoc.Spec.UnorderedList.t()
@type descriptor() :: NLdoc.Spec.ObjectDescriptor.t() | NLdoc.Spec.BooleanDescriptor.t() | NLdoc.Spec.StringDescriptor.t() | NLdoc.Spec.NumberDescriptor.t() | NLdoc.Spec.IntegerDescriptor.t()
@type document_child() :: NLdoc.Spec.BlockQuotation.t() | blockquote_child()
@type object() :: NLdoc.Spec.Asset.t() | NLdoc.Spec.BlockQuotation.t() | NLdoc.Spec.DefinitionDetails.t() | NLdoc.Spec.DefinitionList.t() | NLdoc.Spec.DefinitionTerm.t() | NLdoc.Spec.Document.t() | NLdoc.Spec.Footnote.t() | NLdoc.Spec.FootnoteReference.t() | NLdoc.Spec.Heading.t() | NLdoc.Spec.Image.t() | NLdoc.Spec.Link.t() | NLdoc.Spec.ListItem.t() | NLdoc.Spec.OrderedList.t() | NLdoc.Spec.Paragraph.t() | NLdoc.Spec.Preformatted.t() | NLdoc.Spec.Table.t() | NLdoc.Spec.TableCell.t() | NLdoc.Spec.TableHeader.t() | NLdoc.Spec.TableRow.t() | NLdoc.Spec.Text.t() | NLdoc.Spec.UnorderedList.t()
@type paragraph_child() :: NLdoc.Spec.Image.t() | NLdoc.Spec.Link.t() | NLdoc.Spec.Text.t() | NLdoc.Spec.FootnoteReference.t()
@type text_style() ::
:bold
| :italic
| :underline
| :strikethrough
| :code
| :superscript
| :subscript
| :mark
Functions
Recursively find the first spec object to match the given predicate, or return the given default value.
This function performs a depth-first search through the children of a spec object or list of spec objects, and returns the first spec object for which the predicate returns true.
Examples
iex> alias NLdoc.Spec.{Paragraph, Text}
iex> NLdoc.Spec.find_recursive(
...> [%Text{text: "1"}, %Text{text: "2"}],
...> fn object -> object.text === "2" end
...> )
%Text{text: "2"}
iex> NLdoc.Spec.find_recursive(
...> [%Paragraph{children: [%Text{text: "1"}, %Text{text: "2"}]}, %Paragraph{children: [%Text{text: "3"}, %Text{text: "4"}]}],
...> fn
...> %Text{text: text} -> text |> String.to_integer() |> rem(2) === 0
...> _ -> false
...> end
...> )
%Text{text: "2"}
iex> NLdoc.Spec.find_recursive([], fn _ -> true end)
nil
iex> NLdoc.Spec.find_recursive([], fn _ -> true end, "test")
"test"
iex> NLdoc.Spec.find_recursive([%Text{text: "1"}, %Text{text: "2"}], fn _ -> false end)
nil
iex> NLdoc.Spec.find_recursive([%Text{text: "1"}, %Text{text: "2"}], fn _ -> false end, "default")
"default"
@spec text_styling() :: [text_style()]
@spec version() :: String.t()
Returns the version of the NLdoc API spec that the NLdoc.Spec
library implements.