Added doc comments to generated elements

This commit is contained in:
Brandon Dyck 2019-03-21 22:06:41 -06:00
parent c9d9cc59bc
commit 1e23de1266
2 changed files with 17 additions and 4 deletions

View File

@ -3,6 +3,7 @@
package hatmill
// Html creates a <html> element.
func Html(attribs ...Attrib) func(children ...Term) *ParentElement {
return func(children ...Term) *ParentElement {
return &ParentElement{
@ -14,6 +15,8 @@ func Html(attribs ...Attrib) func(children ...Term) *ParentElement {
}
}
}
// Head creates a <head> element.
func Head(attribs ...Attrib) func(children ...Term) *ParentElement {
return func(children ...Term) *ParentElement {
return &ParentElement{
@ -25,6 +28,8 @@ func Head(attribs ...Attrib) func(children ...Term) *ParentElement {
}
}
}
// Body creates a <body> element.
func Body(attribs ...Attrib) func(children ...Term) *ParentElement {
return func(children ...Term) *ParentElement {
return &ParentElement{
@ -36,6 +41,8 @@ func Body(attribs ...Attrib) func(children ...Term) *ParentElement {
}
}
}
// Div creates a <div> element.
func Div(attribs ...Attrib) func(children ...Term) *ParentElement {
return func(children ...Term) *ParentElement {
return &ParentElement{
@ -47,12 +54,16 @@ func Div(attribs ...Attrib) func(children ...Term) *ParentElement {
}
}
}
// Img creates a <img> element.
func Img(attribs ...Attrib) EmptyElement {
return EmptyElement{
TagName: "img",
Attribs: attribs,
}
}
// Span creates a <span> element.
func Span(attribs ...Attrib) func(children ...Term) *ParentElement {
return func(children ...Term) *ParentElement {
return &ParentElement{

View File

@ -19,11 +19,12 @@ const (
parentType = "parent"
emptyType = "empty"
parentTemplate = `func %s(attribs ...Attrib) func(children ...Term) *ParentElement {
parentTemplate = `// %[1]s creates a <%[2]s> element.
func %[1]s(attribs ...Attrib) func(children ...Term) *ParentElement {
return func(children ...Term) *ParentElement {
return &ParentElement{
EmptyElement: EmptyElement{
TagName: "%s",
TagName: "%[2]s",
Attribs: attribs,
},
Children: children,
@ -31,9 +32,10 @@ const (
}
}
`
emptyTemplate = `func %s(attribs ...Attrib) EmptyElement {
emptyTemplate = `// %[1]s creates a <%[2]s> element.
func %[1]s(attribs ...Attrib) EmptyElement {
return EmptyElement{
TagName: "%s",
TagName: "%[2]s",
Attribs: attribs,
}
}