jupyter-sphinx icon indicating copy to clipboard operation
jupyter-sphinx copied to clipboard

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

Open omanges opened this issue 5 years ago • 11 comments
trafficstars

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

omanges avatar Sep 22 '20 16:09 omanges

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.

akhmerov avatar Sep 22 '20 16:09 akhmerov

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 ?

omanges avatar Sep 22 '20 16:09 omanges

You'd need to figure out two things:

  • How to modify the way the jupyter widgets resolve the extension code
  • How to package your extension together with the generated documentation

akhmerov avatar Sep 22 '20 16:09 akhmerov

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

omanges avatar Sep 22 '20 17:09 omanges

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

akhmerov avatar Sep 22 '20 17:09 akhmerov

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

omanges avatar Sep 23 '20 05:09 omanges

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

omanges avatar Sep 23 '20 09:09 omanges

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

akhmerov avatar Sep 23 '20 09:09 akhmerov

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 avatar Oct 14 '20 14:10 omanges

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>

omanges avatar Oct 14 '20 14:10 omanges

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 ?

12rambau avatar Dec 29 '23 17:12 12rambau