Skip to content

Commit a69f166

Browse files
committed
Update README
1 parent 7b3aad7 commit a69f166

File tree

1 file changed

+88
-83
lines changed

1 file changed

+88
-83
lines changed

README.md

Lines changed: 88 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ FeedKit is a Swift library for Parsing and Generating RSS, Atom, and JSON feeds.
77

88
### FeedKit v10 :warning:
99

10-
FeedKit `v10` is currently in **beta**. It should be stable enough :eyes:, but if stable enough is not enough, consider using **[`v9`](https://github.com/nmdias/FeedKit/releases/tag/9.1.2)** for now. The beta version includes a new parsing engine, features and improvements, and may contain bugs that still need to be ironed out and unit tested.
10+
FeedKit **[`v10`](https://github.com/nmdias/FeedKit)** is currently in **beta**. It should be stable enough :eyes:, but if stable enough is not enough, consider using **[`v9`](https://github.com/nmdias/FeedKit/releases/tag/9.1.2)** for now. The beta version includes a new parsing engine, features and improvements, and may contain bugs that still need to be ironed out and unit tested.
1111

1212
## Features
1313

1414
- [x] [Atom](https://tools.ietf.org/html/rfc4287)
15-
- [x] RSS [0.90](http://www.rssboard.org/rss-0-9-0), [0.91](http://www.rssboard.org/rss-0-9-1), [1.00](http://web.resource.org/rss/1.0/spec), [2.00](http://cyber.law.harvard.edu/rss/rss.html)
16-
- [x] JSON [1.0](https://jsonfeed.org/version/1)
15+
- [x] [RSS](http://cyber.law.harvard.edu/rss/rss.html)
16+
- [x] [JSON](https://jsonfeed.org)
1717
- [x] Namespaces
1818
- [x] [Atom](http://www.w3.org/2005/Atom)
1919
- [x] [Dublin Core](http://purl.org/dc/elements/1.1/)
@@ -30,18 +30,24 @@ FeedKit `v10` is currently in **beta**. It should be stable enough :eyes:, but i
3030

3131
## Usage
3232

33-
The `RSSFeed`, `AtomFeed` and `JSONFeed` structs makes it easy to fetch and parse feeds from a URL. Here's how to use it:
33+
The `Feed`, `RSSFeed`, `AtomFeed` and `JSONFeed` types makes it easy to fetch and parse feeds. Here's how to use them:
34+
35+
### Dedicated Feed Parser
36+
37+
If you know the type of feed that is expected, you can use a dedicated type, such as:
3438

3539
```swift
3640
try await RSSFeed(urlString: "https://developer.apple.com/news/rss/news.rss")
3741
```
3842

39-
## Universal Feed Parser
43+
### Universal Feed Parser
44+
45+
If you don't know the type of feed, use the `Feed` enum.
4046

41-
The `Feed` enum allows you to handle various feed formats, including `RSS`, `Atom`, `RDF`, and `JSON` feeds. This makes it a versatile solution for parsing any type of feed.
47+
The `Feed` enum type allows you to handle various feed formats, including **RSS**, **Atom** and **JSON** feeds. This makes it a versatile solution for parsing any type of feed.
4248

4349
```swift
44-
// Initialize and parse a feed
50+
// Fetch and parse a feed
4551
let feed = try await Feed(urlString: "https://example.com/feed")
4652

4753
// Use a switch to handle different feeds explicitly
@@ -53,12 +59,57 @@ case let .json(feed): // JSON Feed Model
5359
}
5460

5561
// Or through optional properties
56-
feed.rssFeed // feed.atomFeed, feed.jsonFeed, ...
62+
feed.rss // feed.atom, feed.rdf, feed.json, ...
63+
```
64+
65+
### Initializers
66+
67+
All feed types provide multiple initializers. They provide a flexible way to fetch and parse feeds from the most common sources.
68+
69+
<details>
70+
<summary>Show</summary>
71+
72+
From a URL `String`:
73+
74+
```swift
75+
init(urlString: String) async throws
76+
```
77+
78+
From a `URL`, handling both local file URLs and remote URLs:
79+
80+
```swift
81+
init(url: URL) async throws
82+
```
83+
84+
From a local file `URL`:
85+
86+
```swift
87+
init(fileURL url: URL) throws
88+
```
89+
90+
From a remote `URL`:
91+
92+
```swift
93+
init(remoteURL url: URL) async throws
94+
```
95+
96+
From an XML or JSON `String`:
97+
98+
```swift
99+
init(string: String) throws
100+
```
101+
102+
From raw `Data`:
103+
104+
```swift
105+
init(data: Data) throws
57106
```
58107

108+
</details>
109+
59110
## Feed Generation
60111

61-
To generate XML for a Feed, create an instance of an `RSSFeed`, `AtomFeed` or `JSONFeed` and populate it with the necessary data.
112+
To generate an XML string for any given XML feed, create an instance of an `RSSFeed` or `AtomFeed` and populate it with the necessary data.
62113

63114
```swift
64115
let feed = RSSFeed(
@@ -106,89 +157,43 @@ let xmlString = try feed.toXMLString(formatted: true)
106157

107158
</details>
108159

109-
## Initializers
110-
111-
All Feed types, `Feed`, `RSSFeed`, `JSON...` provide various initializers for flexibility in loading and parsing feed data.
112-
113-
<details>
114-
<summary>Show</summary>
115-
116-
From a URL `String`:
117-
118-
```swift
119-
init(urlString: String) async throws
120-
```
121-
122-
From a `URL`, handling both local file URLs and remote URLs:
123-
124-
```swift
125-
init(url: URL) async throws
126-
```
127-
128-
From a local file `URL`:
129-
130-
```swift
131-
init(fileURL url: URL) throws
132-
```
133-
134-
From a remote `URL`:
135-
136-
```swift
137-
init(remoteURL url: URL) async throws
138-
```
139-
140-
From an XML or JSON `String`:
141-
142-
```swift
143-
init(string: String) throws
144-
```
145-
146-
From raw `Data`:
147-
148-
```swift
149-
init(data: Data) throws
150-
```
151-
152-
These initializers provide a flexible way to load feeds from the most common sources.
153-
154-
</details>
155-
156160
## Feed Models
157161

158-
The `RSS`, `Atom`, and `JSON` feed models are highly comprehensive, especially when combined with the supported namespaces. Below is just a small preview of what’s available.
162+
The **RSS**, **Atom**, and **JSON** feed models are highly comprehensive, especially when combined with all the supported namespaces. Below is a small preview of what’s available.
159163

160164
<details>
161165
<summary>Preview</summary>
162166

163167
#### RSS
164168

165169
```swift
166-
feed.title
167-
feed.link
168-
feed.description
169-
feed.language
170-
feed.copyright
171-
feed.managingEditor
172-
feed.webMaster
173-
feed.pubDate
174-
feed.lastBuildDate
175-
feed.categories
176-
feed.generator
177-
feed.docs
178-
feed.cloud
179-
feed.rating
180-
feed.ttl
181-
feed.image
182-
feed.textInput
183-
feed.skipHours
184-
feed.skipDays
185-
//...
186-
feed.dublinCore
187-
feed.syndication
188-
feed.iTunes
170+
channel.title
171+
channel.link
172+
channel.description
173+
channel.language
174+
channel.copyright
175+
channel.managingEditor
176+
channel.webMaster
177+
channel.pubDate
178+
channel.lastBuildDate
179+
channel.categories
180+
channel.generator
181+
channel.docs
182+
channel.cloud
183+
channel.rating
184+
channel.ttl
185+
channel.image
186+
channel.textInput
187+
channel.skipHours
188+
channel.skipDays
189+
// ...
190+
channel.dublinCore
191+
channel.syndication
192+
channel.iTunes
193+
channel.atom
189194
// ...
190195

191-
let item = feed.items?.first
196+
let item = channel.items?.first
192197

193198
item?.title
194199
item?.link
@@ -239,6 +244,8 @@ entry?.published
239244
entry?.source
240245
entry?.rights
241246
// ...
247+
entry?.media
248+
entry?.youTube
242249
```
243250

244251
#### JSON
@@ -256,7 +263,6 @@ feed.favicon
256263
feed.author
257264
feed.expired
258265
feed.hubs
259-
feed.extensions
260266
// ...
261267

262268
let item = feed.items?.first
@@ -276,7 +282,6 @@ item?.author
276282
item?.url
277283
item?.tags
278284
item?.attachments
279-
item?.extensions
280285
// ...
281286
```
282287

0 commit comments

Comments
 (0)