update the docs to make them more readable

This commit is contained in:
Dylan Greene
2013-09-14 15:35:17 -04:00
parent 205657cb40
commit 89e5c05cff

View File

@@ -10,10 +10,11 @@
## Usage ## Usage
var RSS = require('rss'); ```js
var RSS = require('rss');
/* lets create an rss feed */ /* lets create an rss feed */
var feed = new RSS({ var feed = new RSS({
title: 'title', title: 'title',
description: 'description', description: 'description',
feed_url: 'http://example.com/rss.xml', feed_url: 'http://example.com/rss.xml',
@@ -30,8 +31,8 @@
ttl: '60' ttl: '60'
}); });
/* loop over data and add to feed */ /* loop over data and add to feed */
feed.item({ feed.item({
title: 'item title', title: 'item title',
description: 'use this for the content. It can include html.', description: 'use this for the content. It can include html.',
url: 'http://example.com/article4?this&that', // link to the item url: 'http://example.com/article4?this&that', // link to the item
@@ -40,58 +41,65 @@
author: 'Guest Author', // optional - defaults to feed author property author: 'Guest Author', // optional - defaults to feed author property
date: 'May 27, 2012' // any format that js Date can parse. date: 'May 27, 2012' // any format that js Date can parse.
enclosure : {url:'...', file:'path-to-file'} // optional enclosure : {url:'...', file:'path-to-file'} // optional
}); });
// cache the xml // cache the xml
var xml = feed.xml(); var xml = feed.xml();
```
### Feed Options ### Feed Options
* _title_ <string> Title of your site or feed * `title` **string** Title of your site or feed
* _description_ <string> Optional. Short description of the feed. * `description` _optional_ **string** A short description of the feed.
* _generator_ <string> Optional. Feed generator. * `generator` _optional_ **string** Feed generator.
* _feed_url_ <url> Url to the rss feed. * `feed_url` **url string** Url to the rss feed.
* _site_url_ <url> Url to the site that the feed is for. * `site_url` **url string** Url to the site that the feed is for.
* _image_url_ <url> Optional. Small image for feed readers to use. * `image_url` _optional_ **url string* Small image for feed readers to use.
* _docs_ <url> Optional. Url to documentation on this feed. * `docs` _optional_ **url string** Url to documentation on this feed.
* _author_ <string> Who owns this feed. * `author` **string** Who owns this feed.
* _managingEditor_ <string> Optional. Who manages content in this feed. * `managingEditor` _optional_ **string** Who manages content in this feed.
* _webMaster_ <string> Optional. Who manages feed availability and technical support. * `webMaster` _optional_ **string** Who manages feed availability and technical support.
* _copyright_ <string> Optional. Copyright information for this feed. * `copyright` _optional_ **string** Copyright information for this feed.
* _language_ <string> Optional. The language of the content of this feed. * `language` _optional_ **string** The language of the content of this feed.
* _categories_ <array> Optional. One or more categories this feed belongs to. * `categories` _optional_ **array of strings** One or more categories this feed belongs to.
* _pubDate_ <Date object or date string> Optional. The publication date for content in the feed * `pubDate` _optional_ **Date object or date string** The publication date for content in the feed
* _ttl_ <int> Optional. Number of minutes feed can be cached before refreshing from source. * `ttl` _optional_ **integer** Number of minutes feed can be cached before refreshing from source.
### Item Options ### Item Options
In RSS an item can be used for a blog entry, project update, log entry, etc. Your rss feed In RSS an item can be used for a blog entry, project update, log entry, etc. Your rss feed
an have any number of items. Ten to tenty is usually good. an have any number of items. Ten to twenty is usually good.
* _title_ <string> Title of this particular item. * `title` **string** Title of this particular item.
* _description_ <string> Content for the item. Can contain html but link and image urls must include the server name. * `description` **string** Content for the item. Can contain html but link and image urls must be absolute path including hostname.
(Note: I might change this to content in the next release.) * `url` **url string** Url to the item. This could be a blog entry.
* _url_ <url> Url to the item. This could be a blog entry. * `guid` **unique string** A unique string feed readers use to know if an item is new or has already been seen.
* _guid_ <unique string> A unique string feed readers use to know if an item is new or has already been seen.
If you use a guid never change it. If you don't provide a guid then your item urls must If you use a guid never change it. If you don't provide a guid then your item urls must
be unique. be unique.
* _categories_ <array> Optional. If provided, each array item will be added as a category element * `categories` _optional_ **array of strings** If provided, each array item will be added as a category element
* _author_ <string> Optional. If included it is the name of the item's creator. * `author` _optional_ *string* If included it is the name of the item's creator.
If not provided the item author will be the same as the feed author. This is typical If not provided the item author will be the same as the feed author. This is typical
except on multi-author blogs. except on multi-author blogs.
* _date_ <Date object or date string> The date and time of when the item was created. Feed * `date` **Date object or date string** The date and time of when the item was created. Feed
readers use this to determine the sort order. Some readers will also use it to determine readers use this to determine the sort order. Some readers will also use it to determine
if the content should be presented as unread. if the content should be presented as unread.
### Methods ### Methods
* _item(item_options)_ - add an rss item, article, entry etc. #### `item(item_options)`
* _xml([indent])_ - return the xml. If you pass in true it will use four spaces for indenting. If you prefer
tabs use \t instead of true. Add an rss item/article.
#### `xml([indent])`
Return the xml.
If you pass in `true` it will use four spaces for indenting. If you prefer
tabs pass in `\t` instead of true, or a two space string for two space tabs.
## Tests ## Tests
Mocha tests are included. Use `npm test` to run the tests. Tests included use Mocha. Use `npm test` to run the tests.
$ npm test $ npm test