View Source SayCheezEx.Graphs.Provider behaviour (say_cheez_ex v0.3.5)
The interface for a graph provider.
- checks if a such a provider is available, given the providers' own configuration
- renders a graph to some HTML that can be embedded
Link to this section Summary
Functions
Checks whether we have a file in our cache.
Generates a file name for a tuple (module, recipe).
We want to simplify the SVG that Graphviz generates so we can embed it in our HTML.
Formats the error message, if any.
Creates a file name for a temporary file.
Given a recipe recipe for a graph, first tries a cache and then call a "builder" function to create it.
Runs an external command.
Computes a printable SHA for a string.
The only significant advantage of this HTTP client is that it only uses things that are in Erlang itself.
Earmark says that "A HTML Block defined by a tag starting a line and the same tag starting a different line is parsed as one HTML AST node, marked with %{verbatim: true}" (see https://hexdocs.pm/earmark_parser/EarmarkParser.html )
Write a file to its right cache.
Link to this section Callbacks
Link to this section Functions
Checks whether we have a file in our cache.
If we do, we return its contents.
Generates a file name for a tuple (module, recipe).
We want to simplify the SVG that Graphviz generates so we can embed it in our HTML.
Formats the error message, if any.
Creates a file name for a temporary file.
Ths may be a cache file or a proper temporary file.
If you need mode than one file, you should encode it in the extensions.
Given a recipe recipe for a graph, first tries a cache and then call a "builder" function to create it.
So if the SVG was already generated, we load it from disk - if not, we build it again.
builder
Builder
It returns {:ok, svg_text} or {:error, reason} that will be used to display a result.
Runs an external command.
It returns a binary that captures STDOUT+STDERR if all went well,
or a tuple {:error, e}
if something went bonkers.
If it's trying to call a command that does not exist on your
local environment, returns {:error, :cmd_not_found}
.
Computes a printable SHA for a string.
The only significant advantage of this HTTP client is that it only uses things that are in Erlang itself.
https://stackoverflow.com/questions/20108421/using-the-httpc-erlang-module-from-elixir
Earmark says that "A HTML Block defined by a tag starting a line and the same tag starting a different line is parsed as one HTML AST node, marked with %{verbatim: true}" (see https://hexdocs.pm/earmark_parser/EarmarkParser.html )
So we wrap everything in a DIV and call it a day.
Write a file to its right cache.