add documentation for pkgdoc

This commit is contained in:
Jason Moiron
2013-01-16 22:08:09 -05:00
parent 852dd01069
commit 02e5b30cb9
+66 -1
View File
@@ -1,5 +1,70 @@
/*
Create feed output in RSS or Atom.
Syndication (feed) generator library for golang.
Installing
go get github.com/jmoiron/syndicate
Syndicate provides a simple, generic Feed interface with a generic Item object as well as RSS and Atom specific RssFeed and AtomFeed objects which allow access to all of each spec's defined elements.
Examples
Create a Feed and some Items in that feed using the generic interfaces:
import (
"time"
. "github.com/jmoiron/syndicate"
)
now = time.Now()
feed := &Feed{
Title: "jmoiron.net blog",
Link: &Link{Href: "http://jmoiron.net/blog"},
Description: "discussion about tech, footie, photos",
Author: &Author{"Jason Moiron", "jmoiron@jmoiron.net"},
Created: now,
Copyright: "This work is copyright © Benjamin Button",
}
feed.Items = []*Item{
&Item{
Title: "Limiting Concurrency in Go",
Link: &Link{Href: "http://jmoiron.net/blog/limiting-concurrency-in-go/"},
Description: "A discussion on controlled parallelism in golang",
Author: &Author{"Jason Moiron", "jmoiron@jmoiron.net"},
Created: now,
},
&Item{
Title: "Logic-less Template Redux",
Link: &Link{Href: "http://jmoiron.net/blog/logicless-template-redux/"},
Description: "More thoughts on logicless templates",
Created: now,
},
&Item{
Title: "Idiomatic Code Reuse in Go",
Link: &Link{Href: "http://jmoiron.net/blog/idiomatic-code-reuse-in-go/"},
Description: "How to use interfaces <em>effectively</em>",
Created: now,
},
}
From here, you can output Atom or RSS versions of this feed easily
atom, err := feed.ToAtom()
rss, err := feed.ToRss()
You can also get access to the underlying objects that syndicate uses to export its XML
atomFeed := &Atom{feed}.AtomFeed()
rssFeed := &Rss{feed}.RssFeed()
From here, you can modify or add each syndication's specific fields before outputting
atomFeed.Subtitle = "plays the blues"
atom, err := ToXML(atomFeed)
rssFeed.Generator = "Golang Syndicate v1.0 (github.com/jmoiron/syndicate)"
rss, err := ToXML(rssFeed)
*/
package syndicate