report

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package report turns a run into a file to share: the printed markdown, a standalone HTML page or a PDF. The CLI's --pdf and --html and the GUI's Report dialog both use it, so they make the same reports.

Index

Constants

This section is empty.

Variables

View Source
var Formats = []Format{PDF, HTML, Markdown}

Formats lists every format, in the order a menu shows them.

Functions

func Render

func Render(d *doc.Document, results []*run.Result, opts Options) ([]byte, error)

Render makes a report of d with results, matched to its blocks as render.Markdown matches them. Blocks without a result show the output saved in the file, so run.Includes(d, ...) as results reports the file as it was last saved, running nothing.

func Title

func Title(file string) string

Title is a report title for file: its name without the extension.

Types

type Command added in v1.3.0

type Command struct {
	// File is the document, and Dest the report to write.
	File, Dest string
	Format     Format
	HideCode   bool
	HideOutput bool
	// History asks for each block's earlier runs, as --history does.
	History bool
	// Run says the report comes from running the blocks. Otherwise it is
	// of the file as saved, like mdsh -n.
	Run bool
	// Args, Only, Step and StopOnError are the run's options, shown when
	// Run is set.
	Args        []string
	Only        string
	Step        bool
	StopOnError bool
	// Home is the user's home folder, for ~/ paths. Empty names no path
	// that way.
	Home string
}

Command describes a report as an mdsh command line, so the GUI's Report dialog and the TUI's report form can show how to make the same report from a shell.

func (Command) String added in v1.3.0

func (c Command) String() string

String is the command, run in the document's folder: files there are named on their own, and other paths under Home as ~/….

type Format

type Format string

Format is a kind of report.

const (
	// Markdown is what mdsh prints: placeholders as values, mdsh:if
	// sections decided, and no #! line. It is what mdsh -n -o saves.
	Markdown Format = "markdown"
	// HTML is a standalone page, with local images inside it.
	HTML Format = "html"
	// PDF is what mdsh --pdf writes.
	PDF Format = "pdf"
)

func FormatOf

func FormatOf(path string) (Format, bool)

FormatOf names the format a file's extension asks for.

func (Format) Ext

func (f Format) Ext() string

Ext is the format's usual file extension, with its dot.

type Options

type Options struct {
	Format Format
	// HideCode leaves out runnable blocks, as --hide-code does.
	HideCode bool
	// HideOutput leaves out output, as --hide-output does.
	HideOutput bool
	// Env is the caller's environment, for {{$VAR}} placeholders and
	// conditions; see render.Options.
	Env []string
	// Dir is where relative image links are read from, for HTML and
	// PDF. Empty means the working directory.
	Dir string
	// AllowOutside reads images from anywhere, as mdsh --allow-outside
	// does. Otherwise a local image must be inside Dir's root: see
	// package docroot.
	AllowOutside bool
	// Title is the report's title. Empty means none for a PDF and
	// "mdsh report" for an HTML page.
	Title string
	// ShowSecrets prints blocks marked secret as they are. Otherwise
	// their code and output are "(secret)": a report is made to be read
	// by others (see render.Options.MaskSecrets).
	ShowSecrets bool
	// History prints each block's earlier runs, kept by history=N, under
	// its output, as --history does (see render.Options.History).
	History bool
	// InSource reports whether a result is already in the document's
	// source, as for an mdsh-gui document a run was written into; see
	// render.Options.InSource. Nil means none is.
	InSource func(r *run.Result) bool
}

Options control what a report shows.

Jump to

Keyboard shortcuts

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