Skip to content

Commit

Permalink
DOC: fixed readthedocs
Browse files Browse the repository at this point in the history
  • Loading branch information
sglyon committed Oct 6, 2014
1 parent dc8d5b0 commit f23a4b5
Show file tree
Hide file tree
Showing 21 changed files with 111 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
service_name: travis-ci
repo_token: jsCc4k6kaFJLjBQVv9tpwK5ujJMh8sZxc
repo_token: 7f8JDNk6BsPMESy0URL3W00zlazzRcuzR
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Assuming you have [pip](https://pypi.python.org/pypi/pip) on your computer --- a
at a terminal prompt

#### Current Build and Coverage Status:
[![Build Status](https://travis-ci.org/jstac/quant-econ.svg?branch=master)](https://travis-ci.org/jstac/quant-econ)
[![Coverage Status](https://coveralls.io/repos/jstac/quant-econ/badge.png)](https://coveralls.io/r/jstac/quant-econ)
[![Build Status](https://travis-ci.org/QuantEcon/QuantEcon.py.svg?branch=master)](https://travis-ci.org/QuantEcon/QuantEcon.py)
[![Coverage Status](https://coveralls.io/repos/QuantEcon/QuantEcon.py/badge.png)](https://coveralls.io/r/QuantEcon/QuantEcon.py)


### About Git / GitHub
Expand Down
1 change: 1 addition & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ myhtml:
make html

html:
python qe_apidoc.py
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
Expand Down
42 changes: 17 additions & 25 deletions docs/qe_apidoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@
:show-inheritance:
"""

model_module_template = """{mod_name}
{equals}
.. automodule:: quantecon.models.{mod_name}
:members:
:undoc-members:
:show-inheritance:
"""

all_index_template = """=======================
QuantEcon documentation
=======================
Expand Down Expand Up @@ -108,29 +117,6 @@
def source_join(f_name):
return os.path.join("source", f_name)


def gen_module(name, f):
"""
Generate the template for a particular module by writing to the
file f. There are no return values.
Parameters
----------
name : string
The name of the python module within quantecon to document
Examples
--------
>>> with open("my_new_file.rst", "w") as f:
... gen_module(my_new_module, f)
"""
# Define template for auto-generated docs

equals = "=" * len(name)
f.write(module_template.format(mod_name=name, equals=equals))


####################
## Main functions ##
####################
Expand Down Expand Up @@ -164,10 +150,14 @@ def model_tool():
# list file names with models
mod_files = glob("../quantecon/models/[a-z0-9]*.py")
models = map(lambda x: x.split('/')[-1][:-3], mod_files)
# Alphabetize
models.sort()

# list file names of tools
tool_files = glob("../quantecon/[a-z0-9]*.py")
tools = map(lambda x: x.split('/')[-1][:-3], tool_files)
# Alphabetize
tools.sort()

for folder in ["models", "tools"]:
if not os.path.exists(source_join(folder)):
Expand All @@ -177,13 +167,15 @@ def model_tool():
for mod in models:
new_path = os.path.join("source", "models", mod + ".rst")
with open(new_path, "w") as f:
gen_module(mod, f)
equals = "=" * len(mod)
f.write(model_module_template.format(mod_name=mod, equals=equals))

# Write file for each tool
for mod in tools:
new_path = os.path.join("source", "tools", mod + ".rst")
with open(new_path, "w") as f:
gen_module(mod, f)
equals = "=" * len(mod)
f.write(module_template.format(mod_name=mod, equals=equals))

# write (index|models|tools).rst file to include autogenerated files
with open(source_join("index.rst"), "w") as index:
Expand Down
23 changes: 23 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,30 @@

import sys
import os
import pip

try:
from mock import Mock as MagicMock
except ImportError:
def install(package):
pip.main(['install', package])

install('mock')
from mock import Mock as MagicMock

# ------------------------------------------------------------------- #
# MOCK MODULES
# ------------------------------------------------------------------- #
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'

if on_rtd:
class Mock(MagicMock):
@classmethod
def __getattr__(cls, name):
return Mock()

MOCK_MODULES = ['pandas', 'statsmodels', 'sympy', "sympy.mpmath", 'numba']
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down
2 changes: 1 addition & 1 deletion docs/source/models/asset_pricing.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
asset_pricing
=============

.. automodule:: quantecon.asset_pricing
.. automodule:: quantecon.models.asset_pricing
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion docs/source/models/career.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
career
======

.. automodule:: quantecon.career
.. automodule:: quantecon.models.career
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion docs/source/models/ifp.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ifp
===

.. automodule:: quantecon.ifp
.. automodule:: quantecon.models.ifp
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion docs/source/models/jv.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
jv
==

.. automodule:: quantecon.jv
.. automodule:: quantecon.models.jv
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion docs/source/models/lucastree.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
lucastree
=========

.. automodule:: quantecon.lucastree
.. automodule:: quantecon.models.lucastree
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion docs/source/models/odu.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
odu
===

.. automodule:: quantecon.odu
.. automodule:: quantecon.models.odu
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion docs/source/models/optgrowth.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
optgrowth
=========

.. automodule:: quantecon.optgrowth
.. automodule:: quantecon.models.optgrowth
:members:
:undoc-members:
:show-inheritance:
9 changes: 7 additions & 2 deletions docs/source/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@ Tools
.. toctree::
:maxdepth: 2

tools/arma
tools/cartesian
tools/ce_util
tools/compute_fp
tools/discrete_rv
tools/distributions
tools/ecdf
tools/estspec
tools/ivp
tools/kalman
tools/lae
tools/linproc
tools/lqcontrol
tools/lqnash
tools/lss
tools/matrix_eqn
tools/mc_tools
tools/quad
tools/quadsums
tools/rank_nullspace
tools/riccati
tools/robustlq
tools/tauchen
tools/version
6 changes: 3 additions & 3 deletions docs/source/tools/riccati.rst → docs/source/tools/arma.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
riccati
=======
arma
====

.. automodule:: quantecon.riccati
.. automodule:: quantecon.arma
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/tools/cartesian.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cartesian
=========

.. automodule:: quantecon.cartesian
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/tools/distributions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributions
=============

.. automodule:: quantecon.distributions
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/tools/ivp.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ivp
===

.. automodule:: quantecon.ivp
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/tools/lqnash.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
lqnash
======

.. automodule:: quantecon.lqnash
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/tools/matrix_eqn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
matrix_eqn
==========

.. automodule:: quantecon.matrix_eqn
:members:
:undoc-members:
:show-inheritance:
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
linproc
version
=======

.. automodule:: quantecon.linproc
.. automodule:: quantecon.version
:members:
:undoc-members:
:show-inheritance:
13 changes: 13 additions & 0 deletions rtd-pip-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are the required packages for the quant-econ package to build

Sphinx

ipython

numpy

numpydoc

scipy

matplotlib

0 comments on commit f23a4b5

Please sign in to comment.