Introducing interactive code samples in Google Cloud documentation
The Google Cloud documentation set has a new feature that makes it easier for you to run code samples that include placeholder variables. With this new feature, you can replace the variables inline, before you even copy the snippet. When you paste the text into your editor or into the command line, the values are already set!
Placeholder variables represent custom parameter values—values in a code snippet that depend on your scenario or environment. The parameters might specify your credentials or the name of a resource.
With this new feature, you can replace the variables before copying the code sample. Edit variables in your browser, copy the command, and run it right away.
You’ll often find placeholder variables in sample REST API calls and Cloud SDK commands, including the
kubectl samples. How can you tell if a variable is editable? Look for the pencil icon and the dotted underline.
Edit one sample, run them all
If a page has multiple code samples with the same placeholder variable, you only need to replace the variable once. For example, when you replace a PROJECT_ID variable with your own Google Cloud project ID, all instances of the PROJECT_ID variable (including in any other command line samples on the page) will use the same Google Cloud project ID.
Preview successful API calls
Documentation often shows the results of an API call. For example, when we show REST API calls, we usually show sample responses from a server. The placeholder variables in the responses stay in sync with the variables in the examples.
You can make sure your REST API calls are successful by comparing the response you get with the sample. Replace the variables in the example, make the API call, and check the response at a glance.
Try it out
You can find the interactive code samples throughout Google Cloud documentation. To try out the new feature, you can create a Cloud Storage bucket using the gsutil command-line tool or REST API.
Related Google News:
- Google Workspace Updates Weekly Recap - February 19, 2021 February 19, 2021
- Architect your data lake on Google Cloud with Data Fusion and Composer February 19, 2021
- Introducing Model Search: An Open Source Platform for Finding Optimal ML Models February 19, 2021
- Black History Month: Celebrating the success of Black founders with Google Cloud: Get Optimal Tech February 19, 2021
- Marian Croak’s vision for responsible AI at Google February 18, 2021
- Apple TV+ is now available on Google TV February 18, 2021
- New framework expands Google Cloud access globally February 18, 2021
- Signify chooses Google Cloud IoT Core to power Philips Hue smart lighting February 18, 2021