aboutsummaryrefslogtreecommitdiffstats
path: root/docs/mkdocs.py
diff options
context:
space:
mode:
authorTom Christie2012-09-01 21:23:50 +0100
committerTom Christie2012-09-01 21:23:50 +0100
commit99415564741ca849c0771a3cdd3c18a72b74a373 (patch)
tree3f17139758cc74b7a0a574f769688670ea32a645 /docs/mkdocs.py
parentdeedf6957d14c2808c00a009ac2c1d4528cb80c9 (diff)
downloaddjango-rest-framework-99415564741ca849c0771a3cdd3c18a72b74a373.tar.bz2
Get docs ready to deploy
Diffstat (limited to 'docs/mkdocs.py')
-rwxr-xr-xdocs/mkdocs.py56
1 files changed, 0 insertions, 56 deletions
diff --git a/docs/mkdocs.py b/docs/mkdocs.py
deleted file mode 100755
index f984e6f9..00000000
--- a/docs/mkdocs.py
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/env python
-
-import markdown
-import os
-import re
-
-root = os.path.dirname(__file__)
-local = True
-
-if local:
- base_url = 'file://%s/html/' % os.path.normpath(os.path.join(os.getcwd(), root))
- suffix = '.html'
- index = 'index.html'
-else:
- base_url = 'http://tomchristie.github.com/restframeworkdocs/'
- suffix = ''
- index = ''
-
-
-main_header = '<li class="main"><a href="#{{ anchor }}">{{ title }}</a></li>'
-sub_header = '<li><a href="#{{ anchor }}">{{ title }}</a></li>'
-
-page = open(os.path.join(root, 'template.html'), 'r').read()
-
-for (dirpath, dirnames, filenames) in os.walk(root):
- for filename in filenames:
- if not filename.endswith('.md'):
- continue
-
- toc = ''
- text = open(os.path.join(dirpath, filename), 'r').read().decode('utf-8')
- for line in text.splitlines():
- if line.startswith('# '):
- title = line[2:].strip()
- template = main_header
- elif line.startswith('## '):
- title = line[3:].strip()
- template = sub_header
- else:
- continue
-
- anchor = title.lower().replace(' ', '-').replace(':-', '-').replace("'", '').replace('?', '').replace('.', '')
- template = template.replace('{{ title }}', title)
- template = template.replace('{{ anchor }}', anchor)
- toc += template + '\n'
-
- content = markdown.markdown(text, ['headerid'])
-
- build_dir = os.path.join(root, 'html', dirpath)
- build_file = os.path.join(build_dir, filename[:-3] + '.html')
-
- if not os.path.exists(build_dir):
- os.makedirs(build_dir)
- output = page.replace('{{ content }}', content).replace('{{ toc }}', toc).replace('{{ base_url }}', base_url).replace('{{ suffix }}', suffix).replace('{{ index }}', index)
- output = re.sub(r'a href="([^"]*)\.md"', r'a href="\1.html"', output)
- open(build_file, 'w').write(output.encode('utf-8'))