提交 b755173e authored 作者: james@crane's avatar james@crane

lots of doc work

上级 3498d801
THEANO
Documentation et al is in Trac:
http://lgcm.iro.umontreal.ca:8000/theano/wiki/WikiStart
The lisa twiki is deprecated for documenting Theano.
Requirements:
scipy [version?]
numpy [version?]
Python >=2.5 (for function all)
==============
README: theano
==============
.. contents::
Quick-Start
===========
WRITEME.
Project Description
===================
License
-------
Installation
============
(See also the :wiki:`InstallationNotes` on the wiki.)
Software Requirements
---------------------
Downloading Theano
------------------
Setup on Linux
++++++++++++++
Setup on OS-X
+++++++++++++
Setup on Windows
++++++++++++++++
No one has done this yet. WRITEME.
Tips for running on a cluster
+++++++++++++++++++++++++++++
WRITEME.
Running the Test Suite
----------------------
WRITEME
Using Theano
------------
WRITEME
Getting Help
------------
WRITEME
=====================
Developer Start Guide
=====================
- Learn about the basics of using mercurial.
- Learn some `non-basic python`_ to understand what's going on in some of the
tricker files (like tensor.py).
- BasicNumpy_ essential things to know about numpy.
- Learn to write reStructuredText_ for epydoc_.
- ExternalTools - packages that play well with Numpy
- EssentialUnitTest - essential usage of python.unittest
Accounts
========
To obtain developer access: send an email to an admin with an username and
temporary password. Pending approval, this will give you access to both the
repository and Trac. You should then change your password in the
`<http://pylearn.org/theano/prefs preferences>` tab - do *NOT* use a good
password! We are using plain text http which is not secure.
Theano code
===========
The code that makes up Theano is in a single repository available in
`<http://pylearn.org/hg/theano>`__.
As a developer, you should clone this repository like this:
- `hg clone 'http://username:password@pylearn.org/hg/theano' theano`
Setting up your environment
===========================
Some notes on the environment variable $PYTHONPATH.
If theano lives in $DEV/theano, you should have $DEV in your $PYTHONPATH. You should '''not''' have $DEV/theano in your $PYTHONPATH.
Olivier Breuleux explains:
$PYTHONPATH should contain a ":"-separated list of paths, each of which contains one or several Python packages, in the order in which you would like Python to search for them. If a package has sub-packages of interest to you, do _not_ add them in the path: it is not portable, might shadow other packages or short-circuit important things in its __init__.
I advise to never import theano's files from outside theano itself (and I think that is good advice for Python packages in general). Use "from theano import tensor" instead of "import tensor". ... $PYTHONPATH ... should only contain paths to complete packages, so you don't get surprises if I add files that enter in conflict with other packages.
When you install a package, only the package name can be imported directly. If you want a sub-package, you must import it from the main package. That's how it will work in 99.9% of installs because it is the default. Therefore, if you stray from this practice, your code will not be portable. Also, some ways to circumvent circular dependencies might make it so you have to import files in a certain order, which is best handled by the package's own __init__.py.
.. _non-basic python: http://lgcm.iro.umontreal.ca/theano/wiki/NonbasicPython
.. _reStructuredText: http://docutils.sourceforge.net/rst.html
.. _epydoc: http://epydoc.sourceforge.net/
.. _basicnumpy: http://lgcm.iro.umontreal.ca/theano/wiki/BasicNumpy
...@@ -41,8 +41,8 @@ from docutils.core import publish_cmdline, default_description ...@@ -41,8 +41,8 @@ from docutils.core import publish_cmdline, default_description
try: try:
# .. code-block:: python should look nice with this # .. code-block:: python should look nice with this
import pygments_code_block_directive import pygments_code_block_directive
except: except Exception, e:
print >> sys.stderr, "failed to get pygments" print >> sys.stderr, "Failed to import pygments", e
description = ('Generates (X)HTML documents with API documentation links. ' description = ('Generates (X)HTML documents with API documentation links. '
+ default_description) + default_description)
......
#!/bin/bash
APIRST2HTML=apirst2html.py
EPYDOC_ARGS='--external-api=api --external-api-file=api:../html/api/api-objects.txt --external-api-root=api:epydoc/'
mkdir html 2> /dev/null
for RST in graph ; do
$APIRST2HTML $EPYDOC_ARGS $RST.txt html/$RST.html
done
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 125%; }
body { background: #ffffff; }
body .c { color: #808080 } /* Comment */
body .err { color: #F00000; background-color: #F0A0A0 } /* Error */
body .k { color: #008000; font-weight: bold } /* Keyword */
body .o { color: #303030 } /* Operator */
body .cm { color: #808080 } /* Comment.Multiline */
body .cp { color: #507090 } /* Comment.Preproc */
body .c1 { color: #808080 } /* Comment.Single */
body .cs { color: #cc0000; font-weight: bold } /* Comment.Special */
body .gd { color: #A00000 } /* Generic.Deleted */
body .ge { font-style: italic } /* Generic.Emph */
body .gr { color: #FF0000 } /* Generic.Error */
body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
body .gi { color: #00A000 } /* Generic.Inserted */
body .go { color: #808080 } /* Generic.Output */
body .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
body .gs { font-weight: bold } /* Generic.Strong */
body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
body .gt { color: #0040D0 } /* Generic.Traceback */
body .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
body .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
body .kp { color: #003080; font-weight: bold } /* Keyword.Pseudo */
body .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
body .kt { color: #303090; font-weight: bold } /* Keyword.Type */
body .m { color: #6000E0; font-weight: bold } /* Literal.Number */
body .s { background-color: #fff0f0 } /* Literal.String */
body .na { color: #0000C0 } /* Name.Attribute */
body .nb { color: #007020 } /* Name.Builtin */
body .nc { color: #B00060; font-weight: bold } /* Name.Class */
body .no { color: #003060; font-weight: bold } /* Name.Constant */
body .nd { color: #505050; font-weight: bold } /* Name.Decorator */
body .ni { color: #800000; font-weight: bold } /* Name.Entity */
body .ne { color: #F00000; font-weight: bold } /* Name.Exception */
body .nf { color: #0060B0; font-weight: bold } /* Name.Function */
body .nl { color: #907000; font-weight: bold } /* Name.Label */
body .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
body .nt { color: #007000 } /* Name.Tag */
body .nv { color: #906030 } /* Name.Variable */
body .ow { color: #000000; font-weight: bold } /* Operator.Word */
body .w { color: #bbbbbb } /* Text.Whitespace */
body .mf { color: #6000E0; font-weight: bold } /* Literal.Number.Float */
body .mh { color: #005080; font-weight: bold } /* Literal.Number.Hex */
body .mi { color: #0000D0; font-weight: bold } /* Literal.Number.Integer */
body .mo { color: #4000E0; font-weight: bold } /* Literal.Number.Oct */
body .sb { background-color: #fff0f0 } /* Literal.String.Backtick */
body .sc { color: #0040D0 } /* Literal.String.Char */
body .sd { color: #D04020 } /* Literal.String.Doc */
body .s2 { background-color: #fff0f0 } /* Literal.String.Double */
body .se { color: #606060; font-weight: bold; background-color: #fff0f0 } /* Literal.String.Escape */
body .sh { background-color: #fff0f0 } /* Literal.String.Heredoc */
body .si { background-color: #e0e0e0 } /* Literal.String.Interpol */
body .sx { color: #D02000; background-color: #fff0f0 } /* Literal.String.Other */
body .sr { color: #000000; background-color: #fff0ff } /* Literal.String.Regex */
body .s1 { background-color: #fff0f0 } /* Literal.String.Single */
body .ss { color: #A06000 } /* Literal.String.Symbol */
body .bp { color: #007020 } /* Name.Builtin.Pseudo */
body .vc { color: #306090 } /* Name.Variable.Class */
body .vg { color: #d07000; font-weight: bold } /* Name.Variable.Global */
body .vi { color: #3030B0 } /* Name.Variable.Instance */
body .il { color: #0000D0; font-weight: bold } /* Literal.Number.Integer.Long */
=====================================
Theano Project Documentation Overview
=====================================
Using Theano
============
- First of all, read the `n00b guide`_.
- Join `theano-users`_.
- Familiarize yourself with our `glossary of terminology`_.
- Consult some of the `Howto`_ recipes on the wiki.
.. _Howto:
.. _theano-users: http://groups.google.com/group/theano-users?pli=1
.. _theano-dev: http://groups.google.com/group/theano-dev?pli=1
.. _n00b guide: n00b.html
.. _glossary of terminology: glossary.html
Extending Theano
================
- `Get Started as a Developer <DevStartGuide.html>`__ by setting up mercurial, getting a few accounts,
setting up your environment, and getting some background in mercurial, python,
and numpy.
- Join `theano-dev`_ to participate in development discussion.
- Keep an eye on the `Mercurial Changelog <http://pylearn.org/hg/theano>`__.
- Pick a task from the `task list`_.
- Read about `How Theano Works <UserAdvanced.html>`__.
- Browse `Theano's API <../api/>`__.
- Send us your work as a patch to `theano-dev`_ or commit directly to the trunk.
.. _theano-dev: http://groups.google.com/group/theano-dev?pli=1
.. _task list: http://lgcm.iro.umontreal.ca/theano/query?status=accepted&status=assigned&status=new&status=reopened&group=milestone&max=200&col=id&col=summary&col=status&col=owner&col=type&col=priority&col=component&col=time&report=9&order=priority
.. _reStructuredText: http://docutils.sourceforge.net/rst.html
=============
N00b Tutorial
=============
.. contents::
*This documentation is still in-progress. 20080919*
Introduction
============
Great. You know `What theano is`_, and you've even `installed it`_.
But how do you use it?
.. _`What theano is`: http://lgcm.iro.umontreal.ca/theano/wiki/WhatIsTheano
.. _`installed it`: http://lgcm.iro.umontreal.ca/theano/wiki/InstallationNotes
If you have never used Theano before, we recommend you read over this tutorial start-to-finish. This will give you a sense of what you can do with Theano, and how.
Afterwards, we encourage you to read the documentation in accompanying links, which will allow you to understand the underlying concepts behind Theano better.
Scalar example
==============
In the following example, we will build a function `f(x) = x + 1.5`. We will then evaluate that function
.. code-block:: python
import theano
import theano.tensor as tensor
# Declare a symbolic constant
c = tensor.constant(1.5)
# Declare a symbolic floating-point scalar
x = tensor.fscalar()
# The symbolic result y is computed by adding x to c
y = x + c
# f is a function we build to compute output y given input x.
# f(x) = y
# = x + c
# = x + 1.5
f = theano.function([x], [y])
# We now bind 2.5 to an internal copy of x and evaluate an internal y,
# which we return.
# We assert that 4.0 == f(2.5) = 2.5 + 1.5
assert 4.0 == f(2.5)
In the example above, `c`, `x`, and `y` are each a ''symbolic'' result_. They
are symbolic because they stand for variables and have a type_, but
do not necessarily store actual values. Not yet, at least. (To give them
values, we will have to `evaluate` them. More on this below.)
.. _result: WRITEME.html
.. _type: WRITEME.html
Since we are using the addition operator (`x + c`) here on symbolic results, the
output `y` is also symbolic. The `+` corresponds to an ''operation'' in theano
terminology, or ''op'' for short.
We use these results and ops to construct a `symbolic graph`_. The graph is
symbolic because we declare what it computes, but do not actually perform any
computation. Some type-checking is done on while we build our graphs, so if you
try to do something really crazy you'll see an exception right away.
.. _symbolic graph: WRITEME.html
To actually use our graph for computation, we have to compile (or build) it into
a function_ `f`. The compiled function is actually capable of performing
computation. So after we have built f, we use it to compute the value of y from
a `value input` x. Some argument checking is only possible at run-time, so if
you ask for impossible things (i.e. logarithm of a negative number, sum of
matrices with different shapes) then you will get exceptions from the compiled
function. These exceptions can be tricky to understand, but we feel your pain
and we are working hard to make these problems errors easier to fix.
*TODO: Is concrete the opposite of symbolic? Do we actually have a term for this?*
*TODO: Go over TerminologyGlossary and make sure we touch on / link to most basic concepts in the above.*
*It would be worth thinking through the order in which these terms should be introduced.
Can we inline the text?'''*
*Note: Theano has two types of [DefineScalar scalar].*
Matrix example
==============
In the following example, we will build a function to evaluate the dot product `f(x) = dot(x, w)`.
*TODO: Are there ways we can nicely format the matrix math?*
.. code-block:: python
import theano
import theano.tensor as tensor
# Define the symbolic results
x_sym = tensor.matrix()
w_sym = tensor.matrix()
y_sym = tensor.dot(x_sym, w_sym)
f = theano.function([x_sym, w_sym], [y_sym])
from numpy import asarray
# Now, choose concrete x and w values.
# x = [[1 2 3]
# [4 5 6]]
x = asarray([[1, 2, 3], [4, 5, 6]])
# w = [[ 1 2]
# [-1 -2]
# [ 3 3]]
w = asarray([[1, 2], [-1, -2], [3, 3]])
# f(x, w) = [[ 8. 7.]
# [ 17. 16.]]
# .all() checks the equality over all matrix entries.
assert (f(x, w) == asarray([[8, 7], [17, 16]])).all()
*TODO: Explain the matrix and other interesting things going on here.*
*TODO: Explain that we have a lot of numpy functionality reimplemented. Link to numpy docs and say familiarity won't hurt. Also link to list of available ops.*
Broadcasting example
====================
Broadcasting is a subtle and important concept in numpy, which I don't
completely understand. Regardless, here is an example of how broadcasting
works.
*WRITEME: Extend to above example to add a vector.*
Gradient example
================
We are going to write some gradient-based learning code.
You may now wish to review some
`matrix conventions <http://pylearn.org/pylearn/wiki/MatrixConventions>`__.
(Hint: Each row is a training instance, each column is a feature dimension.)
*WRITEME: A simple logistic regression example.*
State example
=============
*WRITEME: A simple logistic regression example, with implicit weights.*
Summary
=======
*TODO: Rewrite above examples to use doctest strings?*
*TODO: Go through above and link all terms, either to wiki documentation or to
epydoc documentation.*
*TODO: I would be useful to actually have example files like this in the source
code. The question is how to automatically extract the source files and inline
them into this documentation.*
...@@ -31,133 +31,149 @@ ...@@ -31,133 +31,149 @@
from docutils import nodes from docutils import nodes
from docutils.parsers.rst import directives from docutils.parsers.rst import directives
try: try:
import pygments import pygments
from pygments import highlight
from pygments.lexers import get_lexer_by_name from pygments.lexers import get_lexer_by_name
from pygments.formatters.html import _get_ttype_class from pygments.formatters.html import _get_ttype_class
except ImportError: from pygments.styles import get_style_by_name
pass from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter
# Customisation
# Customisation # -------------
# ------------- #
# # Do not insert inline nodes for the following tokens.
# Do not insert inline nodes for the following tokens. # (You could add e.g. Token.Punctuation like ``['', 'p']``.) ::
# (You could add e.g. Token.Punctuation like ``['', 'p']``.) ::
unstyled_tokens = ['']
unstyled_tokens = ['']
# DocutilsInterface
# DocutilsInterface # -----------------
# ----------------- #
# # This interface class combines code from
# This interface class combines code from # pygments.formatters.html and pygments.formatters.others.
# pygments.formatters.html and pygments.formatters.others. #
# # It does not require anything of docutils and could also become a part of
# It does not require anything of docutils and could also become a part of # pygments::
# pygments::
class DocutilsInterface(object):
class DocutilsInterface(object): """Parse `code` string and yield "classified" tokens.
"""Parse `code` string and yield "classified" tokens.
Arguments
code -- string of source code to parse
language -- formal language the code is written in.
Merge subsequent tokens of the same token-type.
Yields the tokens as ``(ttype_class, value)`` tuples,
where ttype_class is taken from pygments.token.STANDARD_TYPES and
corresponds to the class argument used in pygments html output.
"""
def __init__(self, code, language):
self.code = code
self.language = language
def lex(self): Arguments
# Get lexer for language (use text as fallback)
try:
lexer = get_lexer_by_name(self.language)
except ValueError:
# info: "no pygments lexer for %s, using 'text'"%self.language
lexer = get_lexer_by_name('text')
return pygments.lex(self.code, lexer)
code -- string of source code to parse
def join(self, tokens): language -- formal language the code is written in.
"""join subsequent tokens of same token-type
""" Merge subsequent tokens of the same token-type.
tokens = iter(tokens)
(lasttype, lastval) = tokens.next() Yields the tokens as ``(ttype_class, value)`` tuples,
for ttype, value in tokens: where ttype_class is taken from pygments.token.STANDARD_TYPES and
if ttype is lasttype: corresponds to the class argument used in pygments html output.
lastval += value
else:
yield(lasttype, lastval)
(lasttype, lastval) = (ttype, value)
yield(lasttype, lastval)
def __iter__(self):
"""parse code string and yield "clasified" tokens
"""
try:
tokens = self.lex()
except IOError:
print "INFO: Pygments lexer not found, using fallback"
# TODO: write message to INFO
yield ('', self.code)
return
for ttype, value in self.join(tokens):
yield (_get_ttype_class(ttype), value)
# code_block_directive """
# --------------------
# ::
def code_block_directive(name, arguments, options, content, lineno, def __init__(self, code, language):
content_offset, block_text, state, state_machine): self.code = code
"""parse and classify content of a code_block self.language = language
"""
language = arguments[0] def lex(self):
# create a literal block element and set class argument # Get lexer for language (use text as fallback)
code_block = nodes.literal_block(classes=["code-block", language]) try:
lexer = get_lexer_by_name(self.language)
# parse content with pygments and add to code_block element except ValueError:
for cls, value in DocutilsInterface(u'\n'.join(content), language): # info: "no pygments lexer for %s, using 'text'"%self.language
if cls in unstyled_tokens: lexer = get_lexer_by_name('text')
# insert as Text to decrease the verbosity of the output. return pygments.lex(self.code, lexer)
code_block += nodes.Text(value, value)
def join(self, tokens):
"""join subsequent tokens of same token-type
"""
tokens = iter(tokens)
(lasttype, lastval) = tokens.next()
for ttype, value in tokens:
if ttype is lasttype:
lastval += value
else:
yield(lasttype, lastval)
(lasttype, lastval) = (ttype, value)
yield(lasttype, lastval)
def __iter__(self):
"""parse code string and yield "clasified" tokens
"""
try:
tokens = self.lex()
except IOError:
print "INFO: Pygments lexer not found, using fallback"
# TODO: write message to INFO
yield ('', self.code)
return
for ttype, value in self.join(tokens):
yield (_get_ttype_class(ttype), value)
# code_block_directive
# --------------------
# ::
def code_block_directive(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
"""parse and classify content of a code_block
"""
language = arguments[0]
# create a literal block element and set class argument
if 0:
code_block = nodes.literal_block(classes=["code-block", language])
code_block += nodes.raw('<b>hello</b> one', 'hello two')
else: else:
code_block += nodes.inline(value, value, classes=[cls]) code_block = nodes.literal_block(classes=["code-block", language])
return [code_block] # parse content with pygments and add to code_block element
for cls, value in DocutilsInterface(u'\n'.join(content), language):
if cls in unstyled_tokens:
# insert as Text to decrease the verbosity of the output.
code_block += nodes.Text(value, value)
else:
code_block += nodes.inline(value, value, classes=[cls])
if 0:
v = highlight(u'\n'.join(content), PythonLexer(),
HtmlFormatter(style='colorful', full=True, cssfile='blah.css'))
print help(nodes.Inline)
return [code_block]
# Register Directive
# ------------------
# ::
code_block_directive.arguments = (1, 0, 1)
code_block_directive.content = 1
directives.register_directive('code-block', code_block_directive)
# .. _doctutils: http://docutils.sf.net/
# .. _pygments: http://pygments.org/
# .. _Using Pygments in ReST documents: http://pygments.org/docs/rstdirective/
# .. _proof of concept:
# http://article.gmane.org/gmane.text.docutils.user/3689
#
# Test output
# -----------
#
# If called from the command line, call the docutils publisher to render the
# input::
# Register Directive except ImportError:
# ------------------ print >> sys.stderr, "Failed to import pygments"
# :: pass
code_block_directive.arguments = (1, 0, 1)
code_block_directive.content = 1
directives.register_directive('code-block', code_block_directive)
# .. _doctutils: http://docutils.sf.net/
# .. _pygments: http://pygments.org/
# .. _Using Pygments in ReST documents: http://pygments.org/docs/rstdirective/
# .. _proof of concept:
# http://article.gmane.org/gmane.text.docutils.user/3689
#
# Test output
# -----------
#
# If called from the command line, call the docutils publisher to render the
# input::
if __name__ == '__main__': if __name__ == '__main__':
from docutils.core import publish_cmdline, default_description from docutils.core import publish_cmdline, default_description
......
/*
* :Author: Your Name
* :Contact: Your Email Address
* :Copyright: This stylesheet has been placed in the public domain.
*
* Stylesheet for use with Docutils. [Optionally place a more
* detailed description here.]
* */
@import url(html4css1.css); /* for basic rst stuff */
@import url(colorful.css); /* for source highlighting */
/* Your customizations go here. For example: */
/*
h1, h2, h3, h4, h5, h6, p.topic-title {
font-family: sans-serif }
*/
Title
=====
Some text.
Subtitle
--------
More stuff_.
.. _stuff:: http://www.google.com
======
Theano
======
---------------------------------------------------------------
An optimizing compiler for matrix valued expressions in Python
---------------------------------------------------------------
Theano is an optimizing compiler in Python, built to evaluate complicated
expressions (especially matrix-valued ones) as quickly as possible.
It was written at LISA_ to explore techniques for machine learning.
Our project uses the name to honour the ancient Greek mathematician.
--------------------------------------------------------------------------------
.. _not in the normal sense: :wiki:`WhatIsTheano`
Overview
========
**To get up & running quickly** see README_.
All **documentation** can be reached from the `Theano Project Documentation Overview`_.
As developers of an open source project, we rely on **feedback** for
determining what features to implement, and what documentation needs to be
improved. The best forum for feedback is the theano-users_ mailing list.
All **discussion** about theano also takes place on the theano-users_ mailing list.
If you find a **bug**, please file a `bug report`_ or send email to
the theano-users_ mailing list. **Patch** submissions should be
sent to theano-dev_.
We welcome all kinds of **contributions**. Our `task list`_ is
full of interesting ideas awaiting a champion. If you have any
questions regarding how to extend Theano, please feel free to ask on
the Theano-dev_ mailing list.
Theano is in active development and should be considered **experimental**.
APIs are subject to change at any time.
Download
========
We recommend that you use the `latest snapshot`_,
Better yet, use `mercurial`_ to keep your installation fresh.
The snapshots usually contain *more features* and *fewer bugs* than the
"official" releases |---| they're not only for developers!
.. class:: credits
Docs by docutils_ and epydoc_.
Project by Mercurial_ and TRAC_.
Powered by Python_ and SciPy_.
Coded at the LISA_ lab.
.. class:: hidden
Google should index the mailing lists:
`theano-users <http://groups.google.com/group/theano-users?pli=1>`__,
and
`theano-dev <http://groups.google.com/group/theano-dev?pli=1>`__.
.. |---| unicode:: U+02014 .. em dash
:trim:
.. _latest snapshot: http://pylearn.org/hg/theano/archive/tip.tar.gz
.. _bug report: http://lgcm.iro.umontreal.ca/theano/newticket
.. _theano-users: http://groups.google.com/group/theano-users?pli=1
.. _theano-dev: http://groups.google.com/group/theano-dev?pli=1
.. _reStructuredText: rst.html
.. _task list: http://lgcm.iro.umontreal.ca/theano/query?status=accepted&status=assigned&status=new&status=reopened&group=milestone&max=200&col=id&col=summary&col=status&col=owner&col=type&col=priority&col=component&col=time&report=9&order=priority
.. _README: README.html
.. _Quick-Start: README.html#quick-start
.. _Theano Project Documentation Overview: doc/index.html
.. _Mercurial: http://www.selenic.com/mercurial/wiki/
.. _docutils: http://docutils.sourceforge.net
.. _epydoc: http://epydoc.sourceforge.net/
.. _scipy: http://scipy.org/
.. _Python: http://www.python.org/
.. _TRAC: http://trac.edgewall.org/
.. _LISA: http://www.iro.umontreal.ca/rubrique.php3?id_rubrique=27
.. |TRAC| image:: http://www.edgewall.org/gfx/trac_logo.png
:target: http://www.edgewall.org/
:alt: Trac Logo
:align: middle
:class: borderless
:width: 193
:height: 32
.. |Python| image:: python.png
:alt: Python Logo
:align: middle
:class: borderless
:width: 193
:height: 32
.. |LISA| image:: http://www.iro.umontreal.ca/images/neurone_chip2.jpg
:target: http://www.iro.umontreal.ca/rubrique.php3?id_rubrique=27
:width: 193
:height: 32
:alt: LISA Logo
:align: middle
:class: borderless
..
Local Variables:
mode: indented-text
indent-tabs-mode: nil
sentence-end-double-space: t
fill-column: 70
End:
#!/bin/bash #!/bin/bash
APIRST2HTML=doc/apirst2html.py
EPYDOC_ARGS='--external-api=api --external-api-file=api:html/api/api-objects.txt --external-api-root=api:../api/'
mkdir -p html/api && mkdir -p html/doc mkdir -p html/api && mkdir -p html/doc
# this builds some stuff or something... basically makes the rest work properly # this builds some stuff or something... basically makes the rest work properly
# for a reason I don't understand. -JB 20080924 # for a reason I don't understand. -JB 20080924
python __init__.py python __init__.py
#runs if you called $./local.build_html.sh epydoc
if [ " $1" != " rst" ]; then if [ " $1" != " rst" ]; then
./epydoc --config local.epydoc ./epydoc --config local.epydoc
fi fi
#runs if you called $./local.build_html.sh rst
if [ " $1" != " epydoc" ]; then if [ " $1" != " epydoc" ]; then
python gen_oplist.py > doc/oplist.txt APIRST2HTML=doc/apirst2html.py
for RST in graph oplist ; do EPYDOC_ARGS='--external-api=api --external-api-file=api:html/api/api-objects.txt --external-api-root=api:../api/ --link-stylesheet'
$APIRST2HTML $EPYDOC_ARGS doc/$RST.txt html/doc/$RST.html # install the stylesheets
done HTML4CSS1='/usr/lib/python2.5/site-packages/docutils/writers/html4css1/html4css1.css'
cp $HTML4CSS1 html/html4css1.css
cp doc/colorful.css html/colorful.css
cp doc/style.css html/style.css
#generate the index & readme files
echo "$APIRST2HTML $EPYDOC_ARGS index.txt html/index.html..."
$APIRST2HTML $EPYDOC_ARGS --stylesheet=style.css index.txt html/index.html
echo "$APIRST2HTML $EPYDOC_ARGS README.txt html/README.html..."
$APIRST2HTML $EPYDOC_ARGS --stylesheet=style.css README.txt html/README.html
#generate the oplist in ReST format
echo "gen oplist..."
python gen_oplist.py > doc/oplist.txt
#generate html files for all the ReST documents in doc/
echo "gen doc/*.txt..."
for RST in doc/*.txt; do
BASENAME=$(basename $RST .txt)
echo "gen doc/$BASENAME.txt..."
$APIRST2HTML $EPYDOC_ARGS --stylesheet=../style.css doc/$BASENAME.txt html/doc/$BASENAME.html
done
fi fi
...@@ -31,7 +31,10 @@ from elemwise import Elemwise, DimShuffle, CAReduce, Sum ...@@ -31,7 +31,10 @@ from elemwise import Elemwise, DimShuffle, CAReduce, Sum
__oplist_constructor_list = [] __oplist_constructor_list = []
"""List of functions to be listed as op constructors in the oplist (`gen_oplist`, doc/oplist.txt).""" """List of functions to be listed as op constructors in the oplist (`gen_oplist`, doc/oplist.txt)."""
def constructor(f): def constructor(f):
"""Make `f` appear as a constructor in the oplist (`gen_oplist`, doc/oplist.txt).""" """Add `f` to :doc:`oplist`.
Make `f` appear as a constructor in the oplist (`gen_oplist`, doc/oplist.txt).
"""
__oplist_constructor_list.append(f) __oplist_constructor_list.append(f)
return f return f
def __oplist_tag(thing, tag): def __oplist_tag(thing, tag):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论