Two issues made docs/api hard to read: 1. The site's custom Markdown parser only recognized `- ` bullets, so the README's `* ` bullets rendered as a single run-on paragraph with literal asterisks. Extended the parser (and tests) to accept the full CommonMark bullet set: `-`, `*`, `+`. 2. The shared .markdown-content container is 88rem wide. Comfortable for /algo's wide tables but uncomfortable for monospace prose, which prefers ~80ch. Added a .api-docs modifier class on the /docs/api page that drops max-width to 60rem, allows table cells to wrap, and slightly downsizes headings.
23 lines
650 B
Elixir
23 lines
650 B
Elixir
defmodule MicrowavepropWeb.ApiDocsLive do
|
|
@moduledoc "Renders `docs/api/README.md` as HTML at `/docs/api`."
|
|
use MicrowavepropWeb, :live_view
|
|
|
|
@external_resource "docs/api/README.md"
|
|
@docs_html "docs/api/README.md" |> File.read!() |> Microwaveprop.Markdown.to_html!()
|
|
|
|
@impl true
|
|
def mount(_params, _session, socket) do
|
|
{:ok, assign(socket, page_title: "API Documentation", content: @docs_html)}
|
|
end
|
|
|
|
@impl true
|
|
def render(assigns) do
|
|
~H"""
|
|
<Layouts.app flash={@flash} current_scope={@current_scope}>
|
|
<div class="markdown-content api-docs">
|
|
{raw(@content)}
|
|
</div>
|
|
</Layouts.app>
|
|
"""
|
|
end
|
|
end
|