Google-apps-script – Is it possible to reverse engineer a Google Doc into Google Apps Script File

google docsgoogle-apps-script

I'm trying to figure out if it is it possible to reverse engineer a Google Doc into Google Apps Script File? I'd like to be able to evaluate a Google Doc (GD#1) by its URL and convert that doc into a Google Apps Script file (AS-GD#1) that contains all the Apps Script and document content needed to create an exact replica of GD#1. I do not want the script to "copy" GD#1. I want the script to create a new Apps Script File that contains all the methods, content, etc… of GD#1.

Does that make sense?

If possible, I'm looking for push in the right direction.

Best Answer

I think that this could be possible, perhaps with some limitations by using the Google Apps Script API as it's used for local development.

It's worth to note that there is a open-source command line tool that use this API called Clasp.