mdoc

package module
v0.0.0-...-de1db36 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2016 License: BSD-3-Clause Imports: 11 Imported by: 0

README

mdoc

Package mdoc provides a http.Handler that renders a directory of Markdown documents.

A command line application is also provided:

$ mdoc [-addr=<addr>] [-theme=<theme>] [<dir>]

Documentation

Overview

Package mdoc provides a http.Handler that renders a directory of Markdown documents.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("mdoc: file not found")

ErrNotFound represents that the file does not exist or is not a Markdown file.

Functions

func New

func New(dir string, opts ...Option) http.Handler

New returns a http.Handler that renders Markdown documents.

Types

type DocumentPage

type DocumentPage struct {
	Layout
	Name    string
	Content template.HTML
}

DocumentPage represents the data used to render a document.

type File

type File struct {
	Name  string
	IsDir bool
}

File represents a file for use in a HTML view.

func (File) DisplayName

func (f File) DisplayName() string

DisplayName returns the file name with a forward slash appended for directories.

type IndexPage

type IndexPage struct {
	Layout
	Files []File
}

IndexPage represents the data used to render a directory listing.

type Layout

type Layout struct {
	// contains filtered or unexported fields
}

Layout represents the page data used by both IndexPage and DocumentPage.

func (Layout) Dir

func (v Layout) Dir() string

Dir returns the path of the current directory.

func (Layout) StaticFile

func (v Layout) StaticFile(name string) string

StaticFile returns the path to an asset file.

type Option

type Option func(*handler)

Option describes a functional option for configuring the handler.

func DocumentRenderer

func DocumentRenderer(fn func(v DocumentPage) ([]byte, error)) Option

DocumentRenderer sets the DocumentPage rendering function. Defaults to a basic rendering function.

func ErrorHandler

func ErrorHandler(fn func(http.ResponseWriter, *http.Request, error)) Option

ErrorHandler sets the http.Handler to delegate to when errors are returned. Defaults to writing plain text error messages.

func IndexRenderer

func IndexRenderer(fn func(v IndexPage) ([]byte, error)) Option

IndexRenderer sets the IndexPage rendering function. Defaults to a basic rendering function.

func Root

func Root(root string) Option

Root sets the URL path to which the handler is mounted at. Defaults to the root URL path.

func Theme

func Theme(dir string) Option

Theme sets the path to the templates and assets used to render Markdown documents.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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