@ywal123456/jskim 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,128 @@
1
+ # ユーザーガイド PDF 生成手順
2
+
3
+ この文書は maintainer 向けです。公式ユーザーガイド本文(`docs/user-guide/`)とは別の運用手順です。
4
+
5
+ ## 目的
6
+
7
+ 分割 Markdown を source of truth として、A4 の PDF を再生成します。
8
+
9
+ ```text
10
+ docs/user-guide/*.md
11
+ → HTML
12
+ → Chromium(Edge / Chrome)
13
+ → JSKim_User_Guide_vX.Y.Z.pdf
14
+ ```
15
+
16
+ ## Source of truth
17
+
18
+ - `docs/user-guide/README.md`
19
+ - `docs/user-guide/01-*.md` ~ `14-*.md`
20
+
21
+ 統合 HTML は生成物です。手編集の対象ではありません。
22
+
23
+ ## Dependency
24
+
25
+ 開発用 dependency:
26
+
27
+ ```bash
28
+ npm install
29
+ ```
30
+
31
+ PDF 生成に使う package:
32
+
33
+ - `markdown-it`
34
+ - `playwright-core`
35
+
36
+ `playwright-core` は browser 本体を download しません。
37
+ PC にインストール済みの Microsoft Edge または Google Chrome を使います。
38
+
39
+ ## コマンド
40
+
41
+ HTML のみ(browser 不要):
42
+
43
+ ```bash
44
+ npm run docs:pdf:html
45
+ ```
46
+
47
+ 確認用 PDF(`dist/`、Git 非管理):
48
+
49
+ ```bash
50
+ npm run docs:pdf
51
+ ```
52
+
53
+ 既定の確認用出力先:
54
+
55
+ ```text
56
+ dist/docs/JSKim_User_Guide_v0.5.2.pdf
57
+ ```
58
+
59
+ npm package / release 用 PDF(`docs/`、Git 管理対象):
60
+
61
+ ```bash
62
+ npm run docs:pdf:package
63
+ ```
64
+
65
+ 既定の package 用出力先:
66
+
67
+ ```text
68
+ docs/JSKim_User_Guide_v0.5.2.pdf
69
+ ```
70
+
71
+ filename の version は `package.json` から読み取ります。script へ version を重複 hardcode しません。
72
+
73
+ ## 成果物の扱い
74
+
75
+ | 成果物 | 用途 | Git |
76
+ | ------ | ---- | --- |
77
+ | `dist/docs/**` | 一時 / 検食用 | 含めない |
78
+ | `docs/JSKim_User_Guide_vX.Y.Z.pdf` | npm package / release 添付候補 | 含める |
79
+ | TEMP HTML / screenshot | 検食用 | 含めない |
80
+
81
+ engine package(`@ywal123456/jskim`)をインストールした利用者は、次の場所で PDF を開けます。
82
+
83
+ ```text
84
+ node_modules/@ywal123456/jskim/docs/JSKim_User_Guide_v0.5.2.pdf
85
+ ```
86
+
87
+ ## Browser の指定
88
+
89
+ 探索優先順位:
90
+
91
+ 1. `--browser <path>`
92
+ 2. 環境変数 `JSKIM_PDF_BROWSER`
93
+ 3. OS ごとの既定候補(Edge / Chrome)
94
+
95
+ 例:
96
+
97
+ ```bash
98
+ npm run docs:pdf -- --browser "C:\Program Files\Google\Chrome\Application\chrome.exe"
99
+ ```
100
+
101
+ ```bash
102
+ set JSKIM_PDF_BROWSER=C:\Path\To\msedge.exe
103
+ npm run docs:pdf
104
+ ```
105
+
106
+ ## Option
107
+
108
+ | option | 説明 |
109
+ | ------ | ---- |
110
+ | `--html-only` | HTML 生成のみ。PDF は作らない |
111
+ | `--package-output` | `docs/JSKim_User_Guide_v${version}.pdf` へ出力 |
112
+ | `--output <path>` | PDF の任意出力先 |
113
+ | `--browser <path>` | 使用する Chromium 系 executable |
114
+ | `--keep-html` | 将来拡張用(現状は HTML を一時ディレクトリへ出力) |
115
+
116
+ `--package-output` と `--output`、`--html-only` と `--package-output` は同時に指定できません。
117
+
118
+ ## 方針
119
+
120
+ - font file を repository に追加しない(system 日本語 font を使用)
121
+ - generated HTML は OS の一時ディレクトリへ出力
122
+ - 確認用 PDF は `dist/docs/`、release 用 PDF は `docs/`
123
+ - 公式 guide 本文の Markdown を PDF 用に書き換えない
124
+
125
+ ## 関連
126
+
127
+ - 公式ガイド: [docs/user-guide/README.md](user-guide/README.md)
128
+ - 実装: `scripts/docs/build-user-guide-pdf.js`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ywal123456/jskim",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Nunjucks-based static HTML build environment with watch, serve, and live reload",
5
5
  "keywords": [
6
6
  "nunjucks",
@@ -39,6 +39,9 @@
39
39
  "watch": "node scripts/watch.js",
40
40
  "serve": "node scripts/serve.js",
41
41
  "dev": "node scripts/dev.js",
42
+ "docs:pdf": "node scripts/docs/build-user-guide-pdf.js",
43
+ "docs:pdf:html": "node scripts/docs/build-user-guide-pdf.js --html-only",
44
+ "docs:pdf:package": "node scripts/docs/build-user-guide-pdf.js --package-output",
42
45
  "test": "node --test --test-concurrency=1 test/**/*.test.js"
43
46
  },
