OpenrelikWorkerCommon.Reporting.MarkdownDocument (openrelik_worker_common v0.1.0)

Copy Markdown View Source

Represents a Markdown document (openrelik_worker_common.reporting.MarkdownDocument).

Summary

Functions

Adds a section to the document.

Initializes a MarkdownDocument struct.

Generates a dictionary (string-keyed map) representation of the document.

Generates a JSON representation of the document.

Generates a Markdown representation of the document.

Types

t()

@type t() :: %OpenrelikWorkerCommon.Reporting.MarkdownDocument{
  fmt: OpenrelikWorkerCommon.Reporting.MarkdownFormatter.t(),
  priority: OpenrelikWorkerCommon.Reporting.Priority.t(),
  sections: [OpenrelikWorkerCommon.Reporting.MarkdownDocumentSection.t()],
  summary: String.t(),
  title: String.t() | nil
}

Functions

add_section(doc)

Adds a section to the document.

When called with just document, appends an empty %MarkdownDocumentSection{} and returns {updated_document, new_section} or, if passed a %MarkdownDocumentSection{} or builder function (section -> section), appends the populated section and returns updated_document.

add_section(doc, section)

new(title \\ nil)

@spec new(String.t() | nil) :: t()

Initializes a MarkdownDocument struct.

to_dict(doc)

@spec to_dict(t()) :: %{required(String.t()) => term()}

Generates a dictionary (string-keyed map) representation of the document.

to_json(doc)

@spec to_json(t()) :: String.t()

Generates a JSON representation of the document.

to_markdown(markdown_document)

@spec to_markdown(t()) :: String.t()

Generates a Markdown representation of the document.