Added more doc comments
This commit is contained in:
parent
4ecd5ccaf7
commit
8b746ee3c0
14
hatmill.go
14
hatmill.go
@ -26,11 +26,15 @@ func writeStringsTo(w io.Writer, n *int64, ss ...string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Attrib represents an HTML attribute.
|
||||
type Attrib struct {
|
||||
Key string
|
||||
Value string
|
||||
}
|
||||
|
||||
// WriteTo writes a to w as an HTML attribute in the form key="value", or
|
||||
// simply key if value is empty. It returns the number of bytes written and any
|
||||
// error encountered.
|
||||
func (a Attrib) WriteTo(w io.Writer) (n int64, err error) {
|
||||
err = writeStringsTo(w, &n, a.Key)
|
||||
if err != nil {
|
||||
@ -42,6 +46,8 @@ func (a Attrib) WriteTo(w io.Writer) (n int64, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// EmptyElement represents an empty HTML element, that is one that cannot have
|
||||
// children.
|
||||
type EmptyElement struct {
|
||||
TagName string
|
||||
Attribs []Attrib
|
||||
@ -49,6 +55,8 @@ type EmptyElement struct {
|
||||
|
||||
func (EmptyElement) isHtml() {}
|
||||
|
||||
// WriteTo writes the HTML markup represented by e to w, returning the number
|
||||
// of bytes written and any error encountered.
|
||||
func (e EmptyElement) WriteTo(w io.Writer) (n int64, err error) {
|
||||
err = writeStringsTo(w, &n, "<", e.TagName)
|
||||
if err != nil {
|
||||
@ -73,6 +81,7 @@ func (e EmptyElement) WriteTo(w io.Writer) (n int64, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// ParentElement represents an HTML element that can have children.
|
||||
type ParentElement struct {
|
||||
EmptyElement
|
||||
Children []Term
|
||||
@ -80,6 +89,8 @@ type ParentElement struct {
|
||||
|
||||
func (e ParentElement) isHtml() {}
|
||||
|
||||
// WriteTo writes the HTML markup represented by e to w, returning the number
|
||||
// of bytes written and any error encountered.
|
||||
func (e ParentElement) WriteTo(w io.Writer) (n int64, err error) {
|
||||
n, err = e.EmptyElement.WriteTo(w)
|
||||
if err != nil {
|
||||
@ -99,10 +110,13 @@ func (e ParentElement) WriteTo(w io.Writer) (n int64, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Text represents an HTML text node.
|
||||
type Text string
|
||||
|
||||
func (Text) isHtml() {}
|
||||
|
||||
// WriteTo writes the contents of t to w, returning the number of bytes written
|
||||
// and any error encountered.
|
||||
func (t Text) WriteTo(w io.Writer) (n int64, err error) {
|
||||
err = writeStringsTo(w, &n, string(t))
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user