Skip to content

Arbitrary grouping of functions with @doc group: :some_group #876

Closed
@lackac

Description

@lackac

The new documentation metadata and specifically the @doc keyword() construct opens up new possibilities for enriching the ExDoc UI and providing better ways to navigate and explore.

ExDoc is already making use of the guard: true metadata to group guards together in Kernel and other modules. It could similarly allow arbitrary grouping of functions:

defmodule Flow do
  @doc group: :mappers
  def each(flow, each)

  @doc group: :mappers
  def filter(flow, filter)

  @doc group: :reducers
  def reduce(flow, acc_fun, reducer_fun)

  @doc group: :reducers
  def group_by(flow, key_fun, value_fun)
end

The code above would instruct ExDoc to create two new groups in the sidebar: "Mappers" and "Reducers". The same grouping would also be used on the main content side. The behaviour would be exactly the same as the existing "Callbacks" and "Types" grouping. Optionally we could also introduce a way to toggle grouping.

This is mostly useful for modules that define a high number of functions where separating them conceptually would provide a better experience for the reader. (e.g. documentation of Flow, or some ExAws packages with larger footprints)

Some details of how this would behave still needs to be worked out and can be discussed if this finds support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions