summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunaina Pai <sunainapai.in@gmail.com>2018-03-24 10:16:45 +0530
committerSunaina Pai <sunainapai.in@gmail.com>2018-03-24 10:16:45 +0530
commitd35427d29ff246087a6ad385c84a51693a9a7848 (patch)
treea15721970fd642fe62b07331e3e3b3c71751466e
parenteb002a4a7f802d5a2bc66ed54a1d3732acb9860a (diff)
Add missing comments
-rwxr-xr-xmakesite.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/makesite.py b/makesite.py
index e0caa0f..20a3f54 100755
--- a/makesite.py
+++ b/makesite.py
@@ -57,6 +57,7 @@ def log(msg, *args):
def truncate(text, words=25):
+ """Remove tags and truncate text to the specified number of words."""
return ' '.join(re.sub('(?s)<.*?>', ' ', text).split()[:words])
@@ -73,7 +74,7 @@ def read_content(filename):
# Read file content.
text = fread(filename)
- # Read metadata.
+ # Read metadata and save it in a dictionary.
date_slug = os.path.basename(filename).split('.')[0]
match = re.search('^(?:(\d\d\d\d-\d\d-\d\d)-)?(.+)$', date_slug)
content = {
@@ -99,6 +100,7 @@ def read_content(filename):
except ImportError as e:
log('WARNING: Cannot render Markdown in {}: {}', filename, str(e))
+ # Update the dictionary with content text and summary text.
content.update({
'content': text,
'summary': truncate(text),
@@ -199,6 +201,7 @@ def main():
make_list(news_posts, '_site/news/index.html',
list_layout, item_layout, blog='news', title='News', **params)
+ # Create RSS feeds.
make_list(blog_posts, '_site/blog/rss.xml',
feed_xml, item_xml, blog='blog', title='Blog', **params)
make_list(news_posts, '_site/news/rss.xml',