aboutsummaryrefslogtreecommitdiffstats
path: root/mkdocs.py
diff options
context:
space:
mode:
authorRobert Romano2012-11-18 21:07:44 -0800
committerRobert Romano2012-11-18 21:07:44 -0800
commitf5f1ac49ec9d9cb180a00c791f2701c3f5a2d65b (patch)
tree663e254f3125d1281035d471fc4fa38d7ca3ee3d /mkdocs.py
parentd541e0c42326443b613df764cbe26a68b852b71d (diff)
parentd1472740bc5f08871343d1a63e409e34d05504cb (diff)
downloaddjango-rest-framework-f5f1ac49ec9d9cb180a00c791f2701c3f5a2d65b.tar.bz2
Update robromano fork with upstream master
Conflicts: docs/topics/credits.md docs/topics/release-notes.md
Diffstat (limited to 'mkdocs.py')
-rwxr-xr-xmkdocs.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/mkdocs.py b/mkdocs.py
index 8106e8e2..2918f7d3 100755
--- a/mkdocs.py
+++ b/mkdocs.py
@@ -11,6 +11,7 @@ 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))
@@ -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