Skip to content

Commit 88890b8

Browse files
authored
Merge pull request #145 from deflis/llms-txt
llms.txtの追加とREADMEの更新
2 parents cb6fb47 + 00adb0a commit 88890b8

4 files changed

Lines changed: 478 additions & 38 deletions

File tree

CLAUDE.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# CLAUDE.md
2+
3+
返答が必要な場合は、日本語で回答してください。
4+
5+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
6+
7+
## Common Development Commands
8+
9+
### Building and Development
10+
- `pnpm run build` - Build the TypeScript project using tsup
11+
- `pnpm run build:tsc` - Run TypeScript compiler directly
12+
- `pnpm run check` - Run all checks (lint, build, test)
13+
- `pnpm run check:lint` - Run ESLint on source and test files
14+
- `pnpm run check:build` - Type check without emitting files
15+
- `pnpm run format` - Auto-fix linting issues with ESLint
16+
17+
### Testing
18+
- `pnpm run test` - Run tests with Vitest
19+
- `pnpm vitest run` - Run tests directly with Vitest
20+
21+
### Documentation
22+
- `pnpm run docs` - Generate TypeDoc documentation
23+
- `pnpm run docs:clean` - Clean documentation directory
24+
- `pnpm run docs:typedoc` - Generate documentation with TypeDoc
25+
26+
### Package Management
27+
- `pnpm install` - Install dependencies (pnpm >= 8 required)
28+
- `pnpm dlx <command>` - Execute packages directly (used in docs generation)
29+
30+
## Code Architecture
31+
32+
This is a TypeScript library that provides a fluent interface wrapper for the Narou (小説家になろう) developer APIs. The library supports both Node.js (using fetch) and browser environments (using JSONP).
33+
34+
### Core Architecture Components
35+
36+
**Dual Environment Support:**
37+
- `src/index.ts` - Node.js entry point using `NarouNovelFetch` (fetch-based)
38+
- `src/index.browser.ts` - Browser entry point using `NarouNovelJsonp` (JSONP-based)
39+
- Both share common builder patterns and types through `src/index.common.ts`
40+
41+
**Builder Pattern Implementation:**
42+
- `SearchBuilderBase` - Abstract base class for all search builders
43+
- `NovelSearchBuilderBase` - Base class for novel-specific search functionality
44+
- `SearchBuilder` - Main novel search builder
45+
- `SearchBuilderR18` - R18 novel search builder
46+
- `RankingBuilder` - Ranking API builder
47+
- `UserSearchBuilder` - User search builder
48+
49+
**API Abstraction:**
50+
- `NarouNovel` (abstract) - Base class defining API contract
51+
- `NarouNovelFetch` - Node.js implementation using fetch
52+
- `NarouNovelJsonp` - Browser implementation using JSONP
53+
54+
**API Endpoints Supported:**
55+
- Novel Search API (`https://api.syosetu.com/novelapi/api/`)
56+
- R18 Novel API (`https://api.syosetu.com/novel18api/api/`)
57+
- Ranking API (`https://api.syosetu.com/rank/rankget/`)
58+
- Ranking History API (`https://api.syosetu.com/rank/rankin/`)
59+
- User Search API (`https://api.syosetu.com/userapi/api/`)
60+
61+
### Key Design Patterns
62+
63+
**Fluent Interface:** All builders use method chaining for parameter building (e.g., `search("word").genre(Genre.Fantasy).order(Order.New).execute()`)
64+
65+
**Type Safety:** Extensive use of TypeScript generics to ensure type-safe field selection and results
66+
67+
**Dual Export Strategy:** The package exports different entry points for different environments via package.json exports field
68+
69+
### Testing Strategy
70+
71+
Tests use Vitest with MSW (Mock Service Worker) for API mocking. Tests are organized by feature with corresponding `.test.ts` files in the `test/` directory.
72+
73+
## Build Configuration
74+
75+
- **tsup** - Primary build tool configured to output both CJS and ESM formats
76+
- **TypeScript** - Targets ES2020 with strict mode enabled
77+
- **ESLint** - Uses TypeScript ESLint configuration with Prettier integration
78+
- **Package Manager** - Uses pnpm (required >= 8)

README.md

Lines changed: 74 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,74 @@
1-
# node-narou
1+
# 📚 node-narou
22

