slash_for_doc_comments 린트 규칙: 문서 주석은 ///로 쓰기

slash_for_doc_comments 린트 규칙: 문서 주석은 ///로 쓰기

Dart는 문서 주석(doc comment)을 두 가지 문법(////**)으로 지원하는데요, 이 린트 규칙은 문서 주석에 ///를 쓰도록 권장하는 규칙이에요.

출처: slash_for_doc_comments

본문

설명

Effective Dart에서도 알려주고 있는 내용인데요, 문서 주석에는 ///를 사용해요.

Dart가 문서 주석을 두 가지 문법(////**)으로 지원하기는 하지만, 저희는 문서 주석에 ///를 쓰는 걸 더 선호해요.

GOOD:

/// Parses a set of option strings. For each option:
///
/// * If it is `null`, then it is ignored.
/// * If it is a string, then [validate] is called on it.
/// * If it is any other type, it is *not* validated.
void parse(List options) {
  // ...
}

문서 주석 안에서는 마크다운을 사용해서 서식을 꾸밀 수도 있어요.

활성화 방법

slash_for_doc_comments 규칙을 활성화하려면 analysis_options.yaml 파일의 linter > rules 아래에 규칙을 추가하면 돼요.

linter:
  rules:
    - slash_for_doc_comments

대신 YAML 맵 문법으로 린트 규칙을 설정하고 있다면, linter > rules 아래에 slash_for_doc_comments: true를 추가하면 돼요.

linter:
  rules:
    slash_for_doc_comments: true

더 알아보기