server

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UpdateTip_Nothing = iota
	UpdateTip_ToUpdate
	UpdateTip_Updating
	UpdateTip_Updated
)
View Source
const (
	WdPkgsListingManner_general  = "general"
	WdPkgsListingManner_promoted = "promoted"
	WdPkgsListingManner_solo     = "solo"

	FooterShowingManner_none               = "none"
	FooterShowingManner_simple             = "simple"
	FooterShowingManner_verbose            = "verbose"
	FooterShowingManner_verbose_and_qrcode = "verbose+qrcode"

	SourceReadingStyle_plain     = "plain"
	SourceReadingStyle_highlight = "highlight"
	SourceReadingStyle_rich      = "rich"
	SourceReadingStyle_external  = "external" // auto detect project hosting URL
)
View Source
const (
	ResTypeNone           pageResType = ""
	ResTypeAPI            pageResType = "api"
	ResTypeModule         pageResType = "mod"
	ResTypePackage        pageResType = "pkg"
	ResTypeDependency     pageResType = "dep"
	ResTypeImplementation pageResType = "imp"
	ResTypeSource         pageResType = "src"
	ResTypeReference      pageResType = "use"
	ResTypeCSS            pageResType = "css"
	ResTypeJS             pageResType = "jvs"
	ResTypeSVG            pageResType = "svg"
	ResTypePNG            pageResType = "png"
)
View Source
const (
	DotMStyle_Unexported = -1
	DotMStyle_NotShow    = 0
	DotMStyle_Exported   = 1
)
View Source
const (
	Phase_Unprepared = iota
	Phase_Analyzed
)
View Source
const DurationToUpdate = time.Hour * 24 * 128
View Source
const MainPkgArrowCharCount = 1
View Source
const PkgDocArrowCharCount = 1
View Source
const Size = 1024 * 1024

Variables

View Source
var (
	BoldTagStart = []byte("<b>")
	BoldTagEnd   = []byte("</b>")
)
View Source
var (
	StarSlash = []byte("*/")
)
View Source
var UpdateTip2DivID = []string{
	UpdateTip_Nothing:  "",
	UpdateTip_ToUpdate: "to-update",
	UpdateTip_Updating: "updating",
	UpdateTip_Updated:  "updated",
}

Functions

func BuildLineOffsets

func BuildLineOffsets(content []byte, onlyStatLineCount bool) (int, []int)

func DotDotSlashes

func DotDotSlashes(count int) string

func FindPackageCommonPrefixPaths

func FindPackageCommonPrefixPaths(pa, pb string) string

func GenDocs

func GenDocs(options PageOutputOptions, args []string, outputDir string, silentMode bool, printUsage func(io.Writer), increaseGCFrequency bool, viewDocsCommand func(string) string)

func GenTestData

func GenTestData(args []string, outputDir string, silent bool, printUsage func(io.Writer))

func GoldsUpdateGoSubCommand added in v0.1.8

func GoldsUpdateGoSubCommand(pkgPath string) string

func ImprovePackagesForListing

func ImprovePackagesForListing(pkgs []*PackageForListing)

func NewHtmlPage

func NewHtmlPage(goldsVersion, title string, theme Theme, translation Translation, currentPageInfo pagePathInfo) *htmlPage

func ParseGoVersion added in v0.1.8

func ParseGoVersion(versionStr []byte) (major, minor int64, err error)

func PreviousVersion

func PreviousVersion(version string) string

Return "" for invalid. Assume the digits of major/minor/patch are all from 0 to 9.

func RelativePath

func RelativePath(a, b string) string

func Run

func Run(options PageOutputOptions, args []string, recommendedPort string, silentMode bool, printUsage func(io.Writer), appPkgPath string, roughBuildTime func() time.Time)

Types

type BuildSourceLinkFunc added in v0.2.7

type BuildSourceLinkFunc func(w writer, commit, extraPath, sourcePath, line, endLine string) error

type ChanCommOprator

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

func (*ChanCommOprator) End

func (ccp *ChanCommOprator) End() token.Pos

func (*ChanCommOprator) Pos

func (ccp *ChanCommOprator) Pos() token.Pos