44
47
  "engines": {
@@ -53,5 +56,9 @@
53
56
  "fast-glob": "^3.3.3",
54
57
  "fs-extra": "^11.3.0",
55
58
  "nunjucks": "^3.2.4"
59
+ },
60
+ "devDependencies": {
61
+ "markdown-it": "^14.3.0",
62
+ "playwright-core": "^1.61.1"
56
63
  }
57
64
  }
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const {
5
+ parseBuildArgs,
6
+ writeGuideHtml,
7
+ writeGuidePdf,
8
+ resolvePdfOutputPath,
9
+ getRepoRoot,
10
+ getPackageVersion,
11
+ } = require('./user-guide-pdf-lib');
12
+
13
+ async function main(argv = process.argv.slice(2)) {
14
+ const options = parseBuildArgs(argv);
15
+ const repoRoot = getRepoRoot();
16
+ const packageVersion = getPackageVersion(repoRoot);
17
+
18
+ if (options.htmlOnly) {
19
+ const result = await writeGuideHtml({ repoRoot });
20
+ console.log('ユーザーガイド HTML を生成しました。');
21
+ console.log(`HTML: ${result.htmlPath}`);
22
+ console.log(`chapter 数: ${result.chapterCount}`);
23
+ return;
24
+ }
25
+
26
+ const outputPath = resolvePdfOutputPath(repoRoot, packageVersion, options);
27
+ const result = await writeGuidePdf({
28
+ repoRoot,
29
+ browserPath: options.browser,
30
+ outputPath,
31
+ });
32
+
33
+ console.log('ユーザーガイドPDFを生成しました。');
34
+ console.log(`browser: ${result.browserPath}`);
35
+ console.log(`HTML: ${result.htmlPath}`);
36
+ console.log(`PDF: ${result.pdfPath}`);
37
+ console.log(`PDF size: ${result.pdfSize} bytes`);
38
+ console.log(`chapter 数: ${result.chapterCount}`);
39
+ }
40
+
41
+ if (require.main === module) {
42
+ main().catch((err) => {
43
+ const message = err && err.message ? err.message : String(err);
44
+ console.error(message);
45
+ process.exitCode = 1;
46
+ });
47
+ }
48
+
49
+ module.exports = { main };