Giter Site home page Giter Site logo

Comments (8)

leopragi avatar leopragi commented on July 29, 2024 1

Cool @enuchi, I ll close the issue once i try the comments: /@customfunction/

from react-google-apps-script.

enuchi avatar enuchi commented on July 29, 2024

Can you add a description @leopragiclevero ? Not sure what you're referring to.

from react-google-apps-script.

pragi-balasubramanian-alation avatar pragi-balasubramanian-alation commented on July 29, 2024

Can you add a description @leopragiclevero ? Not sure what you're referring to.

Added! and also found a solution.

from react-google-apps-script.

leopragi avatar leopragi commented on July 29, 2024

You can do it with CopyWebpackPlugin. My setup is that I have a functions folder on under root where I have multiple JS files. Each JS file can have its own custom function. In Webpack I simply copy the functions/.js to dist/.js (converted to GS file on uploading).

Now this will copy the custom function files without any modification to the google apps script with @customfunction tag.

NOTE: Since all server-side functions all under global scope you can use any util/common function directly on your custom function code.

from react-google-apps-script.

enuchi avatar enuchi commented on July 29, 2024

Yep, looks like this is almost possible with the current setup, just needs a small change to the webpack server config.

Add comments: 'function' to the terserOptions.output configuration:

output: {
   beautify: true,
   comments: 'function',
},

This is the section here:

optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
sourceMap: true,
terserOptions: {
// ecma 5 is needed to support Rhino "DEPRECATED_ES5" runtime
// can use ecma 6 if V8 runtime is used
ecma: 5,
warnings: false,
parse: {},
compress: {
properties: false,
},
mangle: false,
module: false,
output: {
beautify: true,
},
},
}),
],
},

Then add your jsdoc documentation to the function and assign to the global object, as you were doing:

/**
 * Multiplies the input value by 2.
 *
 * @param {number} input The value to multiply.
 * @return The input multiplied by 2.
 * @customfunction
 */
global.DOUBLE = input => input * 2;

After you run npm run deploy you should see autocompletion for your custom function.

custom function

from react-google-apps-script.

enuchi avatar enuchi commented on July 29, 2024

Actually, even better:

output: {
   comments: /@customfunction/,
},

from react-google-apps-script.

leopragi avatar leopragi commented on July 29, 2024

Actually, even better:

output: {
   comments: /@customfunction/,
},

Did you check this by pushing the codes to GAS? Yesterday I did try this but didn't work for me. That's why I fall back on the above method I mentioned.

from react-google-apps-script.

enuchi avatar enuchi commented on July 29, 2024

Yes, the image I shared was from after I pushed the changes. I'll update the repo with these changes soon.

from react-google-apps-script.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.