doc

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package doc implements support for documentation of Gno packages and realms, in a similar fashion to `go doc`. As a reference, the official implementation for `go doc` is used.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Documentable

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

Documentable is a package, symbol, or accessible which can be documented.

func NewDocumentableFromMemPkg

func NewDocumentableFromMemPkg(memPkg *gnovm.MemPackage, unexported bool, symbol, accessible string) (*Documentable, error)

NewDocumentableFromMemPkg gets the pkgData from memPkg and returns a Documentable

func ResolveDocumentable

func ResolveDocumentable(dirs, modDirs, args []string, unexported bool) (*Documentable, error)

ResolveDocumentable returns a Documentable from the given arguments. Refer to the documentation of gno doc for the formats accepted (in general the same as the go doc command). An error may be returned even if documentation was resolved in case some packages in dirs could not be parsed correctly.

dirs specifies the gno system directories to scan which specify full import paths in their directories, such as @/examples and @/gnovm/stdlibs; modDirs specifies directories which contain a gno.mod file.

func (*Documentable) WriteDocumentation

func (d *Documentable) WriteDocumentation(w io.Writer, o *WriteDocumentationOptions) error

func (*Documentable) WriteJSONDocumentation

func (d *Documentable) WriteJSONDocumentation() (*JSONDocumentation, error)

WriteJSONDocumentation returns a JSONDocumentation for the package

type JSONDocumentation

type JSONDocumentation struct {
	PackagePath string `json:"package_path"`
	PackageLine string `json:"package_line"` // package io // import "io"
	PackageDoc  string `json:"package_doc"`  // markdown of top-level package documentation

	// These match each of the sections in a pkg.go.dev package documentation
	Values []*JSONValueDecl `json:"values"` // constants and variables declared
	Funcs  []*JSONFunc      `json:"funcs"`  // Funcs and methods
	Types  []*JSONType      `json:"types"`
}

JSONDocumentation holds package documentation suitable for transmitting as JSON with printable string fields

func (*JSONDocumentation) JSON

func (jsonDoc *JSONDocumentation) JSON() string

type JSONField

type JSONField struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type JSONFunc

type JSONFunc struct {
	Type      string       `json:"type"` // if this is a method
	Name      string       `json:"name"`
	Signature string       `json:"signature"`
	Doc       string       `json:"doc"` // markdown
	Params    []*JSONField `json:"params"`
	Results   []*JSONField `json:"results"`
}

type JSONType

type JSONType struct {
	Name      string `json:"name"`
	Signature string `json:"signature"`
	Doc       string `json:"doc"` // markdown
}

type JSONValue

type JSONValue struct {
	Name string `json:"name"`
	Doc  string `json:"doc"`
	Type string `json:"type"` // often empty
}

type JSONValueDecl

type JSONValueDecl struct {
	Signature string       `json:"signature"`
	Const     bool         `json:"const"`
	Values    []*JSONValue `json:"values"`
	Doc       string       `json:"doc"` // markdown
}

type WriteDocumentationOptions

type WriteDocumentationOptions struct {
	// ShowAll shows all symbols when displaying documentation about a package.
	ShowAll bool
	// Source shows the source code when documenting a symbol.
	Source bool
	// Unexported shows unexported symbols as well as exported.
	Unexported bool
	// Short shows a one-line representation for each symbol.
	Short bool
	// contains filtered or unexported fields
}

WriteDocumentationOptions represents the possible options when requesting documentation through Documentable.

Jump to

Keyboard shortcuts

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