Minor fixes and improvements: PEP8, appearance, etc.

Removed a clumsy workaround (about paths)

Fixed links to image files to fix sphinx warning.

Removed non-ascii character

Another non ascii character

And another non-ascii character... (to be squashed later on)

Corrected some typos in the docstrings of sphinx-gallery files

These corrections have also been submitted as a patch to the original
sphinx-gallery project (#121)

Corrected the appearance of two examples of the gallery

Tweaked CSS for larger images

Added sphinx-gallery's license and a README.txt about the origin of
this directory.

Edited gabor_from_astronaut example for nicer popup

PEP 8 + minor fixes

Removed commented lines of code
This commit is contained in:
emmanuelle
2016-06-06 17:30:44 +02:00
parent d998e7e534
commit 8b2dbd56e5
15 changed files with 101 additions and 72 deletions
+27
View File
@@ -0,0 +1,27 @@
Copyright (c) 2015, Óscar Nájera
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of sphinx-gallery nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+6
View File
@@ -0,0 +1,6 @@
This directory was taken from
https://github.com/sphinx-gallery/sphinx-gallery
Files should not diverge from the original sphinx-gallery project, and
any modifications should be submitted as pull requests to sphinx-gallery
(with some exceptions such as CSS tweaking).
+17 -7
View File
@@ -1,8 +1,8 @@
/*
Sphinx-Gallery is has compatible CSS to fix default sphinx themes
Sphinx-Gallery has compatible CSS to fix default sphinx themes
Tested for Sphinx 1.3.1 for all themes: default, alabaster, sphinxdoc,
scrolls, agogo, traditional, nature, haiku, pyramid
Tested for Read the docs theme 0.1.7 */
Tested for Read the Docs theme 0.1.7 */
.sphx-glr-thumbcontainer {
background: #fff;
border: solid #fff 1px;
@@ -12,7 +12,7 @@ Tested for Read the docs theme 0.1.7 */
box-shadow: none;
float: left;
margin: 5px;
min-height: 230px;
min-height: 240px;
padding-top: 5px;
position: relative;
}
@@ -40,12 +40,12 @@ thumbnail with its default link Background color */
}
.sphx-glr-thumbcontainer .figure {
margin: 10px;
width: 160px;
width: 200px;
}
.sphx-glr-thumbcontainer img {
display: inline;
max-height: 160px;
width: 160px;
max-height: 200px;
width: 200px;
}
.sphx-glr-thumbcontainer[tooltip]:hover:after {
background: rgba(0, 0, 0, 0.8);
@@ -58,7 +58,7 @@ thumbnail with its default link Background color */
padding: 5px 15px;
position: absolute;
z-index: 98;
width: 220px;
width: 240px;
bottom: 52%;
}
.sphx-glr-thumbcontainer[tooltip]:hover:before {
@@ -125,3 +125,13 @@ ul.sphx-glr-horizontal li {
ul.sphx-glr-horizontal img {
height: auto !important;
}
p.sphx-glr-signature a.reference.external {
background-color: #EBECED;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
padding: 3px;
position: absolute;
right: 15px;
}
+3 -7
View File
@@ -58,11 +58,7 @@ def get_data(url, gallery_dir):
if sys.version_info[0] == 2 and isinstance(url, unicode):
url = url.encode('utf-8')
cwd = os.getcwd()
if 'source' in cwd:
cached_file = os.path.join(gallery_dir, 'searchindex')
else:
cached_file = os.path.join('source', gallery_dir, 'searchindex')
cached_file = os.path.join(gallery_dir, 'searchindex')
search_index = shelve.open(cached_file)
if url in search_index:
data = search_index[url]
@@ -321,6 +317,8 @@ class SphinxDocLinkResolver(object):
def _embed_code_links(app, gallery_conf, gallery_dir):
# Add resolvers for the packages for which we want to show links
working_dir = os.getcwd()
os.chdir(app.builder.srcdir)
doc_resolvers = {}
for this_module, url in gallery_conf['reference_url'].items():
try:
@@ -344,8 +342,6 @@ def _embed_code_links(app, gallery_conf, gallery_dir):
"Error:\n".format(this_module))
print(e.args)
working_dir = os.getcwd()
os.chdir(app.builder.srcdir)
html_gallery_dir = os.path.abspath(os.path.join(app.builder.outdir,
gallery_dir))
# patterns for replacement
+3 -3
View File
@@ -4,7 +4,7 @@ r"""
Parser for Jupyter notebooks
============================
Class that holds the Ipython notebook information
Class that holds the Jupyter notebook information
"""
# Author: Óscar Nájera
@@ -48,7 +48,7 @@ def ipy_notebook_skeleton():
def rst2md(text):
"""Converts the RST text from the examples docstrigs and comments
into markdown text for the IPython notebooks"""
into markdown text for the Jupyter notebooks"""
top_heading = re.compile(r'^=+$\s^([\w\s-]+)^=+$', flags=re.M)
text = re.sub(top_heading, r'# \1', text)
@@ -64,7 +64,7 @@ def rst2md(text):
class Notebook(object):
"""Ipython notebook object
"""Jupyter notebook object
Constructs the file cell-by-cell and writes it at the end"""