This software is an add-in for Google Docs to insert statistics from a file created with the tidystats R package. For more information about tidystats, please visit the tidystats website.
This Google Docs add-in is written in Google Apps Script (Google's Javascript-based development platform for building applications and add-ons for Google Sheets, Docs, Forms and other Google Apps), built on the boilerplate project available via https://github.com/enuchi/React-Google-Apps-Script (which can be consulted for details about the code structure).
Later on, the add-in is to be published and available among the official Google add-ins for easy installation. For now, it can only be installed "manually", as follows.
1. Make sure you are running at least Node.js v10 and npm
v6.
2. You need to enable the Google Apps Script API. You can do that via script.google.com/home/usersettings.
3. Clone the repo and install the dependencies.
git clone https://github.com/gasparl/tidystats-Google-Docs-add-in.git
cd React-Google-Apps-Script
npm install
4. Next, you need to log in to clasp that allows managing Google Apps Script projects locally.
npm run login
5. Update the .clasp.json
file in the root of this project with the following three key/value pairs:
{
"scriptId": "1PY037hPcy................................................",
"parentId": ["1Df30......................................."],
"rootDir": "./dist"
}
-
scriptId
: Your existing script project'sscriptId
. You can find it by opening your document, selecting Tools -> Script editor from the menubar, then File -> Project properties, and it will be listed as "Script ID". -
parentId
: An array with a single string, the ID of the parent file (Google Document) that the script project is bound to. You can get this ID from the url, where the format is usuallyhttps://docs.google.com/document/d/{id}/edit
. This allows you to runnpm run open
and open your file directly from the command line. -
rootDir
: This should always remain"./dist"
, the local build folder that is used to store project files.
Now you can run the deploy command to compile and upload the scripts to the specified Google Document. (You may be prompted for confirmation to update your manifest file; select "yes".)
npm run deploy
The deploy command will build all necessary files using production settings, including all server code (Google Apps Script code), client code (React bundle), and config files. All bundled files will be saved to the dist/
folder, and then pushed to the Google Apps Script project.
Now you can open or refresh the Google Document and you should see the new menu "tidystats". (You can also run npm run open
to open the document.) You can also see the uploaded Google Apps Scripts via Tools -> Script editor.
Found a bug or got an idea about how to improve the add-in? Please create a Github issue. If you need some help figuring out how this works, see this support page by Github or simply contact Willem Sleegers on Twitter or via e-mail.