Skip to content

Commit

Permalink
gh-pages uses reST
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Feb 12, 2011
1 parent 4886db0 commit 82eb507
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion docs/Makefile
Expand Up @@ -107,4 +107,5 @@ gh-pages: html pdf
python gh-pages.py

gh-pages-current: html pdf
python gh-pages.py current "Current Development Version"
ipver="$(ipython -v 2>&1)"
python gh-pages.py dev "Current Development Version ($ipver)"
23 changes: 15 additions & 8 deletions docs/gh-pages.py
Expand Up @@ -75,12 +75,12 @@ def init_repo(path):
cd(here)


def render_htmlindex(fname, tag, desc=None):
def render_rstindex(fname, tag, desc=None):
if desc is None:
desc = tag

rel = '<li>{d}: <a href="{t}/index.html">HTML</a> and <a href="{t}/ipython.pdf">PDF</a>'.format(t=tag,d=desc)
rep = re.compile('<!-- RELEASE -->')
rel = '* {d}: `HTML <{t}/index.html>`_ and `PDF <{t}/ipython.pdf>`_.'.format(t=tag,d=desc)
rep = re.compile(r'\.\. release')
out = []
with file(fname) as f:
contents = f.read()
Expand All @@ -95,8 +95,8 @@ def render_htmlindex(fname, tag, desc=None):
return '\n'.join(out)+'\n'


def new_htmlindex(fname, tag, desc=None):
new_page = render_htmlindex(fname, tag, desc)
def new_rstindex(fname, tag, desc=None):
new_page = render_rstindex(fname, tag, desc)
os.rename(fname, fname+'~')
with file(fname, 'w') as f:
f.write(new_page)
Expand All @@ -119,7 +119,14 @@ def new_htmlindex(fname, tag, desc=None):

startdir = os.getcwd()
if not os.path.exists(pages_dir):
# init the repo
init_repo(pages_dir)
else:
# ensure up-to-date before operating
cd(pages_dir)
sh('git checkout gh-pages')
sh('git pull')
cd(startdir)

dest = pjoin(pages_dir, tag)

Expand All @@ -134,7 +141,6 @@ def new_htmlindex(fname, tag, desc=None):

try:
cd(pages_dir)
sh('git checkout gh-pages')
status = sh2('git status | head -1')
branch = re.match('\# On branch (.*)$', status).group(1)
if branch != 'gh-pages':
Expand All @@ -143,8 +149,9 @@ def new_htmlindex(fname, tag, desc=None):
raise RuntimeError(e)

sh('git add %s' % tag)
new_htmlindex('index.html', tag, desc)
sh('git add index.html')
new_rstindex('index.rst', tag, desc)
sh('python build_index.py')
sh('git add index.rst index.html')
sh('git commit -m"Created new doc release, named: %s"' % tag)
print
print 'Most recent 3 commits:'
Expand Down

0 comments on commit 82eb507

Please sign in to comment.