type CodeHost added in v0.2.7

type CodeHost struct {
	ModulePathPrefix string
	// RepositryCharacteristics and GuessRepositryFromSourceURL should be both blank or both non-blank.
	// If it is not blank, the first one in it must be a prefix starting with "https://".
	// Others are character substrings.
	RepositryCharacteristics []string
	// If len(RepositryCharacteristics) > 0, prefix == RepositryCharacteristics[0].
	// And url is prefixed with prefix.
	GuessRepositryFromSourceURL   func(url, prefix string) (repo string, extra string)
	GuessRepositoryFromModulePath func(modulePath string) (repo string, extra string)

	// Only for the hosts which RepositryCharacteristics[0] is available.
	BuildSourceLink BuildSourceLinkFunc
}

type Content

type Content [][]byte // all []byte with capacity Size

func (Content) DataLength

func (c Content) DataLength() int

type ContentPool

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

type FileInfo

type FileInfo struct {
	Filename     string
	MainPosition *token.Position // for main packages only
	Resources    []ResourceWithPosition
	//HasDocs      bool
	DocText                  string
	DocStartLine, DocEndLine int32
}

type KeywordToken

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

see https://groups.google.com/forum/#!topic/golang-tools/PaJBT2WjEPQ

func (*KeywordToken) End

func (kw *KeywordToken) End() token.Pos

func (*KeywordToken) Pos

func (kw *KeywordToken) Pos() token.Pos

type LoadingLogMessage

type LoadingLogMessage struct {
	ID      int
	Message string
}

type MethodImplementationResult

type MethodImplementationResult struct {
	TypeName    *code.TypeName
	Package     *code.Package
	IsInterface bool

	Methods []MethodImplementations

	NonImplementingMethodCount int32
}

type MethodImplementations

type MethodImplementations struct {
	Method          *code.Selector
	Implementations []MethodInfo
}

type MethodInfo

type MethodInfo struct {
	Method    *code.Selector
	Receiver  *TypeForListing
	Explicit  bool // whether or not the method is explicit
	Interface bool // whether or not the Owner is an interface type
}

type ObjectReferences

type ObjectReferences struct {
	Pkg          *code.Package
	CommonPath   string // relative to the current package
	InCurrentPkg bool
	Identifiers  []code.Identifier
}

type Overview

type Overview struct {
	Packages []*PackageForListing

	code.Stats
}

type PackageDependencyInfo

type PackageDependencyInfo struct {
	Name       string
	ImportPath string
	Index      int

	Imports     []*PackageForListing
	ImportedBys []*PackageForListing
}

type PackageDetails

type PackageDetails struct {
	Package *code.Package

	IsStandard bool
	Index      int
	Name       string
	ImportPath string

	NumDeps     uint32
	NumDepedBys uint32

	Files []FileInfo
	//TypeNames []*TypeDetails
	TypeNames []ResourceWithPosition
	////ValueResources []code.ValueResource
	//Functions        []code.ValueResource
	//Variables        []code.ValueResource
	//Constants        []code.ValueResource
	Functions []ResourceWithPosition
	Variables []ResourceWithPosition
	Constants []ResourceWithPosition

	NumExportedTypeNames uint32
	NumExportedFunctions uint32
	NumExportedVariables uint32
	NumExportedConstants uint32

	// ToDo: use go/doc
	//IntroductionCode template.HTML
	Examples       []*doc.Example
	ExampleFileSet *token.FileSet
}

type PackageForListing

type PackageForListing struct {
	Package *code.Package

	Index     int
	Name      string
	Path      string // blank for not analyzed yet
	Prefix    string // the part shared with the last one in list
	Remaining string // the part different from the last one in list

	Module string // module path

	OneLineDoc string

	NumImportedBys int32
	DepHeight      int32
	DepDepth       int32 // The value mains how close to main pacakges.
	LOC            int32

	//IsStandard         bool
	InWorkingDirectory bool
}

type PageOutputOptions added in v0.1.8

