Skip to content

Gallery titles mapping not used for page titles and sidebar #353

@AtharvaJaiswal005

Description

@AtharvaJaiswal005

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions