Documentation
¶
Overview ¶
Package gdocs defines the Docs API v1 wire types this server reads. They mirror the JSON schema of documents.get for the fields we use, which keeps the binary free of the generated client's gRPC and telemetry dependency tree. Field names follow Go conventions; JSON tags follow the API.
Index ¶
- func WalkTabs(tabs []*Tab, fn func(*Tab) bool) bool
- type AutoText
- type Background
- type Body
- type Break
- type Bullet
- type Color
- type CommentAnchor
- type CommentThread
- type DateElement
- type DateElementProperties
- type Dimension
- type Document
- type DocumentStyle
- type DocumentTab
- type EmbeddedObject
- type Footer
- type Footnote
- type FootnoteReference
- type Header
- type HeadingLink
- type ImageProperties
- type InlineObject
- type InlineObjectElement
- type InlineObjectProperties
- type Link
- type LinkedContentReference
- type List
- type ListProperties
- type NamedRange
- type NamedRanges
- type NamedStyle
- type NamedStyles
- type NestingLevel
- type OptionalColor
- type Paragraph
- type ParagraphBorder
- type ParagraphElement
- type ParagraphStyle
- type Person
- type PersonProperties
- type PositionedObject
- type PositionedObjectProperties
- type Post
- type PostAuthor
- type Range
- type RgbColor
- type RichLink
- type RichLinkProperties
- type SectionBreak
- type SectionStyle
- type Shading
- type Size
- type StructuralElement
- type Suggested
- type SuggestionThread
- type Tab
- type TabProperties
- type TabStop
- type Table
- type TableCell
- type TableCellBorder
- type TableCellStyle
- type TableOfContents
- type TableRow
- type TextRun
- type TextStyle
- type WeightedFontFamily
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AutoText ¶
type AutoText struct {
Suggested
Type string `json:"type,omitempty"`
TextStyle *TextStyle `json:"textStyle,omitempty"`
}
AutoText is generated text such as a page number.
type Background ¶ added in v0.4.0
type Background struct {
Color *OptionalColor `json:"color,omitempty"`
}
Background is a solid page colour.
type Body ¶
type Body struct {
Content []*StructuralElement `json:"content,omitempty"`
}
Body is the main content segment.
type Bullet ¶
type Bullet struct {
ListID string `json:"listId,omitempty"`
NestingLevel int64 `json:"nestingLevel,omitempty"`
TextStyle *TextStyle `json:"textStyle,omitempty"`
}
Bullet is list membership.
type Color ¶
type Color struct {
RgbColor *RgbColor `json:"rgbColor,omitempty"`
}
Color is an RGB colour.
type CommentAnchor ¶ added in v0.2.0
type CommentAnchor struct {
AnchorID string `json:"anchorId,omitempty"`
Ranges []*Range `json:"ranges,omitempty"`
}
CommentAnchor is where a comment thread is pinned (Developer Preview).
type CommentThread ¶
type CommentThread struct {
CommentID string `json:"commentId,omitempty"`
AnchorID string `json:"anchorId,omitempty"`
HeadPost Post `json:"headPost,omitempty"`
Replies []Post `json:"replies,omitempty"`
Status string `json:"status,omitempty"`
PlainTextQuote string `json:"plainTextQuote,omitempty"`
}
CommentThread is the shape observed live: no range, but the quoted text.
type DateElement ¶
type DateElement struct {
Suggested
DateID string `json:"dateId,omitempty"`
DateElementProperties *DateElementProperties `json:"dateElementProperties,omitempty"`
TextStyle *TextStyle `json:"textStyle,omitempty"`
}
DateElement is a date chip.
type DateElementProperties ¶
type DateElementProperties struct {
DisplayText string `json:"displayText,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
DateFormat string `json:"dateFormat,omitempty"`
TimeFormat string `json:"timeFormat,omitempty"`
Locale string `json:"locale,omitempty"`
TimeZoneID string `json:"timeZoneId,omitempty"`
}
DateElementProperties describe the date chip.
type Dimension ¶
type Dimension struct {
Magnitude float64 `json:"magnitude,omitempty"`
Unit string `json:"unit,omitempty"`
}
Dimension is a magnitude with a unit (PT).
type Document ¶
type Document struct {
DocumentID string `json:"documentId,omitempty"`
Title string `json:"title,omitempty"`
RevisionID string `json:"revisionId,omitempty"`
SuggestionsViewMode string `json:"suggestionsViewMode,omitempty"`
Body *Body `json:"body,omitempty"`
Headers map[string]Header `json:"headers,omitempty"`
Footnotes map[string]Footnote `json:"footnotes,omitempty"`
Lists map[string]List `json:"lists,omitempty"`
InlineObjects map[string]InlineObject `json:"inlineObjects,omitempty"`
PositionedObjects map[string]PositionedObject `json:"positionedObjects,omitempty"`
NamedRanges map[string]NamedRanges `json:"namedRanges,omitempty"`
DocumentStyle *DocumentStyle `json:"documentStyle,omitempty"`
NamedStyles *NamedStyles `json:"namedStyles,omitempty"`
Tabs []*Tab `json:"tabs,omitempty"`
// Developer Preview fields, populated when commentsViewMode asks for them.
Comments []CommentThread `json:"comments,omitempty"`
Suggestions []SuggestionThread `json:"suggestions,omitempty"`
}
Document is the documents.get response.
type DocumentStyle ¶ added in v0.4.0
type DocumentStyle struct {
Background *Background `json:"background,omitempty"`
PageSize *Size `json:"pageSize,omitempty"`
MarginTop *Dimension `json:"marginTop,omitempty"`
MarginBottom *Dimension `json:"marginBottom,omitempty"`
MarginLeft *Dimension `json:"marginLeft,omitempty"`
MarginRight *Dimension `json:"marginRight,omitempty"`
MarginHeader *Dimension `json:"marginHeader,omitempty"`
PageNumberStart int64 `json:"pageNumberStart,omitempty"`
FlipPageOrientation bool `json:"flipPageOrientation,omitempty"`
}
DocumentStyle is a tab's page setup.
type DocumentTab ¶
type DocumentTab struct {
Body *Body `json:"body,omitempty"`
Headers map[string]Header `json:"headers,omitempty"`
Footnotes map[string]Footnote `json:"footnotes,omitempty"`
Lists map[string]List `json:"lists,omitempty"`
InlineObjects map[string]InlineObject `json:"inlineObjects,omitempty"`
// PositionedObjects are floating images, keyed by object id; unlike
// an inline object they sit on a paragraph rather than in its text.
PositionedObjects map[string]PositionedObject `json:"positionedObjects,omitempty"`
// NamedRanges are the tab's named ranges, keyed by name; one name can
// cover several ranges.
NamedRanges map[string]NamedRanges `json:"namedRanges,omitempty"`
DocumentStyle *DocumentStyle `json:"documentStyle,omitempty"`
// NamedStyles are the definitions every paragraph inherits from; a
// paragraph's namedStyleType names the one it uses.
NamedStyles *NamedStyles `json:"namedStyles,omitempty"`
// CommentAnchors map anchor ids to ranges (Developer Preview, with
// commentsViewMode).
CommentAnchors map[string]CommentAnchor `json:"commentAnchors,omitempty"`
}
DocumentTab is a tab's content.
type EmbeddedObject ¶
type EmbeddedObject struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
ImageProperties *ImageProperties `json:"imageProperties,omitempty"`
EmbeddedDrawingProperties *struct{} `json:"embeddedDrawingProperties,omitempty"`
LinkedContentReference *LinkedContentReference `json:"linkedContentReference,omitempty"`
Size *Size `json:"size,omitempty"`
}
EmbeddedObject describes the object.
type Footnote ¶
type Footnote struct {
FootnoteID string `json:"footnoteId,omitempty"`
Content []*StructuralElement `json:"content,omitempty"`
}
Footnote is a footnote segment.
type FootnoteReference ¶
type FootnoteReference struct {
Suggested
FootnoteID string `json:"footnoteId,omitempty"`
FootnoteNumber string `json:"footnoteNumber,omitempty"`
TextStyle *TextStyle `json:"textStyle,omitempty"`
}
FootnoteReference marks a footnote in the body.
type Header ¶
type Header struct {
HeaderID string `json:"headerId,omitempty"`
Content []*StructuralElement `json:"content,omitempty"`
}
Header is a header segment.
type HeadingLink ¶
HeadingLink targets a heading in a tab.
type ImageProperties ¶
type ImageProperties struct {
ContentURI string `json:"contentUri,omitempty"`
SourceURI string `json:"sourceUri,omitempty"`
}
ImageProperties carry image URIs.
type InlineObject ¶
type InlineObject struct {
ObjectID string `json:"objectId,omitempty"`
InlineObjectProperties *InlineObjectProperties `json:"inlineObjectProperties,omitempty"`
}
InlineObject is an embedded image, drawing or chart.
type InlineObjectElement ¶
type InlineObjectElement struct {
Suggested
InlineObjectID string `json:"inlineObjectId,omitempty"`
TextStyle *TextStyle `json:"textStyle,omitempty"`
}
InlineObjectElement references an inline object.
type InlineObjectProperties ¶
type InlineObjectProperties struct {
EmbeddedObject *EmbeddedObject `json:"embeddedObject,omitempty"`
}
InlineObjectProperties wrap the embedded object.
func (*InlineObjectProperties) Embedded ¶ added in v0.4.0
func (p *InlineObjectProperties) Embedded() *EmbeddedObject
Embedded returns the object, or nil when the properties are absent.
type Link ¶
type Link struct {
URL string `json:"url,omitempty"`
HeadingID string `json:"headingId,omitempty"`
BookmarkID string `json:"bookmarkId,omitempty"`
TabID string `json:"tabId,omitempty"`
Heading *HeadingLink `json:"heading,omitempty"`
}
Link is a hyperlink target.
type LinkedContentReference ¶
type LinkedContentReference struct {
SheetsChartReference *struct {
SpreadsheetID string `json:"spreadsheetId,omitempty"`
ChartID int64 `json:"chartId,omitempty"`
} `json:"sheetsChartReference,omitempty"`
}
LinkedContentReference marks a linked chart.
type List ¶
type List struct {
ListProperties *ListProperties `json:"listProperties,omitempty"`
}
List describes a list's nesting levels.
type ListProperties ¶
type ListProperties struct {
NestingLevels []*NestingLevel `json:"nestingLevels,omitempty"`
}
ListProperties hold the nesting levels.
type NamedRange ¶ added in v0.4.0
type NamedRange struct {
NamedRangeID string `json:"namedRangeId,omitempty"`
Name string `json:"name,omitempty"`
Ranges []*Range `json:"ranges,omitempty"`
}
NamedRange is one named span, which may cover several ranges.
type NamedRanges ¶ added in v0.4.0
type NamedRanges struct {
Name string `json:"name,omitempty"`
NamedRanges []NamedRange `json:"namedRanges,omitempty"`
}
NamedRanges is every range sharing one name.
type NamedStyle ¶ added in v0.5.0
type NamedStyle struct {
NamedStyleType string `json:"namedStyleType,omitempty"`
TextStyle *TextStyle `json:"textStyle,omitempty"`
ParagraphStyle *ParagraphStyle `json:"paragraphStyle,omitempty"`
}
NamedStyle is one named style definition: the text and paragraph formatting every paragraph carrying that style inherits.
type NamedStyles ¶ added in v0.5.0
type NamedStyles struct {
Styles []*NamedStyle `json:"styles,omitempty"`
}
NamedStyles holds a tab's named style definitions.
type NestingLevel ¶
type NestingLevel struct {
GlyphType string `json:"glyphType,omitempty"`
GlyphSymbol string `json:"glyphSymbol,omitempty"`
GlyphFormat string `json:"glyphFormat,omitempty"`
StartNumber int64 `json:"startNumber,omitempty"`
}
NestingLevel is one list level's glyph.
type OptionalColor ¶
type OptionalColor struct {
Color *Color `json:"color,omitempty"`
}
OptionalColor wraps a colour that may be unset.
type Paragraph ¶
type Paragraph struct {
Elements []*ParagraphElement `json:"elements,omitempty"`
ParagraphStyle *ParagraphStyle `json:"paragraphStyle,omitempty"`
Bullet *Bullet `json:"bullet,omitempty"`
PositionedObjectIDs []string `json:"positionedObjectIds,omitempty"`
}
Paragraph is a paragraph block.
type ParagraphBorder ¶ added in v0.6.0
type ParagraphBorder struct {
Color *OptionalColor `json:"color,omitempty"`
Width *Dimension `json:"width,omitempty"`
Padding *Dimension `json:"padding,omitempty"`
DashStyle string `json:"dashStyle,omitempty"`
}
ParagraphBorder is one edge of a paragraph's box.
type ParagraphElement ¶
type ParagraphElement struct {
StartIndex int64 `json:"startIndex,omitempty"`
EndIndex int64 `json:"endIndex,omitempty"`
TextRun *TextRun `json:"textRun,omitempty"`
InlineObjectElement *InlineObjectElement `json:"inlineObjectElement,omitempty"`
FootnoteReference *FootnoteReference `json:"footnoteReference,omitempty"`
PageBreak *Break `json:"pageBreak,omitempty"`
ColumnBreak *Break `json:"columnBreak,omitempty"`
HorizontalRule *Break `json:"horizontalRule,omitempty"`
Person *Person `json:"person,omitempty"`
RichLink *RichLink `json:"richLink,omitempty"`
DateElement *DateElement `json:"dateElement,omitempty"`
Equation *Suggested `json:"equation,omitempty"`
AutoText *AutoText `json:"autoText,omitempty"`
}
ParagraphElement is one inline element; exactly one kind is set.
type ParagraphStyle ¶
type ParagraphStyle struct {
NamedStyleType string `json:"namedStyleType,omitempty"`
HeadingID string `json:"headingId,omitempty"`
Alignment string `json:"alignment,omitempty"`
Direction string `json:"direction,omitempty"`
SpacingMode string `json:"spacingMode,omitempty"`
IndentStart *Dimension `json:"indentStart,omitempty"`
IndentEnd *Dimension `json:"indentEnd,omitempty"`
IndentFirstLine *Dimension `json:"indentFirstLine,omitempty"`
LineSpacing float64 `json:"lineSpacing,omitempty"`
SpaceAbove *Dimension `json:"spaceAbove,omitempty"`
SpaceBelow *Dimension `json:"spaceBelow,omitempty"`
KeepWithNext bool `json:"keepWithNext,omitempty"`
KeepLinesTogether bool `json:"keepLinesTogether,omitempty"`
AvoidWidowAndOrphan bool `json:"avoidWidowAndOrphan,omitempty"`
PageBreakBefore bool `json:"pageBreakBefore,omitempty"`
Shading *Shading `json:"shading,omitempty"`
BorderTop *ParagraphBorder `json:"borderTop,omitempty"`
BorderBottom *ParagraphBorder `json:"borderBottom,omitempty"`
BorderLeft *ParagraphBorder `json:"borderLeft,omitempty"`
BorderRight *ParagraphBorder `json:"borderRight,omitempty"`
BorderBetween *ParagraphBorder `json:"borderBetween,omitempty"`
TabStops []*TabStop `json:"tabStops,omitempty"`
}
ParagraphStyle is paragraph formatting. Every field the API accepts on a write is here; tabStops and headingId are read-only per the discovery document, so they are read and never sent.
type Person ¶
type Person struct {
Suggested
PersonID string `json:"personId,omitempty"`
PersonProperties *PersonProperties `json:"personProperties,omitempty"`
TextStyle *TextStyle `json:"textStyle,omitempty"`
}
Person is a people chip.
type PersonProperties ¶
type PersonProperties struct {
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
}
PersonProperties name the person.
type PositionedObject ¶ added in v0.4.0
type PositionedObject struct {
ObjectID string `json:"objectId,omitempty"`
PositionedObjectProperties *PositionedObjectProperties `json:"positionedObjectProperties,omitempty"`
}
PositionedObject is a floating image anchored to a paragraph.
type PositionedObjectProperties ¶ added in v0.4.0
type PositionedObjectProperties struct {
EmbeddedObject *EmbeddedObject `json:"embeddedObject,omitempty"`
}
PositionedObjectProperties wrap the embedded object and its placement.
func (*PositionedObjectProperties) Embedded ¶ added in v0.4.0
func (p *PositionedObjectProperties) Embedded() *EmbeddedObject
Embedded returns the object, or nil when the properties are absent.
type Post ¶
type Post struct {
PostID string `json:"postId,omitempty"`
Content string `json:"content,omitempty"`
Author PostAuthor `json:"author,omitempty"`
CreateTime string `json:"createTime,omitempty"`
UpdateTime string `json:"updateTime,omitempty"`
CommentAction string `json:"commentAction,omitempty"`
SuggestionAction string `json:"suggestionAction,omitempty"`
}
Post is a comment or suggestion post (Developer Preview).
type PostAuthor ¶
type PostAuthor struct {
DisplayName string `json:"displayName,omitempty"`
Me bool `json:"me,omitempty"`
User string `json:"user,omitempty"`
}
PostAuthor identifies who wrote a post.
type Range ¶ added in v0.2.0
type Range struct {
SegmentID string `json:"segmentId,omitempty"`
StartIndex int64 `json:"startIndex,omitempty"`
EndIndex int64 `json:"endIndex,omitempty"`
TabID string `json:"tabId,omitempty"`
}
Range is a half-open UTF-16 range in one segment of one tab.
type RgbColor ¶
type RgbColor struct {
Red float64 `json:"red,omitempty"`
Green float64 `json:"green,omitempty"`
Blue float64 `json:"blue,omitempty"`
}
RgbColor has components in [0, 1].
type RichLink ¶
type RichLink struct {
Suggested
RichLinkID string `json:"richLinkId,omitempty"`
RichLinkProperties *RichLinkProperties `json:"richLinkProperties,omitempty"`
TextStyle *TextStyle `json:"textStyle,omitempty"`
}
RichLink is a smart chip linking to a Drive file or URL.
type RichLinkProperties ¶
type RichLinkProperties struct {
Title string `json:"title,omitempty"`
URI string `json:"uri,omitempty"`
MimeType string `json:"mimeType,omitempty"`
}
RichLinkProperties describe the link target.
type SectionBreak ¶
type SectionBreak struct {
Suggested
SectionStyle *SectionStyle `json:"sectionStyle,omitempty"`
}
SectionBreak starts a section.
type SectionStyle ¶
type SectionStyle struct {
SectionType string `json:"sectionType,omitempty"`
DefaultHeaderID string `json:"defaultHeaderId,omitempty"`
FirstPageHeaderID string `json:"firstPageHeaderId,omitempty"`
}
SectionStyle is the subset of section formatting we read.
type Shading ¶ added in v0.6.0
type Shading struct {
BackgroundColor *OptionalColor `json:"backgroundColor,omitempty"`
}
Shading is a paragraph's background.
type Size ¶
type Size struct {
Width *Dimension `json:"width,omitempty"`
Height *Dimension `json:"height,omitempty"`
}
Size is width and height.
type StructuralElement ¶
type StructuralElement struct {
StartIndex int64 `json:"startIndex,omitempty"`
EndIndex int64 `json:"endIndex,omitempty"`
Paragraph *Paragraph `json:"paragraph,omitempty"`
Table *Table `json:"table,omitempty"`
SectionBreak *SectionBreak `json:"sectionBreak,omitempty"`
TableOfContents *TableOfContents `json:"tableOfContents,omitempty"`
}
StructuralElement is one block of a segment.
type Suggested ¶
type Suggested struct {
SuggestedInsertionIDs []string `json:"suggestedInsertionIds,omitempty"`
SuggestedDeletionIDs []string `json:"suggestedDeletionIds,omitempty"`
}
Suggested carries the suggestion ids most elements can have.
type SuggestionThread ¶
type SuggestionThread struct {
SuggestionID string `json:"suggestionId,omitempty"`
HeadPost Post `json:"headPost,omitempty"`
Replies []Post `json:"replies,omitempty"`
Status string `json:"status,omitempty"`
SummaryText string `json:"summaryText,omitempty"`
}
SuggestionThread is the shape observed live: id, head post, status, summary.
type Tab ¶
type Tab struct {
TabProperties *TabProperties `json:"tabProperties,omitempty"`
DocumentTab *DocumentTab `json:"documentTab,omitempty"`
ChildTabs []*Tab `json:"childTabs,omitempty"`
}
Tab is one tab with its content and children.
type TabProperties ¶
type TabProperties struct {
TabID string `json:"tabId,omitempty"`
Title string `json:"title,omitempty"`
Index int64 `json:"index,omitempty"`
ParentTabID string `json:"parentTabId,omitempty"`
NestingLevel int64 `json:"nestingLevel,omitempty"`
IconEmoji string `json:"iconEmoji,omitempty"`
}
TabProperties identify and place a tab.
type TabStop ¶ added in v0.6.0
type TabStop struct {
Offset *Dimension `json:"offset,omitempty"`
Alignment string `json:"alignment,omitempty"`
}
TabStop is one tab stop. The API reports these and refuses to set them: "This property is read-only" (discovery document).
type Table ¶
type Table struct {
Suggested
Rows int64 `json:"rows,omitempty"`
Columns int64 `json:"columns,omitempty"`
TableRows []*TableRow `json:"tableRows,omitempty"`
}
Table is a table block.
type TableCell ¶
type TableCell struct {
Suggested
StartIndex int64 `json:"startIndex,omitempty"`
EndIndex int64 `json:"endIndex,omitempty"`
Content []*StructuralElement `json:"content,omitempty"`
TableCellStyle *TableCellStyle `json:"tableCellStyle,omitempty"`
}
TableCell is one cell with nested content.
type TableCellBorder ¶ added in v0.6.0
type TableCellBorder struct {
Color *OptionalColor `json:"color,omitempty"`
Width *Dimension `json:"width,omitempty"`
DashStyle string `json:"dashStyle,omitempty"`
}
TableCellBorder is one edge of a cell. Unlike a paragraph border it has no padding: the cell's own padding covers that.
type TableCellStyle ¶
type TableCellStyle struct {
// RowSpan and ColumnSpan are read-only (discovery document); a merge
// is what changes them.
RowSpan int64 `json:"rowSpan,omitempty"`
ColumnSpan int64 `json:"columnSpan,omitempty"`
BackgroundColor *OptionalColor `json:"backgroundColor,omitempty"`
ContentAlignment string `json:"contentAlignment,omitempty"`
PaddingTop *Dimension `json:"paddingTop,omitempty"`
PaddingBottom *Dimension `json:"paddingBottom,omitempty"`
PaddingLeft *Dimension `json:"paddingLeft,omitempty"`
PaddingRight *Dimension `json:"paddingRight,omitempty"`
BorderTop *TableCellBorder `json:"borderTop,omitempty"`
BorderBottom *TableCellBorder `json:"borderBottom,omitempty"`
BorderLeft *TableCellBorder `json:"borderLeft,omitempty"`
BorderRight *TableCellBorder `json:"borderRight,omitempty"`
}
TableCellStyle is the subset of cell formatting we read.
type TableOfContents ¶
type TableOfContents struct {
Suggested
Content []*StructuralElement `json:"content,omitempty"`
}
TableOfContents is a generated, read-only block.
type TableRow ¶
type TableRow struct {
Suggested
StartIndex int64 `json:"startIndex,omitempty"`
EndIndex int64 `json:"endIndex,omitempty"`
TableCells []*TableCell `json:"tableCells,omitempty"`
}
TableRow is one row.
type TextRun ¶
type TextRun struct {
Suggested
Content string `json:"content,omitempty"`
TextStyle *TextStyle `json:"textStyle,omitempty"`
}
TextRun is styled text.
type TextStyle ¶
type TextStyle struct {
Bold bool `json:"bold,omitempty"`
Italic bool `json:"italic,omitempty"`
Underline bool `json:"underline,omitempty"`
Strikethrough bool `json:"strikethrough,omitempty"`
SmallCaps bool `json:"smallCaps,omitempty"`
BaselineOffset string `json:"baselineOffset,omitempty"`
FontSize *Dimension `json:"fontSize,omitempty"`
WeightedFontFamily *WeightedFontFamily `json:"weightedFontFamily,omitempty"`
ForegroundColor *OptionalColor `json:"foregroundColor,omitempty"`
BackgroundColor *OptionalColor `json:"backgroundColor,omitempty"`
Link *Link `json:"link,omitempty"`
}
TextStyle is character formatting.
type WeightedFontFamily ¶
type WeightedFontFamily struct {
FontFamily string `json:"fontFamily,omitempty"`
Weight int64 `json:"weight,omitempty"`
}
WeightedFontFamily is a font name and weight.