type PageOutputOptions struct {
	GoldsVersion string

	PreferredLang string

	NoStatistics           bool
	NoIdentifierUsesPages  bool
	NotCollectUnexporteds  bool
	AllowNetworkConnection bool
	VerboseLogs            bool
	RenderDocLinks         bool
	UnfoldAllInitially     bool
	SourceReadingStyle     string
	WdPkgsListingManner    string
	FooterShowingManner    string
	Theme                  string
}

type ReferencesResult

type ReferencesResult struct {
	Package    *code.Package
	Identifier string
	Resource   code.Resource
	Selector   *code.Selector // non-nil for fields and methods
	References []*ObjectReferences
	UsesCount  int
}

type ResourceWithPosition added in v0.2.0

type ResourceWithPosition struct {
	Position  token.Position
	FileIndex int32 // -1 means owner file not found
	Offset    int32

	//Res code.Resource
	// Use the following two instead of the above one to avoid
	// 1. change much code
	// 2. too many type assertions
	Type  *TypeDetails       // for PackageDetails.TypeNames only. Alway nil for FileInfo.
	Value code.ValueResource // also for TypeNames in FileInfo
}

type SelectorForListing added in v0.2.0

type SelectorForListing struct {
	*code.Selector
	Middles []*code.Field
	// contains filtered or unexported fields
}

type SourceFileAnalyzeResult

type SourceFileAnalyzeResult struct {
	PkgPath         string
	BareFilename    string
	OriginalPath    string
	GeneratedPath   string
	Lines           []string
	NumRatios       int32 // not including import idendifiers
	NumImportRatios int32
	DocStartLine    int
	DocEndLine      int
}

type TestData_Package

type TestData_Package struct {
	Types      map[string]TestData_Type
	VarNames   []string
	ConstNames []string
	FuncNames  []string
}

type TestData_Type

type TestData_Type struct {
	FieldNames         []string
	MethodNames        []string
	ImplementedByCount int
	ImplementCount     int
	ValueCount         int
	AsInputCount       int
	AsOutputCount      int
	IsAlias            bool // ignore aliases in checking
}

type Theme

type Theme interface {
	Name() string
	CSS() string
}

type Translation

