Skip to content

Commit

Permalink
fix: prevent sphinx builder errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Apr 13, 2024
1 parent 9b4d352 commit 74a5729
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/shibuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@


def _html_page_context(app: Sphinx, pagename: str, templatename: str, context: Dict[str, Any], doctree):
assert isinstance(app.builder, StandaloneHTMLBuilder)
if not isinstance(app.builder, StandaloneHTMLBuilder):
return

# fixing pageurl, need to submit a PR to sphinx
if "pageurl" in context:
Expand All @@ -48,13 +49,15 @@ def _initialize_builder(app: Sphinx):
app.add_js_file("shibuya.js")
app.add_css_file("print.css", media='print')

edit_source_link = create_edit_source_link(app.config.html_context)
app.config.html_context.update({
"edit_source_link": edit_source_link,
"expandtoc": normalize_globaltoc,
})
if hasattr(app.config, 'html_context'):
edit_source_link = create_edit_source_link(app.config.html_context)
app.config.html_context.update({
"edit_source_link": edit_source_link,
"expandtoc": normalize_globaltoc,
})

app.builder.highlighter.formatter = WrapLineFormatter
if isinstance(app.builder, StandaloneHTMLBuilder):
app.builder.highlighter.formatter = WrapLineFormatter


def setup(app: Sphinx):
Expand Down

0 comments on commit 74a5729

Please sign in to comment.