render

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: MIT

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 ActivityEstimate added in v1.1.0

func ActivityEstimate(cost model.CostReport) string

ActivityEstimate renders estimate-only output: the projected cost and the remaining quota, with an explicit statement that nothing was gathered.

Saying so plainly matters — an estimate that reads like a result would let a caller believe it had evidence it never collected.

func ActivityMarkdown added in v1.1.0

func ActivityMarkdown(r model.ActivityResult) string

ActivityMarkdown renders r as Markdown. It never fails, so it is convenient for callers that always want the human-readable form (the MCP text content, for one).

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.

func RenderActivity added in v1.1.0

func RenderActivity(r model.ActivityResult, f Format) (string, error)

RenderActivity encodes a repository activity result in the requested format. JSON is the contract; Markdown is a view of it, never a superset.

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