summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build.py46
1 files changed, 13 insertions, 33 deletions
diff --git a/scripts/build.py b/scripts/build.py
index 2b6055d..560f503 100755
--- a/scripts/build.py
+++ b/scripts/build.py
@@ -8,36 +8,19 @@ from jinja2 import Environment, FileSystemLoader
from utils.reST import reST_to_html
-def build_entry(jenv, entry, older=None, newer=None):
- entry_template = jenv.get_template('entry.html')
-
- source_file = 'entries/{}.rst'.format(entry['file'])
- with open(source_file, 'r') as f:
- source = f.read()
-
- rendered_source = reST_to_html(source)
-
- rendered = entry_template.render(entry=entry,
- older=older,
- newer=newer,
- content=rendered_source)
- with open('out/{}.html'.format(entry['file']), 'w+') as f:
- f.write(rendered)
-
-
-def build_index(jenv, entry, older=None):
- index_template = jenv.get_template('index.html')
-
+def build_entry(jenv, fname, entry, older=None, newer=None):
+ template = jenv.get_template('entry.html')
source_file = 'entries/{}.rst'.format(entry['file'])
with open(source_file, 'r') as f:
source = f.read()
rendered_source = reST_to_html(source)
- rendered = index_template.render(entry=entry,
- older=older,
- content=rendered_source)
- with open('out/index.html', 'w+') as f:
+ rendered = template.render(entry=entry,
+ older=older,
+ newer=newer,
+ content=rendered_source)
+ with open('out/{}.html'.format(fname), 'w+') as f:
f.write(rendered)
@@ -78,16 +61,13 @@ if __name__ == '__main__':
published, unpublished = split_entries(entries)
for entry in unpublished:
- build_entry(jenv, entry)
+ build_entry(jenv, entry['file'], entry)
for index, entry in enumerate(published):
- older = published[index:index-1]
- newer = published[index:index+1]
- build_entry(jenv, entry, older, newer)
-
- if len(published) > 1:
- build_index(jenv, published[-1], published[-2])
- else:
- build_index(jenv, published[-1], None)
+ older = published[index-1:index]
+ newer = published[index+1:index+2]
+ build_entry(jenv, entry['file'], entry, older, newer)
+
+ build_entry(jenv, 'index', published[-1], older=published[-2:-1])
build_archive(jenv, published)