Skip to content

Deleting source links for notebooks causes an error. #103

@douden

Description

@douden

When using untracked Text-based Notebooks and/or an untracked Jupyter Notebooks in combinatio with git_untracked_show_sourcelink == False, the build fails with an error:

Extension error (sphinx_book_theme.header_buttons.launch):
Handler <function add_launch_buttons at 0x0000022D88AD22A0> for event 'html-page-context' threw an exception (exception: 'sourcename')
Traceback (most recent call last):
  File "C:\Users\douden\AppData\Roaming\Python\Python312\site-packages\sphinx\events.py", line 98, in emit
    results.append(listener.handler(self.app, *args))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\douden\AppData\Roaming\Python\Python312\site-packages\sphinx_book_theme\header_buttons\launch.py", line 62, in add_launch_buttons
    context["sourcename"].endswith(".md")
    ~~~~~~~^^^^^^^^^^^^^^
KeyError: 'sourcename'

The cause is line 262 in sphinx_last_updated_by_git.py:

        del context['sourcename']

Deleting this line will have as effect:

  • The above error will disappear.
  • Source files will still be included in the html-ouput, but the links to the source will be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions