forked from Mirror/wren
Recopy css if it has been modified.
This commit is contained in:
@ -8,12 +8,7 @@ import sys
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
def format_file(path, skip_up_to_date):
|
||||
basename = os.path.basename(path)
|
||||
basename = basename.split('.')[0]
|
||||
|
||||
out_path = "build/docs/" + basename + ".html"
|
||||
|
||||
def compare_modification_times(path, out_path):
|
||||
# See if it's up to date.
|
||||
source_mod = os.path.getmtime(path)
|
||||
source_mod = max(source_mod, os.path.getmtime('doc/site/template.html'))
|
||||
@ -21,8 +16,16 @@ def format_file(path, skip_up_to_date):
|
||||
dest_mod = 0
|
||||
if os.path.exists(out_path):
|
||||
dest_mod = os.path.getmtime(out_path)
|
||||
return source_mod < dest_mod
|
||||
|
||||
if skip_up_to_date and source_mod < dest_mod:
|
||||
def format_file(path, skip_up_to_date):
|
||||
basename = os.path.basename(path)
|
||||
basename = basename.split('.')[0]
|
||||
|
||||
out_path = "build/site/" + basename + ".html"
|
||||
|
||||
if skip_up_to_date and compare_modification_times(path, out_path):
|
||||
# It's up to date.
|
||||
return
|
||||
|
||||
title = ""
|
||||
@ -67,6 +70,14 @@ def format_file(path, skip_up_to_date):
|
||||
def format_files(skip_up_to_date):
|
||||
for f in glob.iglob("doc/site/*.markdown"):
|
||||
format_file(f, skip_up_to_date)
|
||||
# Copy the CSS file.
|
||||
css_in = "doc/site/style.css"
|
||||
css_out = "build/site/style.css"
|
||||
if skip_up_to_date and compare_modification_times(css_in, css_out):
|
||||
pass
|
||||
else:
|
||||
shutil.copyfile(css_in, css_out)
|
||||
print "copied css"
|
||||
|
||||
|
||||
# Clean the output directory.
|
||||
@ -80,10 +91,7 @@ os.mkdir("build/docs")
|
||||
# Process each markdown file.
|
||||
format_files(False)
|
||||
|
||||
# Copy the CSS file.
|
||||
shutil.copyfile("doc/site/style.css", "build/docs/style.css")
|
||||
|
||||
# TODO(bob): Check for CSS modification.
|
||||
# Watch files
|
||||
if len(sys.argv) == 2 and sys.argv[1] == '--watch':
|
||||
while True:
|
||||
format_files(True)
|
||||
|
||||
Reference in New Issue
Block a user