forked from wesleywerner/mvc-game-design
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
executable file
·38 lines (35 loc) · 1.33 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
import os
import sys
import shutil
TOC_INCLUDE='# Table of contents\n\n[TOC]\n\n'
STYLE_INCLUDE='<link rel="stylesheet" type="text/css" href="res/style.css">'
BUILD_FILENAME='MVC Game Design by Wesley.html'
if __name__ == '__main__':
print('checking dependencies...')
try:
import markdown
except Exception as e:
print(e)
print('failed to load markdown.\nPlease install it, usually named "python-markdown" in your package manager')
sys.exit(1)
try:
import pygments
except Exception as e:
print(e)
print('syntax highlighting requires pygments installed. usually named "python-pygments" in your package manager, or see http://pygments.org')
sys.exit(1)
print('building documentation...')
with open('README.md', 'r') as intext:
rawtext = TOC_INCLUDE + ''.join(intext.readlines())
html = markdown.markdown(
rawtext, extensions=[
'toc',
'fenced_code',
'codehilite(guess_lang=False)'
]
)
with open(BUILD_FILENAME, 'w') as outtext:
outtext.write(STYLE_INCLUDE)
outtext.write(html)
print('wrote file "%s"' % (BUILD_FILENAME,))