docs構成

This commit is contained in:
ry.yamafuji 2025-12-11 00:48:32 +09:00
parent ab1e6707e2
commit ffc968a476
6 changed files with 3041 additions and 0 deletions

3
.gitignore vendored
View File

@ -1,4 +1,7 @@
dist/
docs/html/
docs/latex/
# ---> C++
# Prerequisites
*.d

11
Dockerfile.doxygen Normal file
View File

@ -0,0 +1,11 @@
# mus
FROM alpine:3.20
# 必要なツールをインストール
RUN apk add --no-cache \
doxygen \
graphviz
WORKDIR /work
CMD ["doxygen", "Doxyfile"]

2868
docs/Doxyfile Normal file

File diff suppressed because it is too large Load Diff

View File

154
readme/develop.md Normal file
View File

@ -0,0 +1,154 @@
# C/C++の開発環境
- [C/C++の開発環境](#ccの開発環境)
- [Linter](#linter)
- [テスト](#テスト)
- [Doc(ドキュメンテーション)](#docドキュメンテーション)
- [環境構築](#環境構築)
- [Dockerを活用する](#dockerを活用する)
- [doxygen 使い方](#doxygen-使い方)
- [CI / CDによる実行](#ci--cdによる実行)
- [Doxyfileの設定](#doxyfileの設定)
- [Docコメントの書き方](#docコメントの書き方)
## Linter
TODO: TBD
## テスト
TODO: TBD
## Doc(ドキュメンテーション)
C / C++ の自動ドキュメンテーションをしたい場合、
Doxygen(Graphviz)が圧倒的スタンダードで、最もおすすめです。
* C / C++ / Java / Python などメジャー言語に対応
* コメントを解析して HTML / PDF / Markdown などへ出力
* 関数・構造体・クラスの関係図UML・依存グラフを自動生成
* C++ テンプレートや名前空間にも対応
* Graphvizを入れれば図が自動で描かれる
### 環境構築
**Macの場合**
```sh
brew install doxygen graphviz
```
**Linux(Ubuntu)の場合**
```sh
sudo apt install doxygen graphviz
```
#### Dockerを活用する
[Dockerfileはこちら](../Dockerfile.doxygen)
Dockerイメージをビルドする
```sh
docker build -f Dockerfile.doxygen -t dev-doxygen .
```
Linuxでコマンドを実行する
```sh
mkdir -p docs
# docker run --rm -v "$(pwd)":/work -w /work/docs dev-doxygen <コマンド>
# 初期化コマンド
docker run --rm -v "$(pwd)":/work -w /work/docs dev-doxygen doxygen -g
# ドキュメントを生成する
docker run --rm -v "$(pwd)":/work -w /work/docs dev-doxygen doxygen Doxyfile
```
### doxygen 使い方
**設定ファイルを生成**
```sh
doxygen -g
```
Doxyfileが作成される
**ドキュメント生成**
```sh
doxygen Doxyfile
```
* html/ に HTML ドキュメント
* latex/ に PDF 用のファイルが出力される(必要なら make)
### CI / CDによる実行
**Git Actionsで生成の場合**
```yaml
- name: Generate Doxygen docs
run: doxygen docs/Doxyfile
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/html
```
### Doxyfileの設定
`docs/Doxyfile`を設定する
```sh
# ドキュメント化したいディレクトリ
INPUT = ../src ../include
# INPUT 内を再帰的に探索
RECURSIVE = YES
# OUTPUT は docs/html に出す
OUTPUT_DIRECTORY = ./html
```
### Docコメントの書き方
C言語の場合
```c
/**
* @brief 二数の最大値を返す関数
* @param a 整数
* @param b 整数
* @return 最大値
*/
int max(int a, int b);
```
C++言語の場合
```c
/**
* @class User
* @brief ユーザー情報を扱うクラス
*/
class User {
public:
/**
* @brief コンストラクタ
*/
User(std::string name, int age);
/**
* @brief 名前を取得する
*/
std::string getName() const;
```

View File

@ -4,7 +4,12 @@
*/
#include <stdio.h>
/**
* @brief Main function
* @return int Exit status
*/
int main(void) {
printf("Hello, world!\n");
return 0;
}