Description
The titles mapping in nbsite_gallery_conf is only used for gallery card labels/thumbnails but not for the actual page title or sidebar entry.
For example, Panel's doc/conf.py defines:
'titles': {
'Vega': 'Altair & Vega',
'DeckGL': 'PyDeck & Deck.gl',
'ECharts': 'PyEcharts & ECharts',
...
}
The gallery cards correctly show "Altair & Vega", but the generated page title and sidebar still show "Vega" (derived from the filename Vega.ipynb).
Root Cause
Both generate_item_md (line 340) and generate_item_rst (line 421) in gallery/gen.py derive the title from the filename only:
name = basename[:-(len(extension)+1)]
title = ' '.join([n[0].capitalize()+n[1:] for n in name.replace('_', ' ').split(' ')])
The titles mapping from content.get('titles', {}) is available via gallery_conf but never consulted in these functions.
Proposed Fix
In both generate_item_md and generate_item_rst, look up the titles mapping before falling back to the filename-derived title:
content = gallery_conf['galleries'][page]
titles = content.get('titles', {})
title = titles.get(name, ' '.join([n[0].capitalize()+n[1:] for n in name.replace('_', ' ').split(' ')]))
Related
Description
The
titlesmapping innbsite_gallery_confis only used for gallery card labels/thumbnails but not for the actual page title or sidebar entry.For example, Panel's
doc/conf.pydefines:The gallery cards correctly show "Altair & Vega", but the generated page title and sidebar still show "Vega" (derived from the filename
Vega.ipynb).Root Cause
Both
generate_item_md(line 340) andgenerate_item_rst(line 421) ingallery/gen.pyderive the title from the filename only:The
titlesmapping fromcontent.get('titles', {})is available viagallery_confbut never consulted in these functions.Proposed Fix
In both
generate_item_mdandgenerate_item_rst, look up thetitlesmapping before falling back to the filename-derived title:Related