View Source Magma.Matter.Module (Magma v0.2.0)

Magma.Matter type behaviour implementation for Elixir modules.

The Magma.Matter.Module struct is used for generation of Magma.Artefacts about Elixir modules. It does not have any additional fields above the Magma.Matter.fields/0 as it retrieves all necessary information via the Elixir and Erlang reflection API from the module name.

Summary

Functions

Returns the list of Magma.Artefact types available for Elixir modules.

Returns the source code of the module, if it exists.

Returns the name of the Magma.Concept document for an Elixir module.

Returns the title header text of the Magma.Concept document for an Elixir module.

Returns a list of the modules the given module is defined under.

Returns a default description for the Magma.Concept document of an Elixir module.

Determines whether the module should be ignored when generating documentation.

Creates a new Magma.Matter.Module instance from a given module name in an ok tuple.

Creates a new Magma.Matter.Module instance from a given module name and fails in error cases.

Returns the title for the description section of the module in artefact prompts.

Returns a string with a Markdown section containing the source code of the module for artefact prompts.

Returns the base path segment to be used for different kinds of documents for Elixir modules.

Returns the path for Magma.Concept documents about Elixir modules.

Returns the source path of the module, if it exists.

Returns a list of the submodules defined under the given module.

Types

@type t() :: %Magma.Matter.Module{name: term()}

Functions

Returns the list of Magma.Artefact types available for Elixir modules.

iex> Magma.Matter.Module.artefacts()
[Magma.Artefacts.ModuleDoc]
@spec code(t() | module() | Path.t()) :: binary() | nil

Returns the source code of the module, if it exists.

The source code is read from the source_path/1.

Returns the name of the Magma.Concept document for an Elixir module.

It is the module name as a string.

Example

iex> Some.Module ...> |> Magma.Matter.Module.new!() ...> |> Magma.Matter.Module.concept_name() "Some.Module"

Returns the title header text of the Magma.Concept document for an Elixir module.

Example

iex> Some.Module ...> |> Magma.Matter.Module.new!() ...> |> Magma.Matter.Module.concept_title() "Some.Module"

Returns a list of the modules the given module is defined under.

Example

iex> Magma.Matter.Module.context_modules(Magma.DocumentStruct.Section)
[Magma, Magma.DocumentStruct]
Link to this function

default_description(matter, _)

View Source

Returns a default description for the Magma.Concept document of an Elixir module.

Determines whether the module should be ignored when generating documentation.

A module is ignored

  • if it has a # Magma pragma: ignore comment at the beginning of its source code, or
  • if it is marked as hidden (e.g. with @moduledoc false) and does not have a

    Magma pragma: include comment at the beginning of its source code.

@spec new(binary() | atom() | [{:name, binary() | atom()}]) ::
  {:ok, t()} | {:error, any()}

Creates a new Magma.Matter.Module instance from a given module name in an ok tuple.

Creates a new Magma.Matter.Module instance from a given module name and fails in error cases.

Link to this function

prompt_concept_description_title(module)

View Source

Returns the title for the description section of the module in artefact prompts.

Example

iex> Some.Module
...> |> Magma.Matter.Module.new!()
...> |> Magma.Matter.Module.prompt_concept_description_title()
"Description of the module `Some.Module`"
Link to this function

prompt_matter_description(matter)

View Source

Returns a string with a Markdown section containing the source code of the module for artefact prompts.

Returns the base path segment to be used for different kinds of documents for Elixir modules.

The base path for all modules is "modules".

Link to this function

relative_concept_path(matter)

View Source

Returns the path for Magma.Concept documents about Elixir modules.

Example

iex> Some.Module
...> |> Magma.Matter.Module.new!()
...> |> Magma.Matter.Module.relative_concept_path()
"modules/Some/Some.Module.md"
@spec source_path(t() | module()) :: Path.t() | nil

Returns the source path of the module, if it exists.

The source path is the file path where the source code of the module is located.

Returns a list of the submodules defined under the given module.

Note: This function relies on the existence of concept documents for modules.