JavaScript 객체 및 메소드를 주석하는 선호하는 방법은 무엇입니까 [폐쇄

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

  •  02-07-2019
  •  | 
  •  

문제

나는 선호하는 (내가 아는 것)에서 다음과 같은 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() { ... }

보너스로 '선호하는'주석 스타일을 읽을 수있는 JavaScript 용 API 생성기가 있는지 알려주십시오.

도움이 되었습니까?

해결책

거기 있습니다 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() {
    // ...
}

그러나자가 생성 문서의 경우 ...

/**
 * 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() {
    // ...
}

야후 제안 유니 돔.

Yahoo가 잘 문서화되어 있으며 Node.js 앱입니다.

또한 동일한 구문을 많이 사용하므로 많은 변경 사항이 하나에서 다른 구문으로 이동할 필요가 없습니다.

Visual Studio 08의 JavaScript 파일에 다음을 붙여 넣고 그와 함께 놀아보십시오.

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-Files 참조 방법 포함)를 찾을 수 있습니다. Scott Gu의 블로그.

첫 번째 예제에서 트리플 댓글을 사용하는 것은 실제로 외부 XML 문서화 도구 및 (Visual Studio) Intelleisense 지원에 사용됩니다. 여전히 유효한 의견이지만 특별한 댓글 : : Actuall 주석 '연산자'는 // 한 줄에 대한 유일한 제한입니다.

두 번째 예제는 C 스타일 블록 주석을 사용하여 여러 줄에 걸쳐 또는 라인 중간에 댓글을 달 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top