aboutsummaryrefslogtreecommitdiffstats
path: root/mkdocs.py
diff options
context:
space:
mode:
authorTom Christie2013-01-15 17:53:24 +0000
committerTom Christie2013-01-15 17:53:24 +0000
commit71e55cc4f6300959398f7aef4a8d91b6a6a2af57 (patch)
tree68c2080034263d897741da33cbc5e09746006257 /mkdocs.py
parent52847a215d4e8de88e81d9ae79ce8bee9a36a9a2 (diff)
parente1076cfb49b6293aa837cf7bdb4c11988892c598 (diff)
downloaddjango-rest-framework-71e55cc4f6300959398f7aef4a8d91b6a6a2af57.tar.bz2
Merge with latest master
Diffstat (limited to 'mkdocs.py')
-rwxr-xr-xmkdocs.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/mkdocs.py b/mkdocs.py
index 5d202d7e..2918f7d3 100755
--- a/mkdocs.py
+++ b/mkdocs.py
@@ -11,20 +11,21 @@ docs_dir = os.path.join(root_dir, 'docs')
html_dir = os.path.join(root_dir, 'html')
local = not '--deploy' in sys.argv
+preview = '-p' in sys.argv
if local:
base_url = 'file://%s/' % os.path.normpath(os.path.join(os.getcwd(), html_dir))
suffix = '.html'
index = 'index.html'
else:
- base_url = 'http://tomchristie.github.com/django-rest-framework'
- suffix = ''
+ base_url = 'http://django-rest-framework.org'
+ suffix = '.html'
index = ''
main_header = '<li class="main"><a href="#{{ anchor }}">{{ title }}</a></li>'
sub_header = '<li><a href="#{{ anchor }}">{{ title }}</a></li>'
-code_label = r'<a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/\1"><span class="label label-info">\1</span></a>'
+code_label = r'<a class="github" href="https://github.com/tomchristie/django-rest-framework/tree/master/rest_framework/\1"><span class="label label-info">\1</span></a>'
page = open(os.path.join(docs_dir, 'template.html'), 'r').read()
@@ -80,3 +81,15 @@ for (dirpath, dirnames, filenames) in os.walk(docs_dir):
output = re.sub(r'<pre>', r'<pre class="prettyprint lang-py">', output)
output = re.sub(r'<a class="github" href="([^"]*)"></a>', code_label, output)
open(output_path, 'w').write(output.encode('utf-8'))
+
+if preview:
+ import subprocess
+
+ url = 'html/index.html'
+
+ try:
+ subprocess.Popen(["open", url]) # Mac
+ except OSError:
+ subprocess.Popen(["xdg-open", url]) # Linux
+ except:
+ os.startfile(url) # Windows