何が好ましい方法のコメントをjavascriptオブジェクト-方法[定休日]

StackOverflow https://stackoverflow.com/questions/127095

  •  02-07-2019
  •  | 
  •  

質問

こatlasが好ましい(かん)の方法は使用xmlなどのコメント:

/// <summary>
///   Method to calculate distance between two points
/// </summary>
///
/// <param name="pointA">First point</param>
/// <param name="pointB">Second point</param>
/// 
function calculatePointDistance(pointA, pointB) { ... }

って得られその他の第3者javascriptライブラリと見ような書式:

/*
 * some comment here
 * another comment here
 * ...
 */
 function blahblah() { ... }

ボーナスパーツとして、ぜひ<url>までご連絡くださいがある場合はAPIリストの発電機のためにJavaScriptを読みこなすのが好'コメントです。

役に立ちましたか?

解決

JSDoc

/**
 * Shape is an abstract base class. It is defined simply
 * to have something to inherit from for geometric 
 * subclasses
 * @constructor
 */
function Shape(color){
 this.color = color;
}

他のヒント

をより簡単に、より良いコメントが良く、使う:)

var something = 10; // My comment

/*
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.
*/

function bigThing() {
    // ...
}

がautogenerated doc...

/**
 * Adds two numbers.
 * @param {number} num1 The first number to add.
 * @param {number} num2 The second number to add.
 * @return {number} The result of adding num1 and num2.
 */
function bigThing() {
    // ...
}

ヤフーの提供 YUIDoc.

でも文書化され、ヤフーは、Node.js アプリです。

でも使用してく同じ構文でない多くの変化した場合のになっていくことになるでしょういます。

み貼り付け、次にjavascriptファイルをVisual Studio08や遊んでもないものとします。

var Namespace = {};
    Namespace.AnotherNamespace = {};

Namespace.AnotherNamespace.annoyingAlert = function(_message)
{
    /// <param name="_message">The message you want alerted two times</param>
    /// <summary>This is really annoying!!</summary>

    alert(_message);
    alert(_message);
};

を行頭に付けた三昧!

詳細情報(どの参考外部javascriptファイル用の大型図書館) スコットグさんのブログ.

の利用にはトリプルコメントの最初の例に対して実際に使用する外部のXMLドキュメンテーションツール(Visual Studio)を行頭に付けます。そのものを有効なコメントがその特別:)のactuallコメント'オペレーター'する// 唯一の制限があり、その単線です。

次の例は使用Cスタイルブロックコメントを可能にするコメントを複数のラインの途中です。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top