-
Notifications
You must be signed in to change notification settings - Fork 73
tutorial RSS feeds #488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
tutorial RSS feeds #488
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4b73465
tutorial RSS feeds
sneakers-the-rat 4e9f1d3
import sphinx util when function runs since we import the conf in the…
sneakers-the-rat 50ae0da
is it the conf??? who is to say
sneakers-the-rat 4e825a7
correct object name
sneakers-the-rat 0a9671c
Add: descriptions for each tutorial
lwasser c43aa1f
Apply suggestions from code review
lwasser 025817c
Update _ext/rss.py
lwasser 8fa5f12
Update rss.py
lwasser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,101 @@ | ||||||
""" | ||||||
Create an RSS feed of tutorials | ||||||
Cribbed from: https://github.com/python/peps/blob/main/pep_sphinx_extensions/generate_rss.py | ||||||
""" | ||||||
|
||||||
from dataclasses import dataclass, asdict | ||||||
from datetime import datetime, UTC | ||||||
from email.utils import format_datetime | ||||||
from html import escape | ||||||
from pprint import pformat | ||||||
from typing import TYPE_CHECKING | ||||||
from urllib.parse import urljoin | ||||||
|
||||||
if TYPE_CHECKING: | ||||||
from sphinx.application import Sphinx | ||||||
|
||||||
|
||||||
def _format_rfc_2822(dt: datetime) -> str: | ||||||
datetime = dt.replace(tzinfo=UTC) | ||||||
return format_datetime(datetime, usegmt=True) | ||||||
|
||||||
|
||||||
@dataclass | ||||||
class RSSItem: | ||||||
title: str | ||||||
date: datetime | ||||||
description: str | ||||||
url: str | ||||||
author: str = "PyOpenSci" | ||||||
|
||||||
@classmethod | ||||||
def from_meta(cls, page_name: str, meta: dict, app: "Sphinx") -> "RSSItem": | ||||||
"""Create from a page's metadata""" | ||||||
url = urljoin(app.config.html_baseurl, app.builder.get_target_uri(page_name)) | ||||||
# purposely don't use `get` here because we want to error if these fields are absent | ||||||
return RSSItem( | ||||||
title=meta[":og:title"], | ||||||
description=meta[":og:description"], | ||||||
date=datetime.fromisoformat(meta["date"]), | ||||||
author=meta.get(":og:author", "PyOpenSci"), | ||||||
|
author=meta.get(":og:author", "PyOpenSci"), | |
author=meta.get(":og:author", "pyOpenSci"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.