godork

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

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

Go to latest
Published: Aug 8, 2017 License: MIT Imports: 11 Imported by: 1

README

godork

A system like godoc but designed for static self-hosting.

It comes in various parts:

  • The core github.com/AstromechZA/godork package. Provides the parsing and interpretation by wrapping the go/doc api.
  • The github.com/AstromechZA/godork/cli binary which wraps all the functionality in a convenient binary.
  • A set of example and default templates in the ./templates directory.

Note: Unlike the official godoc, this package doesn't automatically link text in the output format to other symbols and documentation. That'll be an extension to this package in the future.

Examples

An example package is provided that we use to test various features of this.

The two templates that are provided result in the following:

Build the binary

$ cd ./cli
$ ./build

This creates the godork binary.

Usage

A quick example that generates markdown documentation for the package.

$ godork template ./example github.com/AstromechZA/godork/example --template templates/markdown.md.template > templates/markdown.example.md

Markdown is not the best representation when compared to the official godoc stuff but it may be suitable in some places. So we can move onto using a simple html example:

$ godork template ./example github.com/AstromechZA/godork/example --template templates/milligram.html.template --html-mode > templates/milligram.example.html

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CodeToString

func CodeToString(fset *token.FileSet, node interface{}) string

func ReadPackageDirectory

func ReadPackageDirectory(sourceDirectory string) (*token.FileSet, *ast.Package, error)

func ReadPackageFile

func ReadPackageFile(fset *token.FileSet, sourceFile string) (*ast.File, error)

Types

type Constant

type Constant struct {
	Doc  string
	Code string
}

type Example

type Example struct {
	Name     string
	FullName string
	Doc      string
	Code     string
	Output   string
}

func BuildExamplesForName

func BuildExamplesForName(examples []*doc.Example, name string, fset *token.FileSet) []*Example

type Function

type Function struct {
	Name      string
	Doc       string
	Signature string
	Examples  []*Example
}

type Method

type Method struct {
	Name      string
	Doc       string
	Signature string
	Receiver  string
	Examples  []*Example
}

type PackageDoc

type PackageDoc struct {
	PackageName string
	ImportPath  string
	Doc         string
	Examples    []*Example
	Constants   []*Constant
	Variables   []*Variable
	Functions   []*Function
	Types       []*Type
	Imports     []string
}

func BuildPackageDoc

func BuildPackageDoc(importPath string, fset *token.FileSet, pkg *ast.Package) (*PackageDoc, error)

type Type

type Type struct {
	Name     string
	Doc      string
	Code     string
	Examples []*Example
	Methods  []*Method
}

type Variable

type Variable struct {
	Doc  string
	Code string
}

Directories

Path Synopsis
Package example is an example of various documentation abilities and edge cases.
Package example is an example of various documentation abilities and edge cases.

Jump to

Keyboard shortcuts

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