Skip to content

Commit 6c33175

Browse files
committed
small formatting & naming updates
Addresses @Guts suggestions. Thanks!
1 parent d931339 commit 6c33175

File tree

8 files changed

+53
-52
lines changed

8 files changed

+53
-52
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,21 @@ plugins:
5353
datetime_format: "%Y-%m-%d %H:%M"
5454
default_time: "09:30"
5555
default_timezone: Europe/Paris
56-
description: "My custom feed description" # MkDocs site_description: will be used if this key is not present
5756
enabled: true
57+
feed_description: "My custom feed description" # MkDocs site_description: will be used if this key is not present
5858
feeds_filenames:
5959
json_created: feed_json_created.json
6060
json_updated: feed_json_updated.json
6161
rss_created: feed_rss_created.xml
6262
rss_updated: feed_rss_updated.xml
63+
feed_title: "My custom feed title" # MkDocs site_name: will be used if this key is not present
6364
feed_ttl: 1440
6465
image: https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Feed-icon.svg/128px-Feed-icon.svg.png
6566
json_feed_enabled: true
6667
length: 20
6768
match_path: ".*"
6869
pretty_print: false
6970
rss_feed_enabled: true
70-
title: "My custom feed title" # MkDocs site_name: will be used if this key is not present
7171
url_parameters:
7272
utm_source: "documentation"
7373
utm_medium: "RSS"

docs/configuration.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,9 @@ At the end, into the RSS you will get:
367367

368368
----
369369

370-
### :material-subtitles: `description`: override site description { #description }
370+
### :material-subtitles: `feed_description`: override site description { #description }
371371

372-
This option allows you to override the default MkDocs site description for the description tag in this RSS feed.
372+
This option allows you to override the default MkDocs site description for the description tag in this feed.
373373
This is useful if you have multiple instances of this plugin for multiple feeds. (For example, one feed
374374
for the blog, and a second for documentation updates.)
375375

@@ -378,13 +378,45 @@ This setting is optional. If you do not include it, the default site description
378378
```yaml
379379
plugins:
380380
- rss:
381-
description: The best blog from the best site
381+
feed_description: The best blog from the best site
382382
```
383383
384384
Default: Use the default MkDocs `site_description:`.
385385

386386
----
387387

