Jupyter code cells in Google docs, possible or impossible?

Does someone know how to get started building a plugin for Google docs?

My dream: I’d like to be able to add a “paragraph” to a word processor document. This “paragraph” would contain code (like a notebook cell) that I can run, then we show the output in the document.

Conceptually the UI would be the “inverse” of a notebook. In a Jupyter notebook you have code, code, text, code, code, text (code interspersed by text). In a word processor you’d have text, text, text, code, text (text with occasional bit of code).

Probably this would be a Google doc but could be any word processor really. We could (start with) backing the compute with something like a BinderHub (thebelab or juniper style).

If anyone has any pointers on how to build integrations or extensions like this that would be great. I feel like just learning the correct words to describe what needs doing would be a big win already.

2 Likes

It looks like https://github.com/gsuitedevs/apps-script-samples/tree/master/docs might be a place to get started with examples.

I think that Stencila has a Google Docs integration for interactive Stencila kernels coming soon, though it’s not really a “Jupyter” thing, more like a specific Stencila product

1 Like

Sounds like it is possible to do then, we just have to find out how :slight_smile:

I looked into this about 2 years ago and it wasn’t possible. There is no plugin or extension type for Google Docs to embed custom content. I just looked at https://developers.google.com/apps-script/guides/docs and it looks like you edit a doc programmatically, add menus/dialogs/sidebars, and and respond to an onOpen event, so it doesn’t sound like you could respond to a keypress event. Additionally, app script is like a subset of Javascript (it’s based on JS 1.6), so it doesn’t have the complete Javascript standard library or support ES6 syntax and I think it has restrictions around HTTP requests, etc. If this were possible at the time, then I wouldn’t have spent hundreds of hours working on my “Dynamic Docs” POC that is like a paired-down Google Docs (e.g. Notion or Dropbox Paper) with Jupyter cells powered by the browser and Binder!

3 Likes

Got a link? :slightly_smiling_face: I don’t think I’ve seen that!

I’m curious why you think this is needed? I mean, what you described, to me, just sounds like a Jupyter notebook! (A paragraph or more of text, a code cell, the code output, then repeat.)

Of course, Google docs have collaboration and commenting built in, but in my mind adding collaboration and commenting to Jupyter notebooks is superior to embedding code cells in a Google doc… The text portions in a notebook can have beautiful LaTeX equations, for example. Is it that you think markdown is still a barrier for less techy folks?

A lot more people use something like Google docs/Word than Jupyter. Giving them an easy and low risk way to try out going beyond copy&pasting screenshots of figures would be cool. I am also sure that after a bit of time using it they’d want more and start trying out normal notebooks. This means one use case is as a “gateway drug” to Jupyter.

The other use case is that in my day-to-day job I work with a sales team, a CEO, CFO, etc. Persuading most of these people to install Jupyter is a lost cause. Partly because of the skills they have/lack and also because of the additional support burden. Periodically they ask for up-to-date plots/tables/numbers for sales decks, investor reports or compliance/financial reporting.

Having to run the notebook that makes these is busy work and creates a bottleneck (the small number of people who know how to run the notebook). It would be cool (for them and for me) if we could insert a few cells into the document, spreadsheet or slide deck that produces the up-to-date version. It would empower them to update their figures when ever they want. They could even start making small tweaks.

Overall I think of it as a way of picking people up from where they are now. This makes notebooks considerably more accessible to a very large number of users. Because even with nteract you can not explain how to run a Python notebook I send someone on windows machine in 160characters. Where as people can explain in 160char how to run a Tableaux/other-tools-are-available thing (Download and install Tableaux from https;//blah.com. Then double click the attachment).

5 Likes

Looks like people have managed to build something that lets them hook up Jupyter and Word Embedding Jupyter kernel output in Microsoft Word

1 Like

Limitation with our approach compared to what you’re looking to do is that it just supports a standalone versions of Word - not Word Online, or Google Docs. We’ve had a lot of people ask us about extending it online, so if that’s something you pursue let me know how I can help. Your motivation for doing this is similar to ours too - there is definitely a need out there.

2 Likes

I can see this need too, amongst colleagues. There is a number of analysts that are doing data analysis still from spreadsheets. But they want to be able to collaborate on work done with jupyter by adding comments to analysis… In theory, people could use git for commentary. But even that pushes adoption of both jupyter and git. This pushes away many of those analysts…

1 Like