Copyright 2020 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

package frontend

import (
	
	

	
	
	
)

const (
	pageTypeModule    = "module"
	pageTypeDirectory = "directory"
	pageTypePackage   = "package"
	pageTypeCommand   = "command"
	pageTypeModuleStd = "std"
	pageTypeStdlib    = "standard library"
)
pageTitle determines the pageTitles for a given unit. See TestPageTitlesAndTypes for examples.
func ( *internal.UnitMeta) string {
	switch {
	case .Path == stdlib.ModulePath:
		return "Standard library"
	case .IsCommand():
		return effectiveName(.Path, .Name)
	case .IsPackage():
		return .Name
	case .IsModule():
		, ,  := module.SplitPathVersion(.Path)
		return path.Base()
	default:
		return path.Base(.Path) + "/"
	}
}
pageType determines the pageType for a given unit.
func ( *internal.UnitMeta) string {
	if .Path == stdlib.ModulePath {
		return pageTypeModuleStd
	}
	if .IsCommand() {
		return pageTypeCommand
	}
	if .IsPackage() {
		return pageTypePackage
	}
	if .IsModule() {
		return pageTypeModule
	}
	return pageTypeDirectory
}
pageLabels determines the labels to display for a given unit. See TestPageTitlesAndTypes for examples.
func ( *internal.UnitMeta) []string {
	var  []string
	if .Path == stdlib.ModulePath {
		return nil
	}
	if .IsCommand() {
		 = append(, pageTypeCommand)
	} else if .IsPackage() {
		 = append(, pageTypePackage)
	}
	if .IsModule() {
		 = append(, pageTypeModule)
	}
	if !.IsPackage() && !.IsModule() {
		 = append(, pageTypeDirectory)
	}
	if stdlib.Contains(.Path) {
		 = append(, pageTypeStdlib)
	}
	return 
}
effectiveName returns either the command name or package name.
func (,  string) string {
	if  != "main" {
		return 
	}
	var  string // package path without version
	if [len()-3:] == "/v1" {
		 = [:len()-3]
	} else {
		, _, _ = module.SplitPathVersion()
	}
	,  := path.Split()
	return 
}
absoluteTime takes a date and returns returns a human-readable, date with the format mmm d, yyyy:
Convert to UTC because that is how the date is represented in the DB. (The pgx driver returns local times.) Example: if a date is stored as Jan 30 at midnight, then the local NYC time is on Jan 29, and this function would return "Jan 29" instead of the correct "Jan 30".
	return .In(time.UTC).Format("Jan _2, 2006")