Skip to content

Commit

Permalink
Merge pull request #28 from martinRenou/check_source_suffix
Browse files Browse the repository at this point in the history
Make sure we don't add the ipynb source prefix twice
  • Loading branch information
martinRenou authored Mar 9, 2022
2 parents 7d36cb2 + bc4311c commit db096b2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/jupyterlite_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,16 @@ def parse(self, inputstring, document):
)


def inited(app: Sphinx, error):
def inited(app: Sphinx, config):
# Create the content dir
os.makedirs(os.path.join(app.srcdir, CONTENT_DIR), exist_ok=True)

if (
".ipynb" not in config.source_suffix
and ".ipynb" not in app.registry.source_suffix
):
app.add_source_suffix(".ipynb", "jupyterlite_notebook")


def jupyterlite_build(app: Sphinx, error):
if app.builder.format == "html":
Expand Down Expand Up @@ -242,6 +248,9 @@ def jupyterlite_build(app: Sphinx, error):


def setup(app):
# Initialize RetroLite parser
app.add_source_parser(RetroLiteParser)

app.connect("config-inited", inited)
# We need to build JupyterLite at the end, when all the content was created
app.connect("build-finished", jupyterlite_build)
Expand Down Expand Up @@ -269,10 +278,6 @@ def setup(app):
)
app.add_directive("jupyterlite", JupyterLiteDirective)

# Initialize RetroLite parser
app.add_source_parser(RetroLiteParser)
app.add_source_suffix(".ipynb", "jupyterlite_notebook")

# Initialize Replite directive
app.add_node(
RepliteIframe,
Expand Down

0 comments on commit db096b2

Please sign in to comment.