jupyter / jupyter-sphinx

Sphinx extension for rendering of Jupyter interactive widgets.
https://jupyter-sphinx.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
187 stars 65 forks source link

How to specify a jupyter widget which currently not published on npmjs.com #167

Open omanges opened 4 years ago

omanges commented 4 years ago

Hi, I am trying to build interactive documentation using jupyter-sphinx, but I am not able to view the output, following are the error I am getting, I think it ie because the widget is not published on npmjs.com 🧐

image

akhmerov commented 4 years ago

That's a tough one! We're using the jupyter widget machinery to render everything with the corresponding mimetype. So to see if you can influence that you should probably ask in the widgets repository.

Without interfering with widgets, I think you have the following options. If you have a non-widget way to render your data, you could serve data as a custom mimetype, and include the rendering javascript separately. Or you could return the html that includes the rendering code.

omanges commented 4 years ago

Is there no way to use locally installed jupyter widget extension, like I can install it locally and tell jupyter-sphinx to use it, rather than searching in npmjs.com ?

akhmerov commented 4 years ago

You'd need to figure out two things:

omanges commented 4 years ago

So what I thik is the call for npmjs.com is made by nbconvert while trying to execute the code cell.

akhmerov commented 4 years ago

That you wouldn't see in your browser logs. Also the npmjs calls are made by the browser, and therefore are unrelated to nbconvert.

omanges commented 4 years ago

No, I was talking about who initiated it i.e the require.min.js 😅

omanges commented 4 years ago

@akhmerov jupyter-sphinx uses nbconvert to execute jupyter code right?

akhmerov commented 4 years ago

Correct. To be more precise, it uses nbclient, the former nbconvert execute preprocessor.

omanges commented 4 years ago

It seems we need to set the data-jupyter-widgets-cdn as specified here https://ipywidgets.readthedocs.io/en/latest/embedding.html#the-case-of-custom-widget-libraries , but now the question is how can we set this from an rst file or Sphinx config 🧐

omanges commented 4 years ago

Like we need to find how can we set the data-jupyter-widgets-cdn in the following script tag generated for documentation

<script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="here-map-widget" src="https://unpkg.com/here-map-widget@^0.1.0/dist/index.js"></script>
12rambau commented 10 months ago

Hi @omanges is this issue still bothering you ? I'm a new maintainer of the repository and I try to find where I can be useful and where people have dropped the gantlet for a very long time.

Since 2020 did you publish your widgets on npm ? Did you managed to do it on your own ?