388+
### :material-format-title: `feed_title`: override site title { #title }
389+
390+
This option allows you to override the default MkDocs site name for the title tag in this feed.
391+
This is useful if you have multiple instances of this plugin for multiple feeds. (For example, one feed
392+
for the blog, and a second for documentation updates.)
393+
394+
This setting is optional. If you do not include it, the default site name will be used.
395+
396+
```yaml
397+
plugins:
398+
- rss:
399+
feed_title: My awesome blog feed
400+
```
401+
402+
Default: Use the default MkDocs `site_name:`.
403+
404+
----
405+
406+
### :material-clock-end: `feed_ttl`: feed's cache time { #feed_ttl }
407+
408+
`feed_ttl`: number of minutes to be cached. Inserted as channel `ttl` element. See: [W3C RSS 2.0 documentation](https://www.w3schools.com/xml/rss_tag_ttl.asp).
409+
410+
Default: `1440` (= 1 day)
411+
412+
Output:
413+
414+
```xml
415+
<ttl>1440</ttl>
416+
```
417+
418+
----
419+
388420
### :material-alphabet-latin: `feeds_filenames`: customize the output feed URL { #feeds_filenames }
389421

390422
> Since version 1.13.0.
@@ -410,20 +442,6 @@ Default:
410442

411443
----
412444

413-
### :material-clock-end: `feed_ttl`: feed's cache time { #feed_ttl }
414-
415-
`feed_ttl`: number of minutes to be cached. Inserted as channel `ttl` element. See: [W3C RSS 2.0 documentation](https://www.w3schools.com/xml/rss_tag_ttl.asp).
416-
417-
Default: `1440` (= 1 day)
418-
419-
Output:
420-
421-
```xml
422-
<ttl>1440</ttl>
423-
```
424-
425-
----
426-
427445
### :material-image-outline: `image`: set the channel image { #image }
428446

429447
`image`: URL to image to use as feed illustration.
@@ -496,24 +514,6 @@ Default: `False`.
496514

497515
----
498516

499-
### :material-format-title: `title`: override site title { #title }
500-
501-
This option allows you to override the default MkDocs site title for the title tag in this RSS feed.
502-
This is useful if you have multiple instances of this plugin for multiple feeds. (For example, one feed
503-
for the blog, and a second for documentation updates.)
504-
505-
This setting is optional. If you do not include it, the default site name will be used.
506-
507-
```yaml
508-
plugins:
509-
- rss:
510-
title: My awesome blog feed
511-
```
512-
513-
Default: Use the default MkDocs `site_name:`.
514-
515-
----
516-
517517
### :material-track-light: `url_parameters`: additional URL parameters { #url_parameters }
518518

519519
This option allows you to add parameters to the URLs of the RSS feed items. It works as a dictionary of keys/values that is passed to [Python *urllib.parse.urlencode*](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlencode).

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ plugins:
5454
5555
## Example
5656
57-
As examples, here come the feeds generated for this documentation:
57+
As examples, here are the feeds generated for this documentation:
5858
5959
- [feed_rss_created.xml](feed_rss_created.xml) and [feed_json_created.json](feed_json_created.json) for latest **created** pages: [W3C validator](https://validator.w3.org/feed/check.cgi?url=https%3A//guts.github.io/mkdocs-rss-plugin/feed_rss_created.xml)
6060
- [feed_rss_updated.xml](feed_rss_updated.xml) and [feed_json_updated.json](feed_json_updated.json) for latest **updated** pages: [W3C validator](https://validator.w3.org/feed/check.cgi?url=https%3A//guts.github.io/mkdocs-rss-plugin/feed_rss_updated.xml)

mkdocs_rss_plugin/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ class RssPluginConfig(Config):
4444
)
4545
comments_path = config_options.Optional(config_options.Type(str))
4646
date_from_meta = config_options.SubConfig(_DateFromMeta)
47-
description = config_options.Type(str, default="")
4847
enabled = config_options.Type(bool, default=True)
49-
feed_ttl = config_options.Type(int, default=1440)
5048
feeds_filenames = config_options.SubConfig(_FeedsFilenamesConfig)
49+
feed_description = config_options.Optional(config_options.Type(str))
50+
feed_title = config_options.Optional(config_options.Type(str))
51+
feed_ttl = config_options.Type(int, default=1440)
5152
image = config_options.Optional(config_options.Type(str))
5253
json_feed_enabled = config_options.Type(bool, default=True)
5354
length = config_options.Type(int, default=20)
5455
match_path = config_options.Type(str, default=".*")
5556
pretty_print = config_options.Type(bool, default=False)
5657
rss_feed_enabled = config_options.Type(bool, default=True)
57-
title = config_options.Type(str, default="")
5858
url_parameters = config_options.Optional(config_options.Type(dict))
5959
use_git = config_options.Type(bool, default=True)
6060
use_material_social_cards = config_options.Type(bool, default=True)

mkdocs_rss_plugin/plugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig:
116116
"buildDate": formatdate(get_build_timestamp()),
117117
"copyright": config.copyright,
118118
"description": (
119-
self.config["description"]
120-
if self.config["description"]
121-
else config["site_description"]
119+
self.config.feed_description
120+
if self.config.feed_description
121+
else config.site_description
122122
),
123123
"entries": [],
124124
"generator": f"{__title__} - v{__version__}",
@@ -127,7 +127,7 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig:
127127
"pubDate": formatdate(get_build_timestamp()),
128128
"repo_url": config.repo_url,
129129
"title": (
130-
self.config["title"] if self.config["title"] else config["site_name"]
130+
self.config.feed_title if self.config.feed_title else config.site_name
131131
),
132132
"ttl": self.config.feed_ttl,
133133
}

tests/fixtures/mkdocs_custom_title_description.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ site_url: https://guts.github.io/mkdocs-rss-plugin
44

55
plugins:
66
- rss:
7-
title: My custom RSS title
8-
description: My custom RSS description
7+
feed_title: My custom RSS title
8+
feed_description: My custom RSS description
99

1010
theme:
1111
name: mkdocs

tests/test_build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,8 @@ def test_simple_build_pretty_print_disabled(self):
657657
with Path(Path(tmpdirname) / OUTPUT_RSS_FEED_UPDATED).open("r") as f:
658658
self.assertEqual(len(f.readlines()), 1)
659659

660-
def test_simple_build_custome_title_description(self):
660+
def test_simple_build_custom_title_description(self):
661+
"""Test simple build with custom description and title."""
661662
with tempfile.TemporaryDirectory() as tmpdirname:
662663
cli_result = self.build_docs_setup(
663664
testproject_path="docs",

tests/test_config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ def test_plugin_config_defaults(self):
7070
"default_time": datetime.min.strftime("%H:%M"),
7171
"default_timezone": "UTC",
7272
},
73-
"description": "",
7473
"enabled": True,
74+
"feed_description": None,
75+
"feed_title": None,
7576
"feed_ttl": 1440,
7677
"image": None,
7778
"json_feed_enabled": True,
@@ -85,7 +86,6 @@ def test_plugin_config_defaults(self):
8586
},
8687
"pretty_print": False,
8788
"rss_feed_enabled": True,
88-
"title": "",
8989
"url_parameters": None,
9090
"use_git": True,
9191
"use_material_social_cards": True,
@@ -114,8 +114,9 @@ def test_plugin_config_image(self):
114114
"default_time": datetime.min.strftime("%H:%M"),
115115
"default_timezone": "UTC",
116116
},
117-
"description": "",
118117
"enabled": True,
118+
"feed_description": None,
119+
"feed_title": None,
119120
"feed_ttl": 1440,
120121
"image": self.feed_image,
121122
"json_feed_enabled": True,
@@ -129,7 +130,6 @@ def test_plugin_config_image(self):
129130
},
130131
"pretty_print": False,
131132
"rss_feed_enabled": True,
132-
"title": "",
133133
"url_parameters": None,
134134
"use_git": True,
135135
"use_material_social_cards": True,

0 commit comments

Comments
 (0)