godoc2md

package module
v0.0.0-...-9cf3b12 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: BSD-3-Clause Imports: 11 Imported by: 0

README

godoc2md

This is forked from https://github.com/davecheney/godoc2md. The primary difference being that this version is a library that can be used by other packages.

This a fork of a fork https://github.com/WillAbides/godoc2md. But cleanup and simplified. Point it to a Go repo on disk and generate markdown from it.

I.e. assuming miekg/dns is cloned in /tmp/dns, you can run:

cmd/godoc2md/godoc2md -replace '/tmp/dns' -import 'github.com/miekg/dns' /tmp/dns

-replace removes the "/tmp/dns" prefix from the files in /tmp/dns and allows for the creation of the correct link to the code using the -import path. Optionally the git reference can be given as well, currently this defaults to "master".

Note: godoc2md is a small cmd line that wrap this library. Library usage can be pulled from it.

Bugs

Examples and notes are not rendered.

godocserve

Godocserve is much more interesting as it will render all downloaded markdown as HTML and has a search option. See cmd/godocserve/README.md for more information.

Documentation

Overview

Package godoc2md creates a markdown representation of a package's godoc.

This is forked from https://github.com/davecheney/godoc2md. The primary difference being that this version is a library that can be used by other packages.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Funcs contains the functions used in the template. Of these only subdir_format might be
	// of interest to callers.
	Funcs = map[string]interface{}{
		"comment_md":    commentMdFunc,
		"base":          path.Base,
		"md":            mdFunc,
		"pre":           preFunc,
		"kebab":         kebabFunc,
		"bitscape":      bitscapeFunc,
		"subdir_format": path.Base,
	}
)

Functions

func Transform

func Transform(out io.Writer, path string, config *Config) error

Transform turns your godoc into markdown.The imp (import) path will be used for the generated import statement, the same string is also used for generating file 'files' links, but then it will be prefixed with 'https://'.

Types

type Config

type Config struct {
	SrcLinkHashFormat string
	SrcLinkFormat     string
	ShowTimestamps    bool
	DeclLinks         bool
	Verbose           bool
	Replace           string
	Import            string
	SubPackage        string // If this is a subpackage, this hold the relative import
	GitRef            string // commit, tag, or branch of the repo.
}

Config contains config options for Godoc2md

Directories

Path Synopsis
cmd
godoc2md
godoc2md converts godoc formatted package documentation into Markdown format.
godoc2md converts godoc formatted package documentation into Markdown format.

Jump to

Keyboard shortcuts

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