C++ 문서 작성 스타일
문서를 생성하기 위해 QDoc은 소스 코드를 분석하여 클래스와 같은 C++ 유형에 대한 문서를 생성합니다. 그런 다음 QDoc은 멤버 함수, 속성 및 기타 유형을 적절한 클래스와 연결합니다.
문서는 반드시 .cpp 와 같은 구현 파일에 포함되어야 합니다.
클래스 문서
클래스 문서는 \class 명령과 첫 번째 인수로 지정된 클래스 이름을 사용하여 생성됩니다.
/*!
\class QCache
\brief The QCache class is a template class that provides a cache.
\ingroup tools
\ingroup shared
\reentrant
QCache\<Key, T\> defines a cache that stores objects of type T
associated with keys of type Key. For example, here's the
definition of a cache that stores objects of type Employee
associated with an integer key:
\snippet code/doc_src_qcache.cpp 0
Here's how to insert an object in the cache:
\snippet code/doc_src_qcache.cpp 1
... detailed description omitted
\sa QPixmapCache, QHash, QMap
*/컨텍스트 명령어는 모듈이나 클래스가 추가된 버전 등 클래스에 대한 정보를 추가합니다.
일반적인 컨텍스트 명령어는 다음과 같습니다.
- \brief - 클래스에 대한 간략한 설명 (필수)
- \since - 클래스가 추가된 버전 (필수)
- \internal - 클래스를 내부 클래스로 표시합니다. 내부 클래스는 공개 API 문서에 나타나지 않습니다.
간략한 설명과 상세 설명
간략한 설명 은 \brief 명령어로 표시되며, 클래스의 목적이나 기능을 요약하는 데 사용됩니다. C++ 클래스의 경우, QDoc은 해당 클래스를 분석하여 주석이 달린 정보를 생성합니다. 이 주석이 달린 정보는 클래스를 보여주는 목록과 표에 표시됩니다.
C++ 간략 설명은 다음과 같이 시작해야 합니다:
"The <C++ class name> class"상세 설명 섹션은 간략한 설명 다음에 시작됩니다. 이 섹션은 클래스에 대한 더 자세한 정보를 제공합니다. 상세 설명에는 이미지, 코드 스니펫 또는 다른 관련 문서에 대한 링크가 포함될 수 있습니다. 간략한 설명과 상세 설명 사이에는 반드시 빈 줄 하나가 있어야 합니다.
멤버 함수
일반적으로 함수 문서는 ` .cpp ` 파일에서 해당 함수의 구현 코드 바로 앞에 위치합니다. 구현 코드 바로 위에 위치하지 않는 함수 문서의 경우, \fn 가 필요합니다.
/*!
\fn QString &QString::remove(int position, int n)
Removes \a n characters from the string, starting at the given \a
position index, and returns a reference to the string.
If the specified \a position index is within the string, but \a
position + \a n is beyond the end of the string, the string is
truncated at the specified \a position.
\snippet qstring/main.cpp 37
\sa insert(), replace()
*/
QString &QString::remove(int pos, int len)함수 문서는 함수가 수행하는 작업을 나타내는 동사로 시작합니다. 이는 생성자 및 소멸자에도 적용됩니다.
함수 설명에 흔히 사용되는 동사:
- "생성합니다..." - 생성자용
- "~를 소멸시킵니다..." - 소멸자용
- "~를 반환한다..." - 액세서 함수의 경우
함수 설명에는 다음 내용을 반드시 명시해야 합니다:
- 반환 유형
- 매개변수
- 함수의 동작
\a 명령어는 문서 내의 매개변수를 표시합니다. 반환 유형 문서는 해당 유형 문서로 링크되어야 하거나, 부울 값의 경우 \c 명령어로 표시되어야 합니다.
/*!
Returns \c true if a QScroller object was already created for \a target; \c false otherwise.
\sa scroller()
*/
bool QScroller::hasScroller(QObject *target)속성
속성 설명은 read 함수의 구현 코드 바로 위에 위치합니다. 속성에 대한 topic 명령어는 \property입니다.
/*!
\property QVariantAnimation::duration
\brief the duration of the animation
This property describes the duration in milliseconds of the
animation. The default duration is 250 milliseconds.
\sa QAbstractAnimation::duration()
*/
int QVariantAnimation::duration() const속성 문서는 보통 "이 속성은..."으로 시작하지만, 다음과 같은 대체 표현도 있습니다:
- "이 속성은..."
- "이 속성은 ...을 설명합니다"
- "이 속성은 다음을 나타냅니다..."
- "다음과 같은 경우
true를 반환하고, 다음과 같은 경우false를 반환합니다." - 읽기 전용 속성의 경우. - "…를 설정합니다." — 타입을 구성하는 속성의 경우.
속성 문서에는 다음이 포함되어야 합니다:
- 속성의 설명 및 동작
- 속성에 허용되는 값
- 속성의 기본값
함수와 마찬가지로, 기본 유형은 ` \c ` 명령어로 연결되거나 표시될 수 있습니다.
값 범위 지정 방식의 예는 다음과 같습니다:
값의 범위는 0.0(블러 없음)부터 maximumRadius(최대 블러)까지입니다. 기본적으로 이 속성은 0.0(블러 없음)으로 설정됩니다.
신호, 알림자 및 슬롯
신호, 알림자 및 슬롯에 대한 topic 명령어는 다음과 같습니다. \fn입니다. 신호 문서에는 신호가 언제 트리거되거나 발신되는지가 명시됩니다.
/*!
\fn QAbstractTransition::triggered()
This signal is emitted when the transition has been triggered (after
onTransition() has been called).
*/신호 문서는 일반적으로 “이 신호는 다음 경우에 트리거됩니다...”로 시작합니다. 다음은 다른 표현 방식의 예입니다:
- "이 신호는 다음 경우에 트리거됩니다..."
- "~할 때 트리거됩니다"
- "다음 경우에 방출됩니다..."
슬롯이나 알림기의 경우, 신호에 의해 실행되거나 트리거되는 조건이 문서화되어야 합니다.
- "다음과 같은 경우 실행됩니다..."
- "이 슬롯은 다음 경우에 실행됩니다..."
신호가 오버로드된 속성의 경우, QDoc은 오버로드된 노티파이어들을 한데 묶어 표시합니다. 노티파이어나 신호의 특정 버전을 참조하려면, 해당 속성을 언급하고 노티파이어에 여러 버전이 있음을 명시하면 됩니다.
/*!
\property QSpinBox::value
\brief the value of the spin box
setValue() will emit valueChanged() if the new value is different
from the old one. The \l{QSpinBox::}{value} property has a second notifier
signal which includes the spin box's prefix and suffix.
*/열거형, 네임스페이스 및 기타 유형
열거형, 네임스페이스 및 매크로에는 해당 문서를 위한 주제 명령어가 있습니다:
이러한 유형에 대한 문서 작성 스타일은 해당 항목이 열거형이나 매크로임을 명시한 후 유형 설명을 이어갑니다.
열거형의 경우, \value 명령어는 값을 나열하는 데 사용됩니다. QDoc은 열거형에 대한 값 표를 생성합니다.
/*!
\enum QSql::TableType
This enum type describes types of SQL tables.
\value Tables All the tables visible to the user.
\value SystemTables Internal tables used by the database.
\value Views All the views visible to the user.
\value AllTables All of the above.
*/© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.