From 7c423448aa5e00d8ca1bbf83e1037e177477bd50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sat, 21 Apr 2018 23:30:49 +0300 Subject: [PATCH] Switch to using docstrings for the function documentation --- config.py | 3 +-- generate_html.py | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/config.py b/config.py index 05da309..9277680 100644 --- a/config.py +++ b/config.py @@ -1,8 +1,7 @@ import configparser -# load(filename) -# Populate the config variables def load(filename): + """Populate the config variables""" global port, ssl, url_prefix global site_name diff --git a/generate_html.py b/generate_html.py index 90b4f7a..64e2eb0 100644 --- a/generate_html.py +++ b/generate_html.py @@ -4,8 +4,8 @@ import bs4 import config -# generate_nav(*, soup) → nav_tag def generate_nav(*, soup): + """Returns nav_tag""" # TODO: Don't generate link to a board if we're at the index nav_tag = soup.new_tag('nav') @@ -17,8 +17,8 @@ def generate_nav(*, soup): return nav_tag -# generate_header(*, page_title, soup) → header_tag def generate_header(*, page_title, soup): + """Returns header_tag""" header_tag = soup.new_tag('header') h1_tag = soup.new_tag('h1') @@ -27,15 +27,15 @@ def generate_header(*, page_title, soup): return header_tag -# generate_footer(*, soup) → footer_tag def generate_footer(*, soup): + """Returns footer_tag""" # TODO: Add footer generation return soup.new_tag('footer') -# page_skeleton(*, page_title, contents, soup) → html -# Given page title (string) and contents (iteratable of beautifulsoup tags), create the html -# Since most pages have same basic structure, it makes sense to factor this out from page creation functions def page_skeleton(*, page_title, contents, soup): + """Returns html + Given page title (string) and contents (iteratable of beautifulsoup tags), create the html + Since most pages have same basic structure, it makes sense to factor this out from page creation functions""" # Doctype and head are more or less the same for each page, no need to do anything fancy when adding them soup.append(bs4.Doctype('html')) @@ -63,18 +63,18 @@ def page_skeleton(*, page_title, contents, soup): # We are probably never going to serve enough pages for the additional whitespace to count for data usage return soup.prettify() -# new_soup() → soup -# Since we need a soup object to create tags, split this from page_skeleton def new_soup(): + """Returns soup + Since we need a soup object to create tags, split this from page_skeleton""" # Use python's built-in parser for portability # We'll be constructing the document programmatically, so start with empty tree soup = bs4.BeautifulSoup('', 'html.parser') return soup -# board() → html -# Creates the board index page def board(board_name): + """Returns html + Creates the board index page""" # TODO: Creae a board index page soup = new_soup() @@ -82,15 +82,15 @@ def board(board_name): return page_skeleton(page_title = page_title, contents = [], soup = soup) -# index() → html -# Create the site index def index(): + """Returns html + Create the site index""" # TODO: Create an index page soup = new_soup() return page_skeleton(page_title = config.site_name, contents = [], soup = soup) -# error_404(path) → html def error_404(path): + """Returns html""" soup = new_soup() p_tag = soup.new_tag('p')