or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

entry-management.mdextensions.mdfeed-generation.mdfeed-metadata.mdindex.md

feed-generation.mddocs/

0

# Feed Generation

1

2

Core functionality for creating FeedGenerator instances and generating ATOM and RSS feed output in various formats.

3

4

## Capabilities

5

6

### FeedGenerator Class

7

8

The main class for creating and configuring web feeds.

9

10

```python { .api }

11

class FeedGenerator:

12

def __init__(self):

13

"""

14

Create a new FeedGenerator instance.

15

16

Initializes empty feed with default generator metadata.

17

"""

18

```

19

20

### ATOM Feed Generation

21

22

Generate ATOM 1.0 format feeds as strings or files.

23

24

```python { .api }

25

def atom_str(self, pretty=False, extensions=True, encoding='UTF-8', xml_declaration=True):

26

"""

27

Generate ATOM feed as string.

28

29

Args:

30

pretty (bool): Pretty print XML with indentation

31

extensions (bool): Include loaded extensions in output

32

encoding (str): Character encoding for output

33

xml_declaration (bool): Include XML declaration in output

34

35

Returns:

36

bytes: ATOM feed XML as encoded bytes

37

"""

38

39

def atom_file(self, filename, extensions=True, pretty=False, encoding='UTF-8', xml_declaration=True):

40

"""

41

Write ATOM feed to file.

42

43

Args:

44

filename (str): Output file path

45

extensions (bool): Include loaded extensions in output

46

pretty (bool): Pretty print XML with indentation

47

encoding (str): Character encoding for output

48

xml_declaration (bool): Include XML declaration in output

49

50

Returns:

51

str: The filename that was written

52

"""

53

```

54

55

### RSS Feed Generation

56

57

Generate RSS 2.0 format feeds as strings or files.

58

59

```python { .api }

60

def rss_str(self, pretty=False, extensions=True, encoding='UTF-8', xml_declaration=True):

61

"""

62

Generate RSS feed as string.

63

64

Args:

65

pretty (bool): Pretty print XML with indentation

66

extensions (bool): Include loaded extensions in output

67

encoding (str): Character encoding for output

68

xml_declaration (bool): Include XML declaration in output

69

70

Returns:

71

bytes: RSS feed XML as encoded bytes

72

"""

73

74

def rss_file(self, filename, extensions=True, pretty=False, encoding='UTF-8', xml_declaration=True):

75

"""

76

Write RSS feed to file.

77

78

Args:

79

filename (str): Output file path

80

extensions (bool): Include loaded extensions in output

81

pretty (bool): Pretty print XML with indentation

82

encoding (str): Character encoding for output

83

xml_declaration (bool): Include XML declaration in output

84

85

Returns:

86

str: The filename that was written

87

"""

88

```

89

90

## Usage Examples

91

92

### Basic Feed Generation

93

94

```python

95

from feedgen.feed import FeedGenerator

96

97

fg = FeedGenerator()

98

fg.id('http://example.com/feed')

99

fg.title('My Feed')

100

fg.author({'name': 'Author Name', 'email': 'author@example.com'})

101

fg.link(href='http://example.com', rel='alternate')

102

fg.description('Feed description')

103

fg.language('en')

104

105

# Generate pretty-printed ATOM feed

106

atom_feed = fg.atom_str(pretty=True)

107

print(atom_feed.decode('utf-8'))

108

109

# Generate RSS feed

110

rss_feed = fg.rss_str(pretty=True)

111

print(rss_feed.decode('utf-8'))

112

```

113

114

### File Output

115

116

```python

117

# Write feeds to files

118

fg.atom_file('output.atom', pretty=True)

119

fg.rss_file('output.rss', pretty=True)

120

121

# Generate without extensions

122

atom_no_ext = fg.atom_str(extensions=False)

123

rss_no_ext = fg.rss_str(extensions=False)

124

```

125

126

### Custom Encoding

127

128

```python

129

# Generate with different encoding

130

atom_utf16 = fg.atom_str(encoding='UTF-16', pretty=True)

131

fg.atom_file('feed_utf16.atom', encoding='UTF-16')

132

```