render

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: MIT Package render serializes a query Result into the supported output formats.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Markdown

func Markdown(r model.Result) string

Markdown renders r as Markdown. It never fails, so it is convenient for callers that always want the human-readable form.

Example

ExampleMarkdown renders a query result as a Markdown report grouped by repository, newest commit first.

package main

import (
	"fmt"
	"time"

	"github.com/skaphos/sting/internal/render"
	"github.com/skaphos/sting/model"
)

func main() {
	result := model.Result{
		Author: "octocat",
		Scope:  model.ScopeSearch,
		Since:  time.Date(2026, 5, 22, 0, 0, 0, 0, time.UTC),
		Until:  time.Date(2026, 5, 29, 0, 0, 0, 0, time.UTC),
		Count:  1,
		Commits: []model.Commit{{
			SHA:     "abc1234def5678",
			Repo:    "skaphos/sting",
			Date:    time.Date(2026, 5, 28, 0, 0, 0, 0, time.UTC),
			Message: "Add example\n\nbody ignored in the summary line",
		}},
	}

	fmt.Print(render.Markdown(result))
}
Output:
# Commits by `octocat`

- **Window:** 2026-05-22 → 2026-05-29
- **Scope:** search
- **Commits:** 1

## skaphos/sting

- `abc1234` 2026-05-28 — Add example

func Render

func Render(r model.Result, f Format) (string, error)

Render encodes the result in the requested format.

Types

type Format

type Format string

Format identifies an output encoding.

const (
	FormatJSON     Format = "json"
	FormatMarkdown Format = "markdown"
)

func Parse

func Parse(s string) (Format, error)

Parse normalizes a user-supplied format string, defaulting to Markdown.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL