Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- maven
- angularjs
- Spring
- Python
- 일본
- javadoc
- jquery
- xml
- JavaFX
- webflux
- WebClient
- mybatis
- 개발자 이야기
- 외국인 노동자
- swift
- SQL
- php
- build tool
- SQLite
- bootstrap
- RSocket
- Eclipse
- Ajax
- Linux
- gradle
- node.js
- Apache
- Java
- spring boot
- pdo
- Today
- 122
- Total
- 3,456,555
슬기로운 개발자 생활
[Javadoc] Javadoc 문서 작성 본문
반응형
실제로 문서를 만들어 보도록 하자. 아래는 간단한 Java 샘플 코드이다.
public class Sample01 {
private int w;
private int h;
public Sample01() {
w = 0;
h = 0;
}
public void setSize(int width, int height) {
w = width;
h = height;
}
public int getWidth() {
return w;
}
public int getHeight() {
return h;
}
}
이 샘플 코드에 대해서 Javadoc 주석를 작성한 예는 다음과 같다.
/**
* Javadoc 테스트용 클래스
*
* @author devkuma
* @version 1.0
*/
public class Sample01 {
/**
* 폭
*/
private int w;
/**
* 높이
*/
private int h;
/**
* 디폴트 생성자 클래스
*/
public Sample01() {
w = 0;
h = 0;
}
/**
* 사이즈 설정
*
* @param width 폭
* @param height 높이
*/
public void setSize(int width, int height) {
w = width;
h = height;
}
/**
* 폭 반환
*
* @return 폭
*/
public int getWidth() {
return w;
}
/**
* 높이 반환
*
* @return 높이
*/
public int getHeight() {
return h;
}
}
주석에 대한 자세한 설명은 다른 페이지에서 자세히 살펴 보겠다.
그럼 위의 소스 코드를 "Sample01.java"라는 이름으로 저장하고 저장된 디렉토리에서 다음과 같이 실행을 하도록 한다.
$ javadoc -private -d doc Sample01.java
$ javadoc -private -d doc Sample01.java
Loading source file Sample01.java...
Constructing Javadoc information...
Creating destination directory: "doc/"
Standard Doclet version 1.8.0_161
Building tree for all the packages and classes...
Generating doc/Sample01.html...
Generating doc/package-frame.html...
Generating doc/package-summary.html...
Generating doc/package-tree.html...
Generating doc/constant-values.html...
Building index for all the packages and classes...
Generating doc/overview-tree.html...
Generating doc/index-all.html...
Generating doc/deprecated-list.html...
Building index for all classes...
Generating doc/allclasses-frame.html...
Generating doc/allclasses-noframe.html...
Generating doc/index.html...
Generating doc/help-doc.html...
실행한 디렉토리에 "doc"이란 디렉토리가 만들어지고 다음과 같이 파일들이 생성되어 있다는 것을 확인할 수 있다.
$ ls -al
total 176
drwxr-xr-x 17 kimkc staff 578 10 8 23:49 .
drwxr-xr-x 4 kimkc staff 136 10 8 23:49 ..
-rw-r--r-- 1 kimkc staff 10937 10 8 23:49 Sample01.html
-rw-r--r-- 1 kimkc staff 633 10 8 23:49 allclasses-frame.html
-rw-r--r-- 1 kimkc staff 613 10 8 23:49 allclasses-noframe.html
-rw-r--r-- 1 kimkc staff 3507 10 8 23:49 constant-values.html
-rw-r--r-- 1 kimkc staff 3457 10 8 23:49 deprecated-list.html
-rw-r--r-- 1 kimkc staff 7892 10 8 23:49 help-doc.html
-rw-r--r-- 1 kimkc staff 5448 10 8 23:49 index-all.html
-rw-r--r-- 1 kimkc staff 2744 10 8 23:49 index.html
-rw-r--r-- 1 kimkc staff 3684 10 8 23:49 overview-tree.html
-rw-r--r-- 1 kimkc staff 740 10 8 23:49 package-frame.html
-rw-r--r-- 1 kimkc staff 1 10 8 23:49 package-list
-rw-r--r-- 1 kimkc staff 3906 10 8 23:49 package-summary.html
-rw-r--r-- 1 kimkc staff 3693 10 8 23:49 package-tree.html
-rw-r--r-- 1 kimkc staff 827 10 8 23:49 script.js
-rw-r--r-- 1 kimkc staff 12842 10 8 23:49 stylesheet.css
많은 HTML 파일과 css, js이 생성되어 있다. 이 중에 "index.html" 파일을 브라우저에서 열어보도록 하자.
이와 같이 소스 코드에 쓰여진 의견을 바탕으로 문서가 작성되었다. Javadoc에 대응 한 형태로 주석을 추가하는 것만으로 즉시 클래스 나 메소드 스펙을 만들 수 있으므로 매우 편리하다.
반응형
'IT 개발 > Javadoc' 카테고리의 다른 글
[Javadoc] 주석 필드에 대한 주석 작성 시에 주의점 (0) | 2019.10.20 |
---|---|
[Javadoc] 주석 HTML문 작성 (0) | 2019.10.20 |
[Javadoc] 주석의 구성 (0) | 2019.10.20 |
[Javadoc] Javadoc 대상이 되는 주석 작성 방법 (0) | 2019.10.20 |
[Javadoc] Javadoc으로 생성된 문서 (0) | 2019.10.20 |
0 Comments