Skip to content

Commit f9a26ac

Browse files
committed
Improve FeedType documentation
1 parent 3507913 commit f9a26ac

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

Sources/FeedKit/FeedType.swift

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,50 @@
2323
//
2424

2525
import Foundation
26-
/// Types of feed.
26+
27+
/// Types of feed: RSS, RDF, Atom, and JSON.
28+
///
29+
/// The `FeedType` enum helps detect the feed format based on raw data.
30+
/// It provides methods to determine if the feed is XML-based or JSON-based.
31+
///
32+
/// **Note:** FeedKit handles the automatic determination of the feed type during
33+
/// parsing, so you generally don't need to manually detect the feed type. However,
34+
/// using `FeedType` can be helpful when you want to identify the feed type without
35+
/// parsing or decoding the entire feed.
36+
///
37+
/// Example using `switch`:
38+
/// ```swift
39+
/// if let feed = FeedType(data: feedData) {
40+
/// switch feed {
41+
/// case .rss:
42+
/// print("RSS feed detected")
43+
/// case .rdf:
44+
/// print("RDF feed detected")
45+
/// case .atom:
46+
/// print("Atom feed detected")
47+
/// case .json:
48+
/// print("JSON feed detected")
49+
/// }
50+
/// }
2751
///
28-
/// - atom: The `Atom Syndication Format` feed type.
29-
/// - rdf: The `Really Simple Syndication` feed type version 0.90.
30-
/// - rss: The `Really Simple Syndication` feed type version 2.0.
31-
/// - json: JSON formatted feed, commonly used for web APIs.
52+
/// Example using `if`:
53+
/// ```swift
54+
/// if let feed = FeedType(data: feedData) {
55+
/// if feed.isXML {
56+
/// print("XML-based feed detected")
57+
/// } else if feed.isJson {
58+
/// print("JSON feed detected")
59+
/// }
60+
/// }
61+
/// ```
3262
public enum FeedType {
63+
/// Represents the RSS 2.0 feed format.
3364
case rss
65+
/// Represents the RDF 0.90 feed format.
3466
case rdf
67+
/// Represents the Atom Syndication Format feed.
3568
case atom
69+
/// Represents a JSON-formatted feed, commonly used in web APIs.
3670
case json
3771
}
3872

0 commit comments

Comments
 (0)