Skip to content

Commit

Permalink
Apply gallery title options correctly (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed May 20, 2022
1 parent 7a4615c commit e0d4668
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions nbsite/gallery/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,14 @@ def add_nblink(rst_file, host, deployed_file, download_as,
path='/'.join(components), basename=basename, ftype=ftype))


def _thumbnail_div(path_components, section, backend, fname, extension):
def _thumbnail_div(path_components, section, backend, fname, extension, normalize=True, title=None):
"""Generates RST to place a thumbnail in a gallery"""
label = fname.replace('_', ' ').title()
if title is not None:
label = title
elif normalize:
label = fname.replace('_', ' ').title()
else:
label = fname
thumb = os.path.join(*path_components+['thumbnails', '%s.%s' % (fname, extension)])

# Inside rst files forward slash defines paths
Expand Down Expand Up @@ -554,7 +559,7 @@ def generate_gallery(app, page):
if extension == 'py':
continue
thumb_prefix = '_'.join([pre for pre in (section, backend) if pre])
backend_str = backend+'_' if backend else ''
backend_str = backend+'_' if backend else ''
if thumb_prefix:
thumb_prefix += '_'
if basename in titles:
Expand All @@ -569,7 +574,8 @@ def generate_gallery(app, page):
else:
logger.info('%s %s thumbnail' % (verb, basename))
this_entry = _thumbnail_div(
path_components, section, backend, basename, thumb_extension
path_components, section, backend, basename,
thumb_extension, normalize, titles.get(basename)
)

gallery_rst += this_entry
Expand Down

0 comments on commit e0d4668

Please sign in to comment.