Skip to content

Commit

Permalink
BLD/DOC: use jinja2 templates to allow make.py to build partial docs
Browse files Browse the repository at this point in the history
  • Loading branch information
y-p committed Jan 30, 2014
1 parent ea11bf3 commit 831ea80
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ doc/source/generated
doc/source/_static
doc/source/vbench
doc/source/vbench.rst
doc/source/index.rst
doc/build/html/index.html
*flymake*
scikits
Expand Down
72 changes: 53 additions & 19 deletions doc/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import shutil
import sys
import sphinx
import argparse
import jinja2

os.environ['PYTHONPATH'] = '..'

Expand Down Expand Up @@ -77,7 +79,7 @@ def build_pandas():
os.system('python setup.py clean')
os.system('python setup.py build_ext --inplace')
os.chdir('doc')

def build_prev(ver):
if os.system('git checkout v%s' % ver) != 1:
os.chdir('..')
Expand Down Expand Up @@ -267,22 +269,54 @@ def _get_config():
# current_dir = os.getcwd()
# os.chdir(os.path.dirname(os.path.join(current_dir, __file__)))

if len(sys.argv) > 2:
ftype = sys.argv[1]
ver = sys.argv[2]

if ftype == 'build_previous':
build_prev(ver)
if ftype == 'upload_previous':
upload_prev(ver)
elif len(sys.argv) > 1:
for arg in sys.argv[1:]:
func = funcd.get(arg)
if func is None:
raise SystemExit('Do not know how to handle %s; valid args are %s' % (
arg, list(funcd.keys())))
func()
else:
small_docs = False
all()
import argparse
argparser = argparse.ArgumentParser(description="""
Pandas documentation builder
""".strip())

# argparser.add_argument('-arg_name', '--arg_name',
# metavar='label for arg help',
# type=str|etc,
# nargs='N|*|?|+|argparse.REMAINDER',
# required=False,
# #choices='abc',
# help='help string',
# action='store|store_true')

# args = argparser.parse_args()

#print args.accumulate(args.integers)

def generate_index(api=True, single=False, **kwds):
from jinja2 import Template
with open("source/index.rst.template") as f:
t = Template(f.read())

with open("source/index.rst","wb") as f:
f.write(t.render(api=api,single=single,**kwds))

def main():
generate_index(api=False, single='indexing')
if len(sys.argv) > 2:
ftype = sys.argv[1]
ver = sys.argv[2]

if ftype == 'build_previous':
build_prev(ver)
if ftype == 'upload_previous':
upload_prev(ver)
elif len(sys.argv) == 2:
for arg in sys.argv[1:]:
func = funcd.get(arg)
if func is None:
raise SystemExit('Do not know how to handle %s; valid args are %s' % (
arg, list(funcd.keys())))
func()
else:
small_docs = False
all()
# os.chdir(current_dir)

if __name__ == '__main__':
import sys
sys.exit(main())
9 changes: 9 additions & 0 deletions doc/source/index.rst → doc/source/index.rst.template
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ See the package overview for more detail about what's in the library.
.. toctree::
:maxdepth: 3

{% if single -%}
{{ single }}
{% endif -%}
{%if not single -%}
whatsnew
install
faq
Expand Down Expand Up @@ -136,6 +140,11 @@ See the package overview for more detail about what's in the library.
ecosystem
comparison_with_r
comparison_with_sql
{% endif -%}
{% if api -%}
api
{% endif -%}
{%if not single -%}
contributing
release
{% endif -%}

0 comments on commit 831ea80

Please sign in to comment.