提交 c9f6af36 authored 作者: Oriol (ZBook)'s avatar Oriol (ZBook) 提交者: Oriol Abril-Pla

Update docs to use pymc(pydata) theme

上级 8e097c07
sphinx doesn't like it when this repertory isn't available
sphinx doesn't like it when this repertory isn't available
/* work around https://github.com/snide/sphinx_rtd_theme/issues/149 */
.rst-content table.field-list .field-body {
padding-top: 8px;
}
.rst-versions-up {
cursor: pointer;
display: inline;
}
.wy-side-nav-search>div.version {
color: white;
}
// Create version selector for documentation top bar.
(function() {
var url = window.location.href;
var pytensor_dir = 'pytensor'; // directory containing pytensor doc
// Default pytensor version: release and development.
var versions_dir = {"release": "pytensor", "dev": "pytensor_versions/dev"};
// If doc is run localy
if (url.startsWith('file')) {
pytensor_dir = 'html';
versions_dir = {"local":"html", "test":"test"};
}
var root_url = url.substring(0, url.search('/' + pytensor_dir)) + '/';
// Regular expression to find pytensor version directory in URL.
var version_regex = new RegExp("\\/" + pytensor_dir + "(_versions\\/)?([_a-zA-Z.0-9]*)\\/");
// Get current version
var current_version = url.match(version_regex)[0]
current_version = current_version.substring(1, current_version.length - 1)
// Add current version in case versions.json is unavailable
if (current_version != "pytensor" && current_version != "html") {
ver = current_version.replace("pytensor_versions/", "")
versions_dir[ver] = current_version
}
function build_vswitch() {
// Build HTML string for version selector, based on ReadTheDocs theme's versions.html
var vlabel = current_version.replace("pytensor_versions/", "");
if (vlabel == 'pytensor') {
vlabel = 'release';
}
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: ', vlabel, ' ');
vswitch.push('<span class="fa fa-caret-down"></span>');
vswitch.push('</span>');
vswitch.push('<div class="rst-other-versions">');
vswitch.push('<dl>');
vswitch.push('<dt>Versions</dt>');
for (var version in versions_dir) {
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>');
vswitch.push('<dl>');
vswitch.push('<dt>On GitHub</dt>');
var git_master = "https://github.com/pymc-devs/pytensor"
vswitch.push('<dd><a href=\"', git_master + '\">', 'Fork me', '</a></dd>');
vswitch.push('</dl>');
vswitch.push('</div>');
vswitch.push('</div>');
return vswitch.join('');
}
function build_vswitch_up() {
// Build HTML string for version selector, based on ReadTheDocs theme's versions.html
var vlabel = current_version.replace("pytensor_versions/", "");
if (vlabel == 'pytensor') {
vlabel = 'release';
}
else if (vlabel != "dev") {
vlabel = '';
}
var vswitch = ['<div class="rst-versions-up" data-toggle="rst-versions" role="note" aria-label="versions" align=center>'];
vswitch.push('<span class="rst-current-version" data-toggle="rst-current-version">');
vswitch.push(vlabel);
vswitch.push(' <span class="fa fa-caret-down"></span>');
vswitch.push('</span>');
vswitch.push('</div>');
return vswitch.join('');
}
// Create HTML for version switcher and assign to placeholder in layout.html.
$(document).ready(function() {
// Build default switcher
$('.version_switcher_placeholder').html(build_vswitch());
$('.version_switcher_placeholder_up').html(build_vswitch_up());
// Check server for other doc versions and update switcher.
if (url.startsWith('http')) {
$.getJSON(root_url + 'pytensor_versions/versions.json', function(data){
$.each(data, function(version, dir) {
versions_dir[version] = dir;
});
$('.version_switcher_placeholder').html(build_vswitch());
$('.version_switcher_placeholder_up').html(build_vswitch_up());
});
}
});
})();
......@@ -18,15 +18,9 @@
# absolute, like shown here.
# sys.path.append(os.path.abspath('some/directory'))
import os
import sys
import pytensor
pytensor_path = os.path.join(os.path.dirname(__file__), os.pardir)
sys.path.append(os.path.abspath(pytensor_path))
import versioneer
# General configuration
# ---------------------
......@@ -38,27 +32,15 @@ extensions = [
"sphinx.ext.doctest",
"sphinx.ext.napoleon",
"sphinx.ext.linkcode",
"sphinx.ext.mathjax",
]
needs_sphinx = "3"
todo_include_todos = True
napoleon_google_docstring = False
napoleon_include_special_with_doc = False
# We do it like this to support multiple sphinx version without having warning.
# Our buildbot consider warning as error.
try:
from sphinx.ext import imgmath
extensions.append("sphinx.ext.imgmath")
except ImportError:
try:
from sphinx.ext import pngmath
extensions.append("sphinx.ext.pngmath")
except ImportError:
pass
# Add any paths that contain templates here, relative to this directory.
templates_path = [".templates"]
......@@ -70,22 +52,25 @@ master_doc = "index"
# General substitutions.
project = "PyTensor"
copyright = "PyTensor Developers, 2021; PyMC Developers, 2020-2021; 2008--2019, LISA lab"
copyright = "PyMC Team 2022-present,2020-2021; Aesara Developers, 2021-2022; LISA Lab, 2008--2019"
# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
#
# We need this hokey-pokey because versioneer needs the current
# directory to be the root of the project to work.
_curpath = os.getcwd()
os.chdir(os.path.dirname(os.path.dirname(__file__)))
version = pytensor.__version__
if os.environ.get("READTHEDOCS", False):
rtd_version = os.environ.get("READTHEDOCS_VERSION", "")
if rtd_version.lower() == "stable":
version = pymc.__version__.split("+")[0]
elif rtd_version.lower() == "latest":
version = "dev"
else:
version = rtd_version
else:
rtd_version = "local"
# The full version, including alpha/beta/rc tags.
release = versioneer.get_version()
# The short X.Y version.
version = ".".join(release.split(".")[:2])
os.chdir(_curpath)
del _curpath
release = version
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
......@@ -132,19 +117,18 @@ pygments_style = "sphinx"
# https://github.com/readthedocs/sphinx_rtd_theme/issues/766#issuecomment-513852197
html4_writer = True
# 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_css_file("fix_rtd.css")
html_logo = "images/pytensor_logo.svg"
html_theme = "pymc_sphinx_theme"
html_theme_options = {
"use_search_override": False,
}
html_context = {
"github_user": "pymc-devs",
"github_repo": "pytensor",
"github_version": "main",
"doc_path": "doc",
"default_mode": "light",
}
# The name for this set of Sphinx documents. If None, it defaults to
......@@ -166,7 +150,7 @@ def setup(app):
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = [".static", "images", "library/d3viz/examples"]
html_static_path = ["images", "library/d3viz/examples"]
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
......
......@@ -4,6 +4,12 @@
Developer Start Guide
=====================
.. toctree::
:hidden:
self
internal/index
Contributing
============
......
......@@ -10,9 +10,9 @@ dependencies:
- scipy
- six
- sphinx>=3
- sphinx_rtd_theme
- mock
- pillow
- pip
- pip:
- -e ..[doc]
- git+https://github.com/pymc-devs/pymc-sphinx-theme
- -e ..
......@@ -78,18 +78,9 @@ Community
:hidden:
introduction
install
tutorial/index
extending/index
dev_start_guide
optimizations
library/index
troubleshooting
glossary
links
internal/index
acknowledgement
user_guide
API <library/index>
Contributing <dev_start_guide>
.. _Theano: https://github.com/Theano/Theano
.. _pytensor-users: https://gitter.im/pymc-devs/pytensor
.. _introduction:
====================
PyTensor at a Glance
====================
===============
Getting Started
===============
PyTensor is a Python library that allows one to define, optimize/rewrite, and
evaluate mathematical expressions, especially ones involving multi-dimensional
......@@ -150,6 +150,12 @@ pytensor-dev_
We welcome all kinds of contributions. If you have any questions regarding how
to extend PyTensor, please feel free to ask.
.. toctree::
:hidden:
self
install
tutorial/index
.. _LISA: https://mila.umontreal.ca/
.. _Greek mathematician: http://en.wikipedia.org/wiki/Theano_(mathematician)
......
.. _user_guide:
==========
User Guide
==========
.. toctree::
:maxdepth: 1
extending/index
optimizations
troubleshooting
glossary
links
acknowledgement
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论