Skip to content

Commit

Permalink
Copy CSS and SVG files earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeier committed Aug 13, 2024
1 parent cc292c8 commit d869daa
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/nbsphinx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,23 @@ def builder_inited(app):
os.path.join(os.path.dirname(__file__), '_texinputs'),
os.path.join(app.builder.outdir))

if app.builder.format == 'html':
context = {
'nbsphinx_responsive_width': app.config.nbsphinx_responsive_width,
'nbsphinx_prompt_width': app.config.nbsphinx_prompt_width,
}
assets = (
'nbsphinx-code-cells.css_t',
'nbsphinx-gallery.css',
'nbsphinx-no-thumbnail.svg',
'nbsphinx-broken-thumbnail.svg',
)
for a in assets:
sphinx.util.fileutil.copy_asset(
os.path.join(os.path.dirname(__file__), '_static', a),
os.path.join(app.builder.outdir, '_static'),
context=context)


def env_merge_info(app, env, docnames, other):
env.nbsphinx_notebooks.update(other.nbsphinx_notebooks)
Expand Down Expand Up @@ -1693,22 +1710,6 @@ def html_collect_pages(app):
sphinx.util.copyfile(
os.path.join(app.env.nbsphinx_auxdir, notebook),
os.path.join(app.builder.outdir, notebook))

context = {
'nbsphinx_responsive_width': app.config.nbsphinx_responsive_width,
'nbsphinx_prompt_width': app.config.nbsphinx_prompt_width,
}
assets = (
'nbsphinx-code-cells.css_t',
'nbsphinx-gallery.css',
'nbsphinx-no-thumbnail.svg',
'nbsphinx-broken-thumbnail.svg',
)
for a in assets:
sphinx.util.fileutil.copy_asset(
os.path.join(os.path.dirname(__file__), '_static', a),
os.path.join(app.builder.outdir, '_static'),
context=context)
return [] # No new HTML pages are created

def env_updated(app, env):
Expand Down

0 comments on commit d869daa

Please sign in to comment.