提交 eb95000e authored 作者: Pascal Lamblin's avatar Pascal Lamblin 提交者: GitHub

Merge pull request #4604 from fvisin/change_theme

Change documentation theme to readthedocs and add source links
/* work around https://github.com/snide/sphinx_rtd_theme/issues/149 */
.rst-content table.field-list .field-body {
padding-top: 8px;
}
// Create version selector for documentation top bar.
(function() {
var url = window.location.href;
......@@ -10,9 +9,9 @@
// If doc is run localy
if (url.startsWith('file')) {
theano_dir = 'html';
versions_dir = {"local":"html"};
versions_dir = {"local":"html", "test":"test"};
}
var root_url = url.substring(0, url.search('/' + theano_dir)) + '/';
// Regular expression to find theano version directory in URL.
......@@ -28,51 +27,49 @@
versions_dir[ver] = current_version
}
function build_select() {
// Build HTML string for version selector combo box and
// select current version by iterating versions_dir.
function build_vswitch() {
// Build HTML string for version selector, based on ReadTheDocs theme's versions.html
var vswitch = ['<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions" align=left>'];
vswitch.push('<span class="rst-current-version" data-toggle="rst-current-version">');
vswitch.push('<span class="fa fa-book"></span>');
vswitch.push('v:' + current_version);
vswitch.push('<span class="fa fa-caret-down"></span>');
vswitch.push('</span>');
vswitch.push('<div class="rst-other-versions">');
var select = ['<select>'];
vswitch.push('<dl>');
vswitch.push('<dt>Versions</dt>');
$.each(versions_dir, function(version, dir){
select.push('<option value="' + version + '"');
if (dir == current_version)
select.push(' selected="selected">' + version + '</option>');
else
select.push('>' + version + '</option>');
var new_url = url.replace(url.match(version_regex)[0],
'/' + versions_dir[version] + '/');
vswitch.push('<dd><a href=' + new_url + '>' + version + '</a></dd>');
});
vswitch.push('</dl>');
return select.join('');
}
vswitch.push('<dl>');
vswitch.push('<dt>Downloads</dt>');
var pdf_url = "http://deeplearning.net/software/theano/theano.pdf"
vswitch.push('<dd><a href=' + pdf_url + '>' + 'PDF' + '</a></dd>');
vswitch.push('</dl>');
vswitch.push('<dl>');
vswitch.push('<dt>On GitHub</dt>');
var git_master = "https://github.com/Theano/Theano"
vswitch.push('<dd><a href=' + git_master + '>' + 'Fork me' + '</a></dd>');
vswitch.push('</dl>');
function on_switch() {
// Method triggered when an option is selected in combo box.
var selected = $(this).children('option:selected').attr('value');
vswitch.push('</div>');
vswitch.push('</div>');
// Insert selected version in URL.
var new_url = url.replace(url.match(version_regex)[0],
'/' + versions_dir[selected] + '/');
if (url != new_url) {
$.ajax({
success: function() {
window.location.href = new_url;
},
// If page not in version, go to root of documentation.
error: function() {
window.location.href = root_url + versions_dir[selected] + '/';
}
});
}
return vswitch.join('');
}
// Create combobox HTML, assign to placeholder in layout.html and
// bind selection method.
// Create HTML for version switcher and assign to placeholder in layout.html.
$(document).ready(function() {
// Get theano version.
// var current_version = DOCUMENTATION_OPTIONS.VERSION;
// Build default switcher
$('.version_switcher_placeholder').html(build_select());
$('.version_switcher_placeholder select').bind('change', on_switch)
$('.version_switcher_placeholder').html(build_vswitch());
// Check server for other doc versions and update switcher.
if (url.startsWith('http')) {
......@@ -80,9 +77,7 @@
$.each(data, function(version, dir) {
versions_dir[version] = dir;
});
$('.version_switcher_placeholder').html(build_select());
$('.version_switcher_placeholder select').bind('change', on_switch)
$('.version_switcher_placeholder').html(build_vswitch());
});
}
});
......
{% extends "!layout.html" %}
{%- block rootrellink %}
<li>
<span class="version_switcher_placeholder"></span>
</li>
{{ super() }}
{% endblock %}
{%- block extrahead %}
{% block footer %}
{{ super() }}
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-168290-9']);
_gaq.push(['_trackPageview']);
</script>
<script type="text/javascript"
src="{{ pathto('_static/version_switch.js', 1) }}">
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
{% endblock %}
{% block footer %}
{{ super() }}
<!--Insert version switcher at bottom of sidebar-->
<script type="text/javascript">
(function() {
var ga = document.createElement('script');
ga.src = ('https:' == document.location.protocol ?
'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
ga.setAttribute('async', 'true');
document.documentElement.firstChild.appendChild(ga);
})();
var span = document.createElement("SPAN")
var span_class = document.createAttribute("class");
span_class.value = "version_switcher_placeholder";
span.setAttributeNode(span_class);
var div = document.createElement("DIV");
var text = document.createTextNode("v:");
var div_class = document.createAttribute("class");
div_class.value = "version-switcher";
div.setAttributeNode(div_class);
var style = document.createAttribute("style");
style.value = "color:#27AA5E; padding-right:5px;";
div.setAttributeNode(style);
var align = document.createAttribute("align");
align.value = "right";
div.setAttributeNode(align);
div.appendChild(text);
div.appendChild(span);
var nav_div = document.getElementsByClassName("wy-nav-side")[0];
nav_div.appendChild(div);
</script>
<script type="text/javascript"
src="{{ pathto('_static/version_switch.js', 1) }}">
</script>
{% endblock %}
......@@ -22,6 +22,8 @@ from __future__ import absolute_import, print_function, division
import os
import sys
import theano
theano_path = os.path.join(os.path.dirname(__file__), os.pardir)
sys.path.append(os.path.abspath(theano_path))
......@@ -30,7 +32,11 @@ sys.path.append(os.path.abspath(theano_path))
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.doctest', 'sphinx.ext.napoleon']
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.doctest',
'sphinx.ext.napoleon',
'sphinx.ext.linkcode']
todo_include_todos = True
napoleon_google_docstring = False
......@@ -103,7 +109,20 @@ pygments_style = 'sphinx'
# must exist either in Sphinx' static/ path, or in one of the custom paths
# given in html_static_path.
#html_style = 'default.css'
html_theme = 'sphinxdoc'
# html_theme = 'sphinxdoc'
# Read the docs style:
if os.environ.get('READTHEDOCS') != 'True':
try:
import sphinx_rtd_theme
except ImportError:
pass # assume we have sphinx >= 1.3
else:
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
html_theme = 'sphinx_rtd_theme'
def setup(app):
app.add_stylesheet("fix_rtd.css")
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
......@@ -114,8 +133,7 @@ html_theme = 'sphinxdoc'
# The name of an image file (within the static path) to place at the top of
# the sidebar.
#html_logo = 'images/theano_logo-200x67.png'
html_logo = 'images/theano_logo_allblue_200x46.png'
html_logo = 'images/theano_logo_allwhite_210x70.png'
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
......@@ -165,6 +183,35 @@ html_use_smartypants = True
# Output file base name for HTML help builder.
htmlhelp_basename = 'theanodoc'
# Options for the linkcode extension
# ----------------------------------
# Resolve function
# This function is used to populate the (source) links in the API
def linkcode_resolve(domain, info):
def find_source():
# try to find the file and line number, based on code from numpy:
# https://github.com/numpy/numpy/blob/master/doc/source/conf.py#L286
obj = sys.modules[info['module']]
for part in info['fullname'].split('.'):
obj = getattr(obj, part)
import inspect
import os
fn = inspect.getsourcefile(obj)
fn = os.path.relpath(fn, start=os.path.dirname(theano.__file__))
source, lineno = inspect.getsourcelines(obj)
return fn, lineno, lineno + len(source) - 1
if domain != 'py' or not info['module']:
return None
try:
filename = 'theano/%s#L%d-L%d' % find_source()
except Exception:
filename = info['module'].replace('.', '/') + '.py'
import subprocess
tag = subprocess.Popen(['git', 'rev-parse', 'HEAD'],
stdout=subprocess.PIPE,
universal_newlines=True).communicate()[0][:-1]
return "https://github.com/Theano/theano/blob/%s/%s" % (tag, filename)
# Options for LaTeX output
# ------------------------
......
......@@ -239,10 +239,10 @@ StackOverflow, follow their guidance for `answering questions <http://stackoverf
introduction
install
tutorial/index
library/index
optimizations
extending/index
dev_start_guide
optimizations
library/index
glossary
links
internal/index
......
.. _libdoc:
.. _Library documentation:
=====================
Library Documentation
=====================
=================
API Documentation
=================
This documentation covers Theano module-wise. This is suited to finding the
Types and Ops that you can use to build and compile expression graphs.
......@@ -11,20 +12,20 @@ Types and Ops that you can use to build and compile expression graphs.
.. toctree::
:maxdepth: 1
tensor/index
gradient
compile/index
config
printing
d3viz/index
compile/index
gpuarray/index
sparse/index
sparse/sandbox
scalar/index
gof/index
gpuarray/index
gradient
misc/pkl_utils
scan
printing
sandbox/index
scalar/index
scan
sparse/index
sparse/sandbox
tensor/index
typed_list
There are also some top-level imports that you might find more convenient:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论