Gallery
Pack Building Roadmap - Maker Stories Webinar
Share
Explore
Getting Started with Packs

icon picker
Improve your Pack

Pack building documentation from Coda
Let’s improve the HELLO WORLD pack. We’re going to create a new formula that says “hello” as many times as the user wants it to.
Specifically, we’d like to create a formula MultiHello that takes a number input, returning the world “Hello” that many times, e.g. MultiHello(3) → “Hello Hello Hello!”

1. Add a formula

Let’s go back to our code window. Type in /formula while in the coding window, and you’ll receive the basic skeleton to define a new formula
Loading…
Loading…
Next, let’s fill in this skeleton by giving it a name, description, and changing the parameter and function. Read along with the comments in the code skeleton to see what each line does. Note, you’ll have to change the type for the parameter to be a number.
Remember: this is all just Javascript code, so you can Google to find built-in features like .

The code by this point looks like the following:
Loading…

2. Compile-time debugging

Click “Create Build” again, just as you did to create the first version of your Pack.
If you have issues that prevent Coda from compiling the Pack — e.g. basic syntax errors, you forgot to specify a required field — you’ll get an error in the Debug panel, as shown below; in this example, we forgot to include a close on Line 59.
Loading…
Once you succeed, you’ll get a confirmation message that the build succeeded
Loading…

3. In-doc (run-time) debugging

You can see in-doc, i.e. run-time, errors in the doc itself as well. You can directly print to it from your code too using console.log() just as you normally would.
Go back to the doc you’d created to test the Hello World Pack. Go to the settings panel of the Pack and select "Latest Version.” You’ll notice that it’s been auto-updated to the latest version now and whenever you submit any new versions.
Loading…
You can now test the new formula and see it in action!
Loading…
You can access the debug log from this same panel. This panel includes logs of when features were invoked in the doc and even user-triggered messages and errors via console.log.
Loading…


Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.