FormatParser.Document (format_parser v2.6.0)

A Document struct and functions.

The Document struct contains the fields format and nature.

Summary

Functions

Parses a document from the given input.

Types

t()

@type t() :: %FormatParser.Document{format: any(), intrinsics: map(), nature: atom()}

Functions

parse(file)

@spec parse({:error, binary()} | binary() | any()) :: any()

Parses a document from the given input.

  • If the input is a tuple {:error, file} where file is a binary, it attempts to parse the document from the file.
  • If the input is a binary file, it attempts to parse the document from the file.
  • For any other input, it returns the input as-is.

Examples

iex> parse({:error, "path/to/file"}) # Parses the document from the given file

iex> parse("path/to/file") # Parses the document from the given file

iex> parse(:ok) :ok