简体   繁体   English

如何为Google Apps脚本编写适当的文档?

[英]How to write proper documentation for Google Apps Scripts?

I am a marketer who is learning to code. 我是一名正在学习编码的营销人员。 Currently my main weapon of choice is Google Apps Scripts. 目前我选择的主要武器是Google Apps Scripts。 As I am diving deeper and also writing code for other people, I want to make sure that my code is well documented. 当我深入探索并为其他人编写代码时,我想确保我的代码有详细记录。 Before GAS, I started with Python, where PEP-8 has a clear guideline for this. 在GAS之前,我开始使用Python,其中PEP-8有一个明确的指导方针。 Are there any similar guidelines for GAS? GAS是否有类似的指导方针?

How I document functions currently (aside from having clear variable names and some inline-comments: 我如何记录当前的函数(除了有明确的变量名和一些内联注释:

At the top of each script: 在每个脚本的顶部:

/**
 * @name The name of the script
 *
 * @fileoverview The overview and expected outcome 
 *
 * @author my name and e-mail address
 *
 * @version 1.0
 *
 * @changelog
 * - version 1.0
 *   - Released initial version.
 */

Below each function definition: 在每个函数定义下面:

function buildResultsObject(contactList) {
  /**
   * Parses the contactList to create
   * an object per countryCategory ID
   *
   * The data array in the object is initialised
   * to be empty and will be filled when the 
   * data is parsed with another function.
   *
   * @param {contactList} the values from the contact list sheet as a 2-level array
   * @returns {Object} results
   *
   * Example structure of results:
   * 
   *  {'AUBAK':
   *    {
   *    'country; 'AU'
   *    'category': 'BAK'
   *    'email': 'a@b.com',
   *    'data': []
   *    }
   *  }
   *
   */

  code here
}

My questions: 我的问题:

  • Is this how I should do it or is there a better way? 这是我应该怎么做或有更好的方法吗?
  • What do the @ tags do in the comments exactly? @标签在评论中做了什么? For example I noticed that with the @name parameter, I am actually changing the name of the script that can be ran in the 'Select function' dropdown below the menu bar. 例如,我注意到使用@name参数,我实际上正在更改可以在菜单栏下方的“选择功能”下拉列表中运行的脚本的名称。

This following link should suffice: 以下链接应该足够:

https://google.github.io/styleguide/jsguide.html https://google.github.io/styleguide/jsguide.html

Chapter 7 in the guide linked above covers all you need to know. 上面链接的指南中的第7章涵盖了您需要了解的所有内容。

But you should also checkout the apps script reference documentation (and add-ons documentation) as there are some GAS specific @tags related to oauth scopes and add-ons that are only documented there. 但是您还应该检查应用程序脚本参考文档(和附加组件文档),因为有一些与oauth作用域相关的特定于@tags和仅在那里记录的附加组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM