aboutsummaryrefslogtreecommitdiffstats
path: root/mkdocs.py
diff options
context:
space:
mode:
authorStephan Groß2012-11-21 11:56:34 +0100
committerStephan Groß2012-11-21 11:56:34 +0100
commit6ba4df8a27016fd5e60a3852eea6c97231a03281 (patch)
tree935bb3d51a9c3f4307d2d83d4b4c2e4d884886e3 /mkdocs.py
parented713d0354b67bdc64de9346b9a72e1adfced76e (diff)
parent3268c67343f6fc6364a0127a7bfabeb907a4751d (diff)
downloaddjango-rest-framework-6ba4df8a27016fd5e60a3852eea6c97231a03281.tar.bz2
Merge remote-tracking branch 'upstream/master' into regex_field
Conflicts: 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