type Translation interface {
	Name() string
	LangTag() string

	// common
	Text_Space() string
	Text_Comma() string
	Text_Colon(atLineEnd bool) string
	Text_Period(paragraphEnd bool) string
	Text_Parenthesis(close bool) string
	Text_EnclosedInOarentheses(text string) string
	Text_PreferredFontList() string

	// server
	Text_Server_Started() string

	// analyzing
	Text_Analyzing() string
	Text_AnalyzingRefresh(currentPageURL string) string // also used in other pages
	Text_Analyzing_Start() string
	Text_Analyzing_Done(d time.Duration, memoryUse string) string

	Text_Analyzing_PreparationDone(d time.Duration) string // ToDo: merge these into one?
	Text_Analyzing_NFilesParsed(numFiles int, d time.Duration) string
	Text_Analyzing_ParsePackagesDone(numFiles int, d time.Duration) string
	Text_Analyzing_CollectPackages(numMods int, d time.Duration) string
	Text_Analyzing_CollectModules(numPkgs int, d time.Duration) string
	Text_Analyzing_CollectExamples(d time.Duration) string
	Text_Analyzing_SortPackagesByDependencies(d time.Duration) string
	Text_Analyzing_CollectDeclarations(d time.Duration) string
	Text_Analyzing_CollectRuntimeFunctionPositions(d time.Duration) string
	//Text_Analyzing_ConfirmTypeSources(d time.Duration) string
	Text_Analyzing_CollectSelectors(d time.Duration) string
	Text_Analyzing_FindImplementations(d time.Duration) string
	Text_Analyzing_RegisterInterfaceMethodsForTypes(d time.Duration) string
	Text_Analyzing_MakeStatistics(d time.Duration) string
	Text_Analyzing_CollectSourceFiles(d time.Duration) string
	Text_Analyzing_CollectObjectReferences(d time.Duration) string
	Text_Analyzing_CacheSourceFiles(d time.Duration) string

	// overview page
	Text_Overview() string
	Text_PackageList() string
	Text_StatisticsWithMoreLink(detailedStatsLink string) string
	Text_SimpleStats(stats *code.Stats) string
	Text_Modules() string                                    // to use
	Text_BelongingModule() string                            // to use
	Text_RequireStat(numRequires, numRequiredBys int) string // to use
	Text_UpdateTip(tipName string) string                    // tip names: "ToUpdate", "Updating", "Updated"

	Text_SortBy(whatToSort string) string // also used in other pages
	Text_SortByItem(by string) string     // also used in other pages

	// package details page
	Text_Package(pkgPath string) string
	Text_BelongingPackage() string // also used in source code page
	Text_PackageDocsLinksOnOtherWebsites(pkgPath string, isStdPkg bool) string
	Text_ImportPath() string
	Text_ImportStat(numImports, numImportedBys int, depPageURL string) string
	Text_InvolvedFiles(num int) string
	Text_Examples(num int) string
	Text_PackageLevelTypeNames() string
	Text_TypeParameters() string
	//Text_AllPackageLevelValues(num int) string
	Text_PackageLevelFunctions() string
	Text_PackageLevelVariables() string
	Text_PackageLevelConstants() string
	Text_PackageLevelResourceSimpleStat(statsAreExact bool, num, numExporteds int, mentionExporteds bool) string
	Text_UnexportedResourcesHeader(show bool, numUnexporteds int, exact bool) string
	Text_ListUnexportes() string

	Text_BasicType() string
	Text_Fields() string // ToDo: merge these into one?
	Text_Methods() string
	Text_ImplementedBy() string
	Text_Implements() string
	Text_AsOutputsOf() string
	Text_AsInputsOf() string
	Text_AsTypesOf() string

	// package dependencies page
	Text_DependencyRelations(pkgPath string) string // also used in package details page with a blank argument.
	Text_Imports() string
	Text_ImportedBy() string

	// method implementation page
	Text_MethodImplementations() string
	Text_NumMethodsImplementingNothing(count int) string
	Text_ViewMethodImplementations() string

	// object references(uses) page
	Text_ReferenceList() string
	Text_CurrentPackage() string
	Text_ObjectKind(kind string) string
	Text_ObjectUses(num int) string // also used in other pages

	// source code page
	Text_SourceCode(pkgPath, bareFilename string) string
	Text_SourceFilePath() string
	Text_GeneratedFrom() string

	// statistics
	Text_Statistics() string
	Text_ChartTitle(chartName string) string
	Text_StatisticsTitle(titleName string) string
	Text_PackageStatistics(values map[string]interface{}) []string
	Text_TypeStatistics(values map[string]interface{}) []string
	Text_ValueStatistics(values map[string]interface{}) []string
	Text_Othertatistics(values map[string]interface{}) []string

	// Footer
	Text_GeneratedPageFooter(goldsVersion, qrCodeLink, goOS, goArch string) string
	Text_GeneratedPageFooterSimple(goldsVersion, goOS, goArch string) string
}

type TypeDetails added in v0.2.0

type TypeDetails struct {
	TypeName         *code.TypeName
	AllListsAreBlank bool
	Popularity       int

	Aliases []*TypeForListing // excluding self if self is an alias.

	Fields             []*SelectorForListing // []*code.Selector
	Methods            []*code.Selector
	NumExportedFields  int32
	NumExportedMethods int32

	ImplementedBys      []*TypeForListing
	Implements          []*TypeForListing
	NumExportedImpedBys int32
	NumExportedImpls    int32

	AsInputsOf              []*ValueForListing
	AsOutputsOf             []*ValueForListing
	NumExportedAsInputsOfs  int32
	NumExportedAsOutputsOfs int32

	Values            []*ValueForListing
	NumExportedValues int32
}

type TypeForListing

type TypeForListing struct {
	//*code.TypeName
	//Instantiated *InstantiatedInfo
	//IsOriginType bool
	BaseType         *code.TypeInfo
	NameWithTypeArgs string // for sorting purpose

	IsPointer    bool
	InCurrentPkg bool
	CommonPath   string // relative to the current package
}

type ValueForListing

type ValueForListing struct {
	code.ValueResource
	InCurrentPkg bool
	CommonPath   string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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