diff options
| author | Marko Tibold | 2012-11-15 23:31:53 +0100 | 
|---|---|---|
| committer | Marko Tibold | 2012-11-15 23:31:53 +0100 | 
| commit | cba181f4bce6684a45aa869cae0b2cca0c35eee0 (patch) | |
| tree | bc4c98f282c529e512b3fe4a68d42c1753964fa3 /mkdocs.py | |
| parent | 3b258d69c92e9d9293f7c5d1690f0ca434e677e3 (diff) | |
| download | django-rest-framework-cba181f4bce6684a45aa869cae0b2cca0c35eee0.tar.bz2 | |
./mkdocs.py -p opens a preview in your default browser. Tested on Mac, but should work on windows and Linux as well.
Diffstat (limited to 'mkdocs.py')
| -rwxr-xr-x | mkdocs.py | 13 | 
1 files changed, 13 insertions, 0 deletions
| @@ -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 | 
