types

package
v0.0.0-...-8e482eb Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package types provide types for format-independent codelab data model.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codelab

type Codelab struct {
	Meta
	Steps []*Step
}

Codelab is a top-level structure containing metadata and codelab steps.

func NewCodelab

func NewCodelab() *Codelab

func (*Codelab) NewStep

func (c *Codelab) NewStep(title string) *Step

NewStep creates a new codelab step, adding it to c.Steps slice.

type Context

type Context struct {
	Env     string       `json:"environment"`       // Current export environment
	Format  string       `json:"format"`            // Output format, e.g. "html"
	Prefix  string       `json:"prefix,omitempty"`  // Assets URL prefix for HTML-based formats
	MainGA  string       `json:"mainga,omitempty"`  // Global Google Analytics ID
	Updated *ContextTime `json:"updated,omitempty"` // Last update timestamp
}

Context is an export context. It is defined in this package so that it can be used by both cli and a server.

type ContextMeta

type ContextMeta struct {
	Context
	Meta
}

ContextMeta is a composition of export context and meta data.

type ContextTime

type ContextTime time.Time

ContextTime is a wrapper around time.Time so we can implement JSON marshalling.

func (ContextTime) MarshalJSON

func (ct ContextTime) MarshalJSON() ([]byte, error)

MarshalJSON implements Marshaler interface. The output format is RFC3339.

func (*ContextTime) UnmarshalJSON

func (ct *ContextTime) UnmarshalJSON(b []byte) error

UnmarshalJSON implements Unmarshaler interface. Accepted formats: - RFC3339 - YYYY-MM-DD

type LegacyStatus

type LegacyStatus []string

LegacyStatus supports legacy status values which are strings as opposed to an array, e.g. "['one', u'two', ...]".

func (LegacyStatus) MarshalJSON

func (s LegacyStatus) MarshalJSON() ([]byte, error)

MarshalJSON implements Marshaler interface.

func (LegacyStatus) String

func (s LegacyStatus) String() string

String turns a status into a string

func (*LegacyStatus) UnmarshalJSON

func (s *LegacyStatus) UnmarshalJSON(b []byte) error

UnmarshalJSON implements Unmarshaler interface.

type Meta

type Meta struct {
	ID         string            `json:"id"`                 // ID is also part of codelab URL
	Duration   int               `json:"duration"`           // Codelab duration in minutes
	Title      string            `json:"title"`              // Codelab title
	Authors    string            `json:"authors,omitempty"`  // Arbitrary authorship text
	Summary    string            `json:"summary"`            // Short summary
	Source     string            `json:"source"`             // Codelab source doc
	Theme      string            `json:"theme"`              // Usually first item of Categories
	Status     *LegacyStatus     `json:"status"`             // Draft, Published, Hidden, etc.
	Categories []string          `json:"category"`           // Categories from the meta table
	Tags       []string          `json:"tags"`               // All environments supported by the codelab
	Feedback   string            `json:"feedback,omitempty"` // Issues and bugs are sent here
	GA         string            `json:"ga,omitempty"`       // Codelab-specific GA tracking ID
	Extra      map[string]string `json:"extra,omitempty"`    // Extra metadata specified in pass_metadata

	URL string `json:"url"` // Legacy ID; TODO: remove
}

Meta contains a single codelab metadata.

type Step

type Step struct {
	Title    string          // Step title
	Tags     []string        // Step environments
	Duration time.Duration   // Duration
	Content  *nodes.ListNode // Root node of the step nodes tree
}

Step is a single codelab step, containing metadata and actual content.

Jump to

Keyboard shortcuts

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