docdiff 0.6.2 → 0.6.4
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.
- checksums.yaml +4 -4
- data/Makefile +27 -49
- data/README.md +351 -0
- data/README_ja.md +351 -0
- data/Rakefile +2 -42
- data/bin/docdiff +53 -30
- data/{docdiff.conf.example → doc/example/docdiff.conf.example} +4 -3
- data/doc/man/docdiff.adoc +146 -0
- data/doc/news.md +180 -0
- data/doc/shell_completion/_docdiff.zsh +51 -0
- data/doc/shell_completion/docdiff.bash +68 -0
- data/docdiff.gemspec +1 -0
- data/lib/doc_diff.rb +13 -0
- data/lib/docdiff/version.rb +1 -1
- data/lib/docdiff/view.rb +4 -4
- data/test/charstring_test.rb +121 -121
- data/test/docdiff_test.rb +1 -1
- data/test/document_test.rb +109 -109
- data/test/fixture/01_ja_utf8_lf.txt +2 -0
- data/test/fixture/02_ja_utf8_lf.txt +2 -0
- data/test/view_test.rb +135 -111
- metadata +39 -36
- data/devutil/changelog.sh +0 -40
- data/index.html +0 -181
- data/langfilter.rb +0 -10
- data/readme.html +0 -750
- data/readme.md +0 -185
- /data/{docdiffwebui.cgi → doc/example/docdiffwebui.cgi} +0 -0
- /data/{docdiffwebui.html → doc/example/docdiffwebui.html} +0 -0
- /data/{img/docdiff-screenshot-format-html-digest-firefox.png → doc/img/screenshot-format-html-digest-firefox.png} +0 -0
- /data/{img/docdiff-screenshot-format-html-firefox.png → doc/img/screenshot-format-html-firefox.png} +0 -0
- /data/{img/docdiff-screenshot-format-tty-cmdexe-en.png → doc/img/screenshot-format-tty-cmdexe-en.png} +0 -0
- /data/{img/docdiff-screenshot-format-tty-cmdexe-ja.png → doc/img/screenshot-format-tty-cmdexe-ja.png} +0 -0
- /data/{img/docdiff-screenshot-format-tty-rxvtunicode-en.png → doc/img/screenshot-format-tty-rxvtunicode-en.png} +0 -0
- /data/{img/docdiff-screenshot-format-tty-rxvtunicode-ja.png → doc/img/screenshot-format-tty-rxvtunicode-ja.png} +0 -0
- /data/{img/docdiff-screenshot-format-tty-xterm-en.png → doc/img/screenshot-format-tty-xterm-en.png} +0 -0
- /data/{img/docdiff-screenshot-format-tty-xterm-ja.png → doc/img/screenshot-format-tty-xterm-ja.png} +0 -0
- /data/{img/docdiff-screenshot-resolution-linewordchar-xterm.png → doc/img/screenshot-resolution-linewordchar-xterm.png} +0 -0
- /data/{sample/01.en.ascii.cr → test/fixture/01_en_ascii_cr.txt} +0 -0
- /data/{sample/01.en.ascii.crlf → test/fixture/01_en_ascii_crlf.txt} +0 -0
- /data/{sample/01.en.ascii.lf → test/fixture/01_en_ascii_lf.txt} +0 -0
- /data/{sample/01.ja.eucjp.lf → test/fixture/01_ja_eucjp_lf.txt} +0 -0
- /data/{sample/01.ja.sjis.cr → test/fixture/01_ja_sjis_cr.txt} +0 -0
- /data/{sample/01.ja.sjis.crlf → test/fixture/01_ja_sjis_crlf.txt} +0 -0
- /data/{sample/01.ja.utf8.crlf → test/fixture/01_ja_utf8_crlf.txt} +0 -0
- /data/{sample/02.en.ascii.cr → test/fixture/02_en_ascii_cr.txt} +0 -0
- /data/{sample/02.en.ascii.crlf → test/fixture/02_en_ascii_crlf.txt} +0 -0
- /data/{sample/02.en.ascii.lf → test/fixture/02_en_ascii_lf.txt} +0 -0
- /data/{sample/02.ja.eucjp.lf → test/fixture/02_ja_eucjp_lf.txt} +0 -0
- /data/{sample/02.ja.sjis.cr → test/fixture/02_ja_sjis_cr.txt} +0 -0
- /data/{sample/02.ja.sjis.crlf → test/fixture/02_ja_sjis_crlf.txt} +0 -0
- /data/{sample/02.ja.utf8.crlf → test/fixture/02_ja_utf8_crlf.txt} +0 -0
- /data/{sample/humpty_dumpty01.ascii.lf → test/fixture/humpty_dumpty01_ascii_lf.txt} +0 -0
- /data/{sample/humpty_dumpty02.ascii.lf → test/fixture/humpty_dumpty02_ascii_lf.txt} +0 -0
data/README_ja.md
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
# DocDiff
|
|
2
|
+
|
|
3
|
+
* [English](README.md) | Japanese
|
|
4
|
+
|
|
5
|
+
(C) 2000 Hisashi MORITA
|
|
6
|
+
|
|
7
|
+
## 簡単な説明
|
|
8
|
+
|
|
9
|
+
2つのテキストファイルを単語ごと、文字ごと、あるいは行ごとに比較する
|
|
10
|
+
|
|
11
|
+
## スクリーンショット
|
|
12
|
+
|
|
13
|
+
<div style="display: grid; grid-template-columns: 1fr 1fr;">
|
|
14
|
+
|
|
15
|
+
<p>HTML出力<br />
|
|
16
|
+
<img src="doc/img/screenshot-format-html-firefox.png" alt="HTML output"/></p>
|
|
17
|
+
|
|
18
|
+
<p>HTML出力(ダイジェスト)<br />
|
|
19
|
+
<img src="doc/img/screenshot-format-html-digest-firefox.png" alt="HTML output (digest)" /></p>
|
|
20
|
+
|
|
21
|
+
<p>tty出力<br />
|
|
22
|
+
<img src="doc/img/screenshot-format-tty-rxvtunicode-en.png" alt="tty output" /></p>
|
|
23
|
+
|
|
24
|
+
<p>tty出力(日本語のテキストを比較)<br />
|
|
25
|
+
<img src="doc/img/screenshot-format-tty-rxvtunicode-ja.png" alt="tty output (comparing Japanese text)" /></p>
|
|
26
|
+
|
|
27
|
+
<p>tty出力<br />
|
|
28
|
+
<img src="doc/img/screenshot-format-tty-xterm-en.png" alt="tty output" /></p>
|
|
29
|
+
|
|
30
|
+
<p>tty出力(日本語のテキストを比較)<br />
|
|
31
|
+
<img src="doc/img/screenshot-format-tty-xterm-ja.png" alt="tty output (comparing Japanese text)" /></p>
|
|
32
|
+
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<p>英語のテキスト(コードページ437)を比較(Windows上のCygwin環境)<br />
|
|
36
|
+
<img src="doc/img/screenshot-format-tty-cmdexe-en.png" alt="Comparing English text (codepage 437) on Windows (Cygwin)" /></p>
|
|
37
|
+
|
|
38
|
+
<p>日本語のテキスト(コードページ937)を比較(Windows上のCygwin環境)<br />
|
|
39
|
+
<img src="doc/img/screenshot-format-tty-cmdexe-ja.png" alt="Comparing Japanese text (codepage 932) on Windows (Cygwin)" /></p>
|
|
40
|
+
|
|
41
|
+
<p>行ごと、単語ごと、文字ごとの比較が可能(フォーマットはtty)<br/>
|
|
42
|
+
<img src="doc/img/screenshot-resolution-linewordchar-xterm.png" alt="You can compare text files by line, word, or character (format: tty)" /></p>
|
|
43
|
+
|
|
44
|
+
(バージョン0.3.2時点のスクリーンショットです。)
|
|
45
|
+
|
|
46
|
+
## 概要
|
|
47
|
+
|
|
48
|
+
DocDiffは2つのテキストファイルを比較してその違いを表示します。単語ごと、文字ごと、そして行ごとにファイルを比較できます。結果を出力する形式は、HTML、tty(文字端末向けのエスケープシーケンス)、Manued(真鵺道という校正用のマークアップ形式)などが用意されており、ユーザ定義のタグを使うこともできます。
|
|
49
|
+
|
|
50
|
+
次のエンコーディング(文字コード)と行末コード(改行文字)をサポートしています: ASCII(およびISO-8859-*などのシングルバイトエンコーディング)、UTF-8、EUC-JP、Shift_JIS(Windows-31J)、そしてCR、LF、CRLF。
|
|
51
|
+
|
|
52
|
+
## 使い方
|
|
53
|
+
|
|
54
|
+
### 概要
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
$ docdiff [options] oldfile newfile
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
e.g.
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
$ docdiff old.txt new.txt > diff.html
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
詳しくはヘルプメッセージを参照してください(`docdiff --help`)。
|
|
67
|
+
|
|
68
|
+
### 例
|
|
69
|
+
|
|
70
|
+
<pre>
|
|
71
|
+
$ cat 01_ja_eucjp_lf.txt
|
|
72
|
+
こんにちは、私の名前はわたなべです。
|
|
73
|
+
私はJust Another Ruby Porterです。
|
|
74
|
+
$ cat 02_ja_eucjp_lf.txt
|
|
75
|
+
こんばんは、私の名前はまつもとです。
|
|
76
|
+
Rubyを作ったのは私です。私はRuby Hackerです。
|
|
77
|
+
$ docdiff --tty 01_ja_eucjp_lf.txt 02_ja_eucjp_lf.txt
|
|
78
|
+
<span class="before-change" style="background: yellow; border: thin inset;"><del>こんにちは</del></span><span class="after-change" style="background: lime; font-weight: bolder; border: thin outset;"><ins>こんばんは</ins></span>、私の<span class="before-change" style="background: yellow; border: thin inset;"><del>名前はわたなべです</del></span><span class="after-change" style="background: lime; font-weight: bolder; border: thin outset;"><ins>名前はまつもとです</ins></span>。
|
|
79
|
+
<span class="add" style="background: deepskyblue; font-weight: bolder; border: thin outset;"><ins>Rubyを作ったのは私です。</ins></span>私は<span class="del" style="background: hotpink; border: thin inset;"><del>Just Another </del></span>Ruby <span class="before-change" style="background: yellow; border: thin inset;"><del>Porter</del></span><span class="after-change" style="background: lime; font-weight: bolder; border: thin outset;"><ins>Hacker</ins></span>です。
|
|
80
|
+
$
|
|
81
|
+
</pre>
|
|
82
|
+
|
|
83
|
+
## 必要なソフトウェア
|
|
84
|
+
|
|
85
|
+
* 実行時に必要なソフトウェア:
|
|
86
|
+
- [Ruby](https://www.ruby-lang.org/) (>= 3.0)
|
|
87
|
+
* 開発時に必要なソフトウェア:
|
|
88
|
+
- Make ([GNU Make](https://www.gnu.org/software/make/))
|
|
89
|
+
- [Git](https://git-scm.com/)
|
|
90
|
+
- [md2html](https://github.com/mity/md4c)(ドキュメント生成用)
|
|
91
|
+
- [Rake](https://ruby.github.io/rake/)(オプショナル)
|
|
92
|
+
- sed, gzip, tar, etc.
|
|
93
|
+
|
|
94
|
+
## インストール方法
|
|
95
|
+
|
|
96
|
+
いくつかのOSでは、DocDiffがパッケージとして提供されていることがあります。そのような場合は、それらのパッケージを使ってインストールするのが早道でしょう。
|
|
97
|
+
|
|
98
|
+
### Debianパッケージ
|
|
99
|
+
|
|
100
|
+
サイト単位でのインストール:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
$ sudo apt update
|
|
104
|
+
$ sudo apt install docdiff
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Gemパッケージ
|
|
108
|
+
|
|
109
|
+
Rubyに詳しいならば、gemパッケージとしてDocDiffをインストールしたいと思うかもしれません。
|
|
110
|
+
|
|
111
|
+
ユーザ単位でのインストール([RubyGems.org](https://rubygems.org/)から):
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
$ gem install docdiff
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
ユーザ単位でのインストール(手元でのビルドから):
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
$ rake build
|
|
121
|
+
$ gem install pkg/docdiff-X.Y.Z.gem
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
(注意:Gemとしてインストールしたアプリケーションを起動するには、`PATH`環境変数を適切に設定する必要があります。[rbenv](https://github.com/rbenv/rbenv)などのRuby環境管理ツールを使うと便利かもしれません。)
|
|
125
|
+
|
|
126
|
+
### Makeを使ってソースからインストールする
|
|
127
|
+
|
|
128
|
+
やむをえずMakeを使ってソースからDocDiffをインストールするときは、事前によくテストしてください。
|
|
129
|
+
|
|
130
|
+
`tmp`ディレクトリへのテストインストール:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
$ mkdir tmp
|
|
134
|
+
$ make install DESTDIR=tmp PREFIX=/local
|
|
135
|
+
$ tree tmp || la -lR tmp
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
ユーザ単位でのインストールの例(ファイルを上書きしたりディレクトリ構造を汚くしたりしかねないので、おすすめしませんが):
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
$ make install DESTDIR=~ PREFIX=/local
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## 設定
|
|
145
|
+
|
|
146
|
+
設定ファイルは次の場所に配置すると有効になります:
|
|
147
|
+
|
|
148
|
+
* `/etc/docdiff/docdiff.conf`(サイト全体の設定)
|
|
149
|
+
|
|
150
|
+
* `~/.config/docdiff/docdiff.conf`(ユーザごとの設定)([`$XDG_CONFIG_HOME`](https://specifications.freedesktop.org/basedir/0.8/)参照)
|
|
151
|
+
|
|
152
|
+
(警告:`~/etc/docdiff/docdiff.conf`や`~/.docdiff/docdiff.conf`は、互換性のために今のところは有効なままですが、廃止される予定であり、使うことは推奨されません。また、同時に存在できるユーザ設定ファイルは一つだけです。)
|
|
153
|
+
|
|
154
|
+
設定ファイルの記法は次のとおりです(`docdiff.conf.example`ファイルも参照してください。配布アーカイブに含まれているはずです):
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
# comment
|
|
158
|
+
key1 = value
|
|
159
|
+
key2 = value
|
|
160
|
+
...
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
値(value)は、数字として解釈できるもの以外は、すべて文字列として扱われます。数字は数値(たいていは整数)として扱われます。
|
|
164
|
+
|
|
165
|
+
## 問題解決とヒント
|
|
166
|
+
|
|
167
|
+
### Wrong argument type nil (expected Module) (TypeError)
|
|
168
|
+
|
|
169
|
+
DocDiffがたまにエンコーディングや行末文字の自動判定に失敗して、次のようなエラーを出力することがあります。
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
charstring.rb:47:in `extend': wrong argument type nil (expected Module) (TypeError)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
このような場合は、エンコーディングや行末文字を明示的に指定してみてください(e.g. `docdiff --utf8 --crlf`)。
|
|
176
|
+
|
|
177
|
+
### 不適切な挿入と削除
|
|
178
|
+
|
|
179
|
+
スペースで区切られたテキスト(英文やプログラムのソースコードなど)を比較しているときに、行末にある単語が、特に必要もないのにいったん削除されてからまた挿入されることがあります。これはDocDiffの単語分割機能に制限があるせいで起きます。テキストは次のように単語に分割されます。
|
|
180
|
+
|
|
181
|
+
* Text 1:
|
|
182
|
+
```
|
|
183
|
+
foo bar
|
|
184
|
+
```
|
|
185
|
+
(`"foo bar" => ["foo ", "bar"]`)
|
|
186
|
+
|
|
187
|
+
* Text 2:
|
|
188
|
+
```
|
|
189
|
+
foo
|
|
190
|
+
bar
|
|
191
|
+
```
|
|
192
|
+
(`"foo\nbar" => ["foo", "\n", "bar"]`)
|
|
193
|
+
|
|
194
|
+
* 比較した結果:
|
|
195
|
+
<pre>
|
|
196
|
+
<del>foo </del><ins>foo</ins><ins>
|
|
197
|
+
</ins>bar
|
|
198
|
+
</pre>
|
|
199
|
+
(`"<del>foo </del><ins>foo</ins><ins>\n</ins>bar"`)
|
|
200
|
+
|
|
201
|
+
Fooは(必要もないのに)削除されると同時に挿入されています。
|
|
202
|
+
|
|
203
|
+
作者はこの問題をいつか解決したいと思っていますが、簡単ではなさそうです。もし空白を1つの要素として分割したなら(i.e. `["foo", " ", "bar"]`)、比較した結果出力される単語の並びが今よりも不自然になってしまいます。良い案があったら教えてください。
|
|
204
|
+
|
|
205
|
+
### DocDiffをバージョン管理システムと組み合わせて使う
|
|
206
|
+
|
|
207
|
+
DocDiffをVCSの外部diffプログラムとして使いたければ、次のようにするとよいでしょう。
|
|
208
|
+
|
|
209
|
+
* Git:
|
|
210
|
+
```
|
|
211
|
+
$ GIT_EXTERNAL_DIFF=~/bin/gitdocdiff.sh git diff
|
|
212
|
+
```
|
|
213
|
+
`~/bin/gitdocdiff.sh`:
|
|
214
|
+
```
|
|
215
|
+
#!/bin/sh
|
|
216
|
+
docdiff --ascii --lf --tty --digest $2 $5
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
* Subversion:
|
|
220
|
+
```
|
|
221
|
+
$ svn diff --diff-cmd=docdiff --extensions "--ascii --lf --tty --digest"
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
(場合によっては`git diff --word-diff-regex="\w"`で十分なこともありますが。)
|
|
225
|
+
|
|
226
|
+
zshを使えば、いろいろな場所にある文書をDocDiffや他のユーティリティで自由に比較できます。次の例ではリポジトリ内の特定のリビジョンのfoo.htmlとウェブサイト上のfoo.htmlとを比較しています。
|
|
227
|
+
|
|
228
|
+
* Git:
|
|
229
|
+
```
|
|
230
|
+
$ docdiff =(git show abc1234:foo.html) =(curl --silent http://www.example.org/foo.html)
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
* Subversion:
|
|
234
|
+
```
|
|
235
|
+
$ docdiff =(svn cat -r3 http://svn.example.org/repos/foo.html) =(curl --silent http://www.example.org/foo.html)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### プレーンテキストではない文書ファイルを比較する
|
|
239
|
+
|
|
240
|
+
適切な変換ツールを使えば、プレーンテキスト以外のファイルも比較できる場合があります。
|
|
241
|
+
|
|
242
|
+
* PDF文書中のテキストを比較する:
|
|
243
|
+
```
|
|
244
|
+
$ docdiff =(pdftotext foo.pdf -) =(pdftotext bar.pdf -)
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
* HTML文書中のテキスト(タグを除く)を比較する:
|
|
248
|
+
```
|
|
249
|
+
$ docdiff =(w3m -dump -cols 10000 foo.html) =(w3m -dump -cols 10000 http://www.example.org/foo.html)
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
* Microsoft Word文書中のテキストを比較する:
|
|
253
|
+
```
|
|
254
|
+
$ docdiff =(wvWare foo.doc | w3m -T text/html -dump -cols 10000) =(wvWare bar.doc | w3m -T text/html -dump -cols 10000)
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Latin-* (ISO-8859-*) のための回避策: ASCIIを指定する
|
|
258
|
+
|
|
259
|
+
文字コードがLatin-* (ISO-8859-*) のテキストを扱うときは、文字コードに`ASCII`を指定してみてください。`ASCII`が指定されると、DocDiffは対象をシングルバイト文字のテキストとして扱います。
|
|
260
|
+
|
|
261
|
+
* Latin-1テキストを比較する:
|
|
262
|
+
```
|
|
263
|
+
$ docdiff --encoding=ASCII latin-1-old.txt latin-1-new.txt
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## ライセンス
|
|
267
|
+
|
|
268
|
+
このソフトウェアはいわゆる修正BSDスタイルライセンス(<http://www.opensource.org/licenses/bsd-license.php>(広告条項なし))のもとで配布されています。このソフトウェアに貢献すると、あなたは貢献したものが同ライセンスのもとに取り込まれることに同意したとみなされます。
|
|
269
|
+
|
|
270
|
+
ソースコードの主となる部分の著作権と使用条件は次のとおりです:
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
Copyright (C) Hisashi MORITA. All rights reserved.
|
|
274
|
+
|
|
275
|
+
Redistribution and use in source and binary forms, with or without
|
|
276
|
+
modification, are permitted provided that the following conditions
|
|
277
|
+
are met:
|
|
278
|
+
1. Redistributions of source code must retain the above copyright
|
|
279
|
+
notice, this list of conditions and the following disclaimer.
|
|
280
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
281
|
+
notice, this list of conditions and the following disclaimer in the
|
|
282
|
+
documentation and/or other materials provided with the distribution.
|
|
283
|
+
3. Neither the name of the University nor the names of its contributors
|
|
284
|
+
may be used to endorse or promote products derived from this software
|
|
285
|
+
without specific prior written permission.
|
|
286
|
+
|
|
287
|
+
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
288
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
289
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
290
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
291
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
292
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
293
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
294
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
295
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
296
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
297
|
+
SUCH DAMAGE.
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Diffライブラリ(`lib/docdiff/diff.rb`および`lib/docdiff/diff/*`)は、もともと田中哲さんによるRuby/CVSの一部分でした。Ruby/CVSは修正BSDスタイルライセンスのもとで配布されています。詳細は次を参照してください。
|
|
301
|
+
|
|
302
|
+
* <http://raa.ruby-lang.org/list.rhtml?name=ruby-cvs>
|
|
303
|
+
* <http://cvs.m17n.org/~akr/ruby-cvs/>
|
|
304
|
+
|
|
305
|
+
## クレジット
|
|
306
|
+
|
|
307
|
+
* Hisashi MORITA (author)
|
|
308
|
+
|
|
309
|
+
## 謝辞
|
|
310
|
+
|
|
311
|
+
* Akira TANAKA (diff library author)
|
|
312
|
+
* Shin'ichiro HARA (initial idea and algorithm suggestion)
|
|
313
|
+
* Masatoshi SEKI (patch)
|
|
314
|
+
* Akira YAMADA (patch, Debian package)
|
|
315
|
+
* Kenshi MUTO (testing, bug report, Debian package)
|
|
316
|
+
* Kazuhiro NISHIYAMA (bug report)
|
|
317
|
+
* Hiroshi OHKUBO (bug report)
|
|
318
|
+
* Shugo MAEDA (bug report)
|
|
319
|
+
* Kazuhiko (patch)
|
|
320
|
+
* Shintaro Kakutani (patches)
|
|
321
|
+
* Masayoshi Takahashi (patches)
|
|
322
|
+
* Masakazu Takahashi (patch)
|
|
323
|
+
* Hibariya (bug report)
|
|
324
|
+
* Hiroshi SHIBATA (patch)
|
|
325
|
+
* Tamotsu Takahashi (patches)
|
|
326
|
+
* MIKAMI Yoshiyuki (patch)
|
|
327
|
+
|
|
328
|
+
このリストが全く不完全で、いろいろな形で貢献してくださった多くの方々へ謝意を表しそこねていることをお詫びします。本当にありがとうございます。
|
|
329
|
+
|
|
330
|
+
## 情報源
|
|
331
|
+
|
|
332
|
+
### フォーマット
|
|
333
|
+
|
|
334
|
+
* [HTML/XHTML](https://www.w3.org/)
|
|
335
|
+
* tty (Graphic rendition using VT100 / ANSI escape sequences)
|
|
336
|
+
- [VT100](https://vt100.net/docs/tp83/appendixb.html)
|
|
337
|
+
- [ANSI](https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html)
|
|
338
|
+
* [Manued](https://sundayresearch.eu/hitoshi/otherprojects/manued/) ([in Japanese](https://sundayresearch.eu/hitoshi/otherprojects/manued/index-j.html)) (Manuscript Editing Language: a proofreading method for text)
|
|
339
|
+
|
|
340
|
+
### 同様の機能を備えたソフトウェア
|
|
341
|
+
|
|
342
|
+
テキストを単語単位や文字単位で比較することができるソフトウェアは、数多く存在します。
|
|
343
|
+
|
|
344
|
+
* CLI:
|
|
345
|
+
- [wdiff](https://www.gnu.org/software/wdiff/) (requires spaces between words)
|
|
346
|
+
- cdif / [sdif-tools](https://github.com/kaz-utashiro/sdif-tools)
|
|
347
|
+
* GUI:
|
|
348
|
+
- [WinMerge](https://winmerge.org/) (Windows)
|
|
349
|
+
* Editor extensions:
|
|
350
|
+
- [ediff](https://www.gnu.org/software/emacs/manual/html_mono/ediff.html) (Emacs)
|
|
351
|
+
- [diff-detail](http://ohkubo.s53.xrea.com/xyzzy/index.html#diff-detail) ([xyzzy](https://github.com/xyzzy-022/xyzzy))
|
data/Rakefile
CHANGED
|
@@ -2,51 +2,11 @@ require 'rake/clean'
|
|
|
2
2
|
require 'rake/testtask'
|
|
3
3
|
require 'bundler/gem_tasks'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
DOCS = FileList['ChangeLog', 'readme.en.html', 'readme.ja.html',
|
|
7
|
-
'index.en.html', 'index.ja.html']
|
|
8
|
-
DOCSRC = FileList['readme.html', 'index.html', 'img', 'sample']
|
|
9
|
-
TESTS = FileList['test/*_test.rb']
|
|
10
|
-
TESTLOGS = Dir.glob('test/*_test.rb').map{|f|
|
|
11
|
-
File.basename(f).ext('log')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
WWWUSER = ENV['WWWUSER'] ||= 'hisashim,docdiff'
|
|
15
|
-
WWWSITE = ENV['WWWSITE'] ||= 'web.sourceforge.net'
|
|
16
|
-
WWWSITEPATH = ENV['WWWSITEPATH'] ||= 'htdocs/'
|
|
17
|
-
WWWDRYRUN = ENV['WWWDRYRUN'] ||= '--dry-run'
|
|
5
|
+
ENV['SOURCE_DATE_EPOCH'] ||= `git show --quiet --format=%ct HEAD`
|
|
18
6
|
|
|
19
7
|
Rake::TestTask.new do |t|
|
|
20
|
-
t.test_files =
|
|
8
|
+
t.test_files = FileList['test/*_test.rb']
|
|
21
9
|
t.verbose = true
|
|
22
10
|
end
|
|
23
11
|
|
|
24
12
|
task :default => :test
|
|
25
|
-
|
|
26
|
-
desc "generate documents"
|
|
27
|
-
task :docs => DOCS
|
|
28
|
-
|
|
29
|
-
file 'ChangeLog' do |t|
|
|
30
|
-
sh "devutil/changelog.sh > #{t.name}"
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
rule(/.*\.(?:en|ja)\.html/ => proc{|tn| tn.gsub(/\.(?:en|ja)/, '')}) do |t|
|
|
34
|
-
sh "#{RUBY} -E UTF-8 langfilter.rb" +
|
|
35
|
-
" --#{t.name.gsub(/.*?\.(en|ja)\.html/){$1}}" +
|
|
36
|
-
" #{t.prerequisites.first} > #{t.name}"
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
desc "force to rsync web contents"
|
|
40
|
-
task :wwwupload do |t|
|
|
41
|
-
sh "rake www WWWDRYRUN="
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
desc "rsync web contents"
|
|
45
|
-
task :www => DOCSRC + DOCS do |t|
|
|
46
|
-
sh "rsync #{WWWDRYRUN} -auv -e ssh --delete" +
|
|
47
|
-
" --exclude='.svn' --exclude='.git'" +
|
|
48
|
-
t.prerequisites.join(' ') +
|
|
49
|
-
" #{WWWUSER}@#{WWWSITE}:#{WWWSITEPATH}"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
CLEAN.include(DOCS, TESTLOGS)
|
data/bin/docdiff
CHANGED
|
@@ -14,6 +14,7 @@ default_config = {
|
|
|
14
14
|
:format => "html",
|
|
15
15
|
:cache => true,
|
|
16
16
|
:digest => false,
|
|
17
|
+
:pager => nil,
|
|
17
18
|
:verbose => false
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -28,73 +29,78 @@ end
|
|
|
28
29
|
|
|
29
30
|
ARGV.options {|o|
|
|
30
31
|
o.def_option('--resolution=RESOLUTION',
|
|
31
|
-
|
|
32
|
+
resolutions = ['line', 'word', 'char'],
|
|
32
33
|
'specify resolution (granularity)',
|
|
33
|
-
|
|
34
|
+
"#{resolutions.join('|')} (default: word)"
|
|
34
35
|
){|s| clo[:resolution] = (s || "word")}
|
|
35
|
-
o.def_option('--line', '
|
|
36
|
-
o.def_option('--word', '
|
|
37
|
-
o.def_option('--char', '
|
|
36
|
+
o.def_option('--line', 'same as --resolution=line'){clo[:resolution] = "line"}
|
|
37
|
+
o.def_option('--word', 'same as --resolution=word'){clo[:resolution] = "word"}
|
|
38
|
+
o.def_option('--char', 'same as --resolution=char'){clo[:resolution] = "char"}
|
|
38
39
|
|
|
39
40
|
o.def_option('--encoding=ENCODING',
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
encodings = ['ASCII', 'EUC-JP', 'Shift_JIS', 'CP932', 'UTF-8', 'auto'],
|
|
42
|
+
"specify character encoding",
|
|
43
|
+
"#{encodings.join('|')} (default: auto)",
|
|
44
|
+
"(try ASCII for single byte encodings such as ISO-8859)"
|
|
43
45
|
){|s| clo[:encoding] = (s || "auto")}
|
|
44
46
|
o.def_option('--ascii', 'same as --encoding=ASCII'){clo[:encoding] = "ASCII"}
|
|
45
|
-
o.def_option('--
|
|
47
|
+
o.def_option('--iso8859', 'same as --encoding=ASCII'){clo[:encoding] = "ASCII"}
|
|
48
|
+
o.def_option('--iso8859x', 'same as --encoding=ASCII (deprecated)'){clo[:encoding] = "ASCII"}
|
|
46
49
|
o.def_option('--eucjp', 'same as --encoding=EUC-JP'){clo[:encoding] = "EUC-JP"}
|
|
47
50
|
o.def_option('--sjis', 'same as --encoding=Shift_JIS'){clo[:encoding] = "Shift_JIS"}
|
|
48
51
|
o.def_option('--cp932', 'same as --encoding=CP932'){clo[:encoding] = "CP932"}
|
|
49
52
|
o.def_option('--utf8', 'same as --encoding=UTF-8'){clo[:encoding] = "UTF-8"}
|
|
50
53
|
|
|
51
54
|
o.def_option('--eol=EOL',
|
|
52
|
-
|
|
55
|
+
eols = ['CR','LF','CRLF','auto'],
|
|
53
56
|
'specify end-of-line character',
|
|
54
|
-
|
|
57
|
+
"#{eols.join('|')} (default: auto)",
|
|
55
58
|
){|s| clo[:eol] = (s || "auto")}
|
|
56
59
|
o.def_option('--cr', 'same as --eol=CR'){clo[:eol] = "CR"}
|
|
57
60
|
o.def_option('--lf', 'same as --eol=LF'){clo[:eol] = "LF"}
|
|
58
61
|
o.def_option('--crlf', 'same as --eol=CRLF'){clo[:eol] = "CRLF"}
|
|
59
62
|
|
|
60
63
|
o.def_option('--format=FORMAT',
|
|
61
|
-
|
|
64
|
+
formats = ['tty', 'manued', 'html', 'wdiff', 'stat', 'user'],
|
|
62
65
|
'specify output format',
|
|
63
|
-
|
|
64
|
-
"(default is html)",
|
|
66
|
+
"#{formats.join('|')} (default: html) (stat is deprecated)",
|
|
65
67
|
'(user tags can be defined in config file)'
|
|
66
68
|
){|s| clo[:format] = (s || "manued")}
|
|
67
69
|
o.def_option('--tty', 'same as --format=tty'){clo[:format] = "tty"}
|
|
68
70
|
o.def_option('--manued', 'same as --format=manued'){clo[:format] = "manued"}
|
|
69
71
|
o.def_option('--html', 'same as --format=html'){clo[:format] = "html"}
|
|
70
72
|
o.def_option('--wdiff', 'same as --format=wdiff'){clo[:format] = "wdiff"}
|
|
71
|
-
o.def_option('--stat', 'same as --format=stat (not
|
|
73
|
+
o.def_option('--stat', 'same as --format=stat (not implemented) (deprecated)'){clo[:format] = "stat"}
|
|
72
74
|
|
|
73
75
|
o.def_option('--label LABEL', '-L LABEL',
|
|
74
|
-
'
|
|
76
|
+
'use label instead of file name (not implemented; exists for compatibility with diff)'
|
|
75
77
|
){|s1, s2| clo[:label1], clo[:label2] = s1, s2}
|
|
76
78
|
|
|
77
79
|
o.def_option('--digest', 'digest output, do not show all'){clo[:digest] = true}
|
|
78
80
|
o.def_option('--summary', 'same as --digest'){clo[:digest] = true}
|
|
79
81
|
o.def_option('--display=DISPLAY',
|
|
80
|
-
|
|
82
|
+
display_types = ['inline', 'block', 'multi'],
|
|
81
83
|
'specify presentation type (effective only with digest; experimental feature)',
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
o.def_option('--cache', 'use file cache (not
|
|
84
|
+
"#{display_types.join('|')} (default: inline) (multi is deprecated)",
|
|
85
|
+
){|s| clo[:display] ||= s.downcase}
|
|
86
|
+
o.def_option('--cache', 'use file cache (not implemented) (deprecated)'){clo[:cache] = true}
|
|
87
|
+
o.def_option('--pager=PAGER', String,
|
|
88
|
+
'specify pager (if available, $DOCDIFF_PAGER is used by default)'
|
|
89
|
+
){|s| clo[:pager] = s}
|
|
90
|
+
o.def_option('--no-pager', 'do not use pager'){clo[:pager] = false}
|
|
91
|
+
o.def_option('--config-file=FILE', String,
|
|
92
|
+
'specify config file to read'){|s| clo[:config_file] = s}
|
|
85
93
|
o.def_option('--no-config-file',
|
|
86
94
|
'do not read config files'){clo[:no_config_file] = true}
|
|
87
|
-
o.def_option('--
|
|
88
|
-
'specify config file to read'){|s| clo[:config_file] = s}
|
|
89
|
-
o.def_option('--verbose', 'run verbosely (not supported yet)'){clo[:verbose] = true}
|
|
95
|
+
o.def_option('--verbose', 'run verbosely (not well-supported) (deprecated)'){clo[:verbose] = true}
|
|
90
96
|
|
|
91
97
|
o.def_option('--help', 'show this message'){puts o; exit(0)}
|
|
92
98
|
o.def_option('--version', 'show version'){puts DocDiff::AppVersion; exit(0)}
|
|
93
|
-
o.def_option('--license', 'show license'){puts DocDiff::License; exit(0)}
|
|
94
|
-
o.def_option('--author', 'show author(s)'){puts DocDiff::Author; exit(0)}
|
|
99
|
+
o.def_option('--license', 'show license (deprecated)'){puts DocDiff::License; exit(0)}
|
|
100
|
+
o.def_option('--author', 'show author(s) (deprecated)'){puts DocDiff::Author; exit(0)}
|
|
95
101
|
|
|
96
102
|
o.on_tail("When invoked as worddiff or chardiff, resolution will be set accordingly.",
|
|
97
|
-
"Config files: /etc/docdiff/docdiff.conf, ~/etc/docdiff/docdiff.conf")
|
|
103
|
+
"Config files: /etc/docdiff/docdiff.conf, ~/.config/docdiff/docdiff.conf (or ~/etc/docdiff/docdiff.conf (deprecated))")
|
|
98
104
|
|
|
99
105
|
o.parse!
|
|
100
106
|
} or exit(1)
|
|
@@ -108,12 +114,20 @@ unless clo[:no_config_file] == true # process_commandline_option
|
|
|
108
114
|
end
|
|
109
115
|
# message = docdiff.process_config_file(DocDiff::UserConfigFileName)
|
|
110
116
|
case
|
|
111
|
-
when File.exist?(DocDiff::UserConfigFileName)
|
|
112
|
-
|
|
117
|
+
when [File.exist?(DocDiff::UserConfigFileName),
|
|
118
|
+
File.exist?(DocDiff::AltUserConfigFileName),
|
|
119
|
+
File.exist?(DocDiff::XDGUserConfigFileName)].count(true) >= 2
|
|
120
|
+
raise <<~EOS
|
|
121
|
+
#{DocDiff::UserConfigFileName}, #{DocDiff::AltUserConfigFileName}, and \
|
|
122
|
+
#{DocDiff::XDGUserConfigFileName} cannot be used at the same time. \
|
|
123
|
+
Keep one and remove or rename the others.
|
|
124
|
+
EOS
|
|
113
125
|
when File.exist?(DocDiff::UserConfigFileName)
|
|
114
126
|
message = docdiff.process_config_file(DocDiff::UserConfigFileName)
|
|
115
127
|
when File.exist?(DocDiff::AltUserConfigFileName)
|
|
116
128
|
message = docdiff.process_config_file(DocDiff::AltUserConfigFileName)
|
|
129
|
+
when File.exist?(DocDiff::XDGUserConfigFileName)
|
|
130
|
+
message = docdiff.process_config_file(DocDiff::XDGUserConfigFileName)
|
|
117
131
|
end
|
|
118
132
|
if clo[:verbose] == true || docdiff.config[:verbose] == true
|
|
119
133
|
STDERR.print message
|
|
@@ -126,11 +140,20 @@ unless clo[:config_file].nil?
|
|
|
126
140
|
raise "#{clo[:config_file]} does not exist."
|
|
127
141
|
end
|
|
128
142
|
if clo[:verbose] == true || docdiff.config[:verbose] == true
|
|
129
|
-
STDERR.
|
|
143
|
+
STDERR.print message
|
|
130
144
|
end
|
|
131
145
|
end
|
|
132
146
|
docdiff.config.update(clo)
|
|
133
147
|
|
|
148
|
+
docdiff.config[:pager] =
|
|
149
|
+
if (pager = docdiff.config[:pager]).is_a?(String) && !pager.empty?
|
|
150
|
+
pager
|
|
151
|
+
elsif (pager = docdiff.config[:pager]) == false
|
|
152
|
+
pager
|
|
153
|
+
elsif (pager = ENV['DOCDIFF_PAGER']) && !pager.empty?
|
|
154
|
+
pager
|
|
155
|
+
end
|
|
156
|
+
|
|
134
157
|
# config stuff done
|
|
135
158
|
|
|
136
159
|
# process the documents
|
|
@@ -188,4 +211,4 @@ output = docdiff.run(doc1, doc2,
|
|
|
188
211
|
:format => docdiff.config[:format],
|
|
189
212
|
:digest => docdiff.config[:digest],
|
|
190
213
|
:display => docdiff.config[:display]})
|
|
191
|
-
|
|
214
|
+
docdiff.print_or_write_to_pager(output, docdiff.config[:pager])
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
# eol = LF
|
|
7
7
|
# format = html
|
|
8
8
|
# digest = off
|
|
9
|
-
# cache = off # not implemented
|
|
10
|
-
#
|
|
9
|
+
# cache = off # (not implemented) (deprecated)
|
|
10
|
+
# pager = less --raw-control-chars
|
|
11
|
+
# verbose = no # (not well-supported) (deprecated)
|
|
11
12
|
#
|
|
12
|
-
## user-defined tags (not well-supported
|
|
13
|
+
## user-defined tags (not well-supported)
|
|
13
14
|
# tag_common_start = '<=>'
|
|
14
15
|
# tag_common_end = '</=>'
|
|
15
16
|
# tag_del_start = '<->'
|