3 ms·
I use Google Docs code a lot at work in "production". Here's my experiences: Yes, you can do more than a few hundred lines of code. My in house library is no
by iamchrisle 14y ago
I use Google Docs code a lot at work in "production". Here's my experiences:
Yes, you can do more than a few hundred lines of code. My in house library is now about 5k LOC. Yes, it's basically straight JavaScript. Everything is there except for the DOM. Yes, the online editor sucks. I don't use it at all. (see below how) No, you cannot use jQuery/Prototype, etc (there's no DOM or Window class). No, you cannot use long running methods. Google Docs cuts you off at around 30 seconds of execution. No, you cannot share code. (see below)
-- How I develop on Google Docs:
1. I develop it outside of Google Docs using Sublime Text 2
2. I test using Node.JS + assert() + methane.js (see below)
3. I then minify it using Google Closure Tool
4. Then I copy and paste it into Google Docs
This works well because the online editor blows when you're doing anything semi-complex.
--- Testing in Google Docs
I use node.js + assert() + methane.js. What is methane.js? It's a little piece of JS that mocks some of the Google Apps classes and functions. I can then override that mocked method to return the value I expect Google to return and test my own methods.
It's here: https://github.com/chrisle/methane https://github.com/chrisle/methane
Consider it alpha code. It's not very well documented. It works for me!(tm)....
-- Sharing code in Google Docs:
Inside of onLoad() I've seen people use UrlFetch and then eval() the response string as a way of getting shared code to work. Not ideal, but it works. I personally don't share code or use this method.