33
[![npm version](https://badge.fury.io/js/narou.svg)](https://badge.fury.io/js/narou)
44
[![Node.js CI](https://github.com/deflis/node-narou/actions/workflows/nodejs-test.yml/badge.svg)](https://github.com/deflis/node-narou/actions/workflows/nodejs-test.yml)
5-
65
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/deflis/node-narou)
76

8-
[なろうデベロッパー](https://dev.syosetu.com/)の API を fluent interface で利用できるラッパーライブラリです。
9-
ブラウザでの JSONP の利用も可能です。
7+
[なろうデベロッパー](https://dev.syosetu.com/)の API を fluent interface で利用できる TypeScript ライブラリです。
8+
A TypeScript wrapper library for Narou Developer APIs with fluent interface.
109

11-
以下の API をラップしています。
10+
## ✨ 特徴
1211

13-
- [なろう小説 API](https://dev.syosetu.com/man/api/)
14-
- [なろう小説ランキング API](https://dev.syosetu.com/man/rankapi/)
15-
- [なろう殿堂入り API](https://dev.syosetu.com/man/rankinapi/)
16-
- [なろう R18 小説 API](https://dev.syosetu.com/xman/api/)
12+
- 🔗 **メソッドチェーン対応**: 直感的な fluent interface で API を操作
13+
- 🌐 **マルチ環境対応**: Node.js とブラウザの両方で動作
14+
- 📝 **TypeScript 完全対応**: 型安全性と IntelliSense サポート
15+
- 🔀 **デュアル実装**: fetch (Node.js) と JSONP (ブラウザ) を自動選択
16+
- 📚 **全 API カバー**: なろうデベロッパーの全 API に対応
1717

18-
## Installation
18+
## 🚀 対応 API
1919

20-
以下のコマンドでインストールできます。
20+
| API | 説明 | 関数 |
21+
|-----|------|------|
22+
| [なろう小説 API](https://dev.syosetu.com/man/api/) | 小説の検索・絞り込み | `search()` |
23+
| [なろう小説ランキング API](https://dev.syosetu.com/man/rankapi/) | ランキング取得 | `ranking()` |
24+
| [なろう殿堂入り API](https://dev.syosetu.com/man/rankinapi/) | ランキング履歴取得 | `rankingHistory()` |
25+
| [なろう R18 小説 API](https://dev.syosetu.com/xman/api/) | 18禁小説検索 | `searchR18()` |
26+
| [なろうユーザ検索 API](https://dev.syosetu.com/man/userapi/) | ユーザー検索 | `searchUser()` |
2127

22-
```
28+
## 📦 インストール
29+
30+
```bash
31+
# 推奨: pnpm
32+
pnpm add narou
33+
34+
# または
2335
npm install narou
36+
yarn add narou
37+
```
38+
39+
## 🚀 クイックスタート
40+
41+
### Node.js での使用
42+
43+
```typescript
44+
import { search, ranking } from "narou";
45+
import { Genre, Order, RankingType } from "narou";
46+
47+
// 異世界恋愛小説を検索
48+
const result = await search("異世界")
49+
.genre(Genre.RenaiIsekai)
50+
.order(Order.FavoriteNovelCount)
51+
.limit(10)
52+
.execute();
53+
54+
console.log(`${result.allcount}件の小説が見つかりました`);
2455
```
2556

26-
## Usage - API
57+
### ブラウザでの使用
2758

28-
https://deflis.github.io/node-narou/ を参照してください。
59+
```typescript
60+
// ブラウザでは専用のインポートを使用(JSONP対応)
61+
import { search } from "narou/browser";
2962

30-
ブラウザで利用したい場合 `narou/browser` をimportしてください。こちらを利用することで自動的にfetch(nodejs)への依存がなくなり、JSONPを利用するようになります。
63+
const result = await search("魔法").execute();
64+
```
3165

32-
すでにサポート終了していますがfetchをサポートしないNode.jsバージョンで利用する場合は 、 `NarouNovelFetch` にfetchのNode.js実装を渡してください。
33-
なお、その場合の動作は確認していないので動かなければIssueを立ててください。
66+
## 📖 詳細な API ドキュメント
3467

68+
- **🔗 [完全な API ドキュメント](https://deflis.github.io/node-narou/)** - TypeDoc で生成された詳細なドキュメント
69+
- **🤖 [LLM 向けドキュメント](https://deflis.github.io/node-narou/llms.txt)** - AI/LLM が理解しやすい形式のドキュメント(TypeDoc JSON から自動生成)
3570

36-
## Example
71+
## 📝 使用例
3772

3873
```typescript
3974
import { search, ranking, rankingHistory, searchR18 } from "narou";
@@ -113,32 +148,35 @@ for (const novel of searchR18Result.values) {
113148
}
114149
```
115150

116-
## Development
117-
118-
```
119-
120-
# watch
151+
## 🛠️ 開発
121152

122-
npm run watch
153+
このプロジェクトでは pnpm を使用しています。
123154

124-
# build
155+
```bash
156+
# 依存関係のインストール
157+
pnpm install
125158

126-
npm run build
159+
# ビルド
160+
pnpm run build
127161

128-
# test
162+
# テスト実行
163+
pnpm run test
129164

130-
npm run test
165+
# 型チェック
166+
pnpm run check
131167

168+
# ドキュメント生成(TypeDoc + llms.txt)
169+
pnpm run docs
132170
```
133171

134-
## Contributing
172+
## 🤝 コントリビューション
135173

136-
1. Fork it!
137-
2. Create your feature branch: `git checkout -b my-new-feature`
138-
3. Commit your changes: `git commit -am 'Add some feature'`
139-
4. Push to the branch: `git push origin my-new-feature`
140-
5. Submit a pull request :D
174+
1. このリポジトリをフォーク
175+
2. フィーチャーブランチを作成: `git checkout -b my-new-feature`
176+
3. 変更をコミット: `git commit -am 'Add some feature'`
177+
4. ブランチにプッシュ: `git push origin my-new-feature`
178+
5. プルリクエストを作成
141179

142-
## License
180+
## 📄 ライセンス
143181

144-
MIT
182+
MIT License - 詳細は [LICENSE](LICENSE) ファイルを参照してください。

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@
5959
"prepack": "run-z format build",
6060
"format": "eslint --fix src/** test/**",
6161
"test": "vitest run",
62-
"docs": "run-z docs:clean docs:typedoc",
62+
"docs": "run-z docs:clean docs:typedoc docs:json docs:llms",
6363
"docs:clean": "pnpm dlx rimraf docs",
64-
"docs:typedoc": "pnpm dlx typedoc --out ./docs src/index.ts"
64+
"docs:typedoc": "pnpm dlx typedoc --out ./docs src/index.ts",
65+
"docs:json": "pnpm dlx typedoc --json docs/api.json src/index.ts",
66+
"docs:llms": "node scripts/generate-llms-txt.js"
6567
},
6668
"devDependencies": {
6769
"@swc/core": "^1.11.29",

0 commit comments

Comments
 (0)