doc

package
v0.0.0-...-9c7514e Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestTypeHuman requestType = iota
	RequestTypeRefresh
)

Variables

View Source
var (
	ErrInvalidRemotePath = errors.New("invalid package remote path")
	ErrNoServiceMatch    = errors.New("package remote path does not match any service")
)
View Source
var (
	ErrPackageNotModified = errors.New("Package has not been modified")
	ErrPackageNoGoFile    = errors.New("Package does not contain Go file")
)
View Source
var (
	Client = &http.Client{Transport: httpTransport}
)
View Source
var (
	ErrFetchTimeout = errors.New("Fetch package timeout")
)

Functions

func CheckPackage

func CheckPackage(importPath string, render macaron.Render, rt requestType) (*db.PkgInfo, error)

CheckPackage checks package by import path.

func FormatCode

func FormatCode(w io.Writer, code *string, links []*Link)

FormatCode highlights keywords and adds HTML links to them.

func SaveDocPage

func SaveDocPage(docPath string, data []byte) int

SaveDocPage saves doc. content to JS file(s), it returns max index of JS file(s); it returns -1 when error occurs.

func SavePkgDoc

func SavePkgDoc(docPath string, readmes map[string][]byte)

SavePkgDoc saves readered readme.md file data.

Types

type Annotation

type Annotation struct {
	Pos, End   int16
	Kind       AnnotationKind
	ImportPath string
}

type AnnotationKind

type AnnotationKind int16
const (
	ExportLinkAnnotation AnnotationKind = iota
	AnchorAnnotation
	CommentAnnotation
	PackageLinkAnnotation
	BuiltinAnnotation
)

type Code

type Code struct {
	Text        string
	Annotations []Annotation
}

type Example

type Example struct {
	Name string
	Doc  string
	Code string
	//Play   string
	Output string
	IsUsed bool // Indicates if it's used by any kind object.
}

Example represents function or method examples.

type File

type File struct {
	// Top-level declarations.
	Consts []*Value
	Funcs  []*Func
	Types  []*Type
	Vars   []*Value

	// Internal declarations.
	Ifuncs []*Func
	Itypes []*Type
}

A File describles declaration of file.

type Func

type Func struct {
	Name, FullName string
	Doc            string
	Decl, FmtDecl  string
	URL            string // VCS URL.
	Code           string // Included field 'Decl', formatted.
	Examples       []*Example
}

Func represents functions

type Link struct {
	Path, Name, Comment string // package path, identifier name, and comments.
}

A link describes the (HTML) link information for an identifier. The zero value of a link represents "no link".

type Package

type Package struct {
	*db.PkgInfo

	Readme map[string][]byte

	*PkgDecl

	IsHasExport bool

	// Top-level declarations.
	IsHasConst, IsHasVar bool

	IsHasExample bool

	IsHasFile   bool
	IsHasSubdir bool
}

Package represents the full documentation and declaration of a project or package.

type PkgDecl

type PkgDecl struct {
	Tag string // Current tag of project.
	Doc string // Package documentation(doc.go).

	File

	Examples             []*Example // Function or method example.
	Imports, TestImports []string   // Imports.
	Files, TestFiles     []*Source  // Source files.

	Notes []string // Source code notes.
	Dirs  []string // Subdirectories
}

PkgDecl is package declaration in database acceptable form.

type RepoCommit

type RepoCommit struct {
	Commit struct {
		Committer struct {
			Date time.Time `json:"date"`
		} `json:"committer"`
	} `json:"commit"`
}

type RepoInfo

type RepoInfo struct {
	DefaultBranch string `json:"default_branch"`
	Fork          bool   `json:"fork"`
	Parent        struct {
		FullName string `json:"full_name"`
	} `json:"parent"`
}

type Source

type Source struct {
	SrcName   string
	BrowseUrl string
	RawSrcUrl string
	SrcData   []byte
}

Source represents a Source code file.

func (*Source) Data

func (s *Source) Data() []byte

func (*Source) IsDir

func (s *Source) IsDir() bool

func (*Source) ModTime

func (s *Source) ModTime() time.Time

func (*Source) Mode

func (s *Source) Mode() os.FileMode

func (*Source) Name

func (s *Source) Name() string

func (*Source) RawUrl

func (s *Source) RawUrl() string

func (*Source) SetData

func (s *Source) SetData(p []byte)

func (*Source) Size

func (s *Source) Size() int64

func (*Source) Sys

func (s *Source) Sys() interface{}

type Type

type Type struct {
	Name          string // Type name.
	Doc           string
	Decl, FmtDecl string // Normal and formatted form of declaration.
	URL           string // VCS URL.

	Consts, Vars []*Value
	Funcs        []*Func // Exported functions that return this type.
	Methods      []*Func // Exported methods.

	IFuncs   []*Func // Internal functions that return this type.
	IMethods []*Func // Internal methods.

	Examples []*Example
}

Type represents structs and interfaces.

type Value

type Value struct {
	Name          string // Value name.
	Doc           string
	Decl, FmtDecl string // Normal and formatted form of declaration.
	URL           string // VCS URL.
}

Value represents constants and variable

type WalkDepth

type WalkDepth uint

WalkDepth indicates how far the process goes.

const (
	WD_Imports WalkDepth = iota
	WD_All
)

type WalkMode

type WalkMode uint

WalkMode indicates which things to do.

const (
	WM_All WalkMode = 1 << iota
	WM_NoReadme
	WM_NoExample
)

type WalkRes

type WalkRes struct {
	WalkDepth
	WalkType
	WalkMode
	RootPath string    // For WT_Local mode.
	Srcs     []*Source // For WT_Memory mode.
	BuildAll bool
}

type WalkType

type WalkType uint

WalkType indicates which way to get data for walker.

const (
	WT_Local WalkType = iota
	WT_Memory
	WT_Zip
	WT_TarGz
	WT_Http
)

type Walker

type Walker struct {
	LineFmt string
	Pdoc    *Package

	Examples []*doc.Example // Function or method example.
	Fset     *token.FileSet
	SrcLines map[string][]string // Source file line slices.
	SrcFiles map[string]*Source
	Buf      []byte // scratch space for printNode method.
	// contains filtered or unexported fields
}

Walker holds the state used when building the documentation.

func (*Walker) Build

func (w *Walker) Build(wr *WalkRes) (*Package, error)

Build generates documentation from given source files through 'WalkType'.

Jump to

Keyboard shortcuts

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