madowu 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +20 -1
- data/Gemfile +3 -3
- data/VERSION +1 -1
- data/bin/dirmap +33 -9
- data/bin/madowu +7 -3
- data/bin/tex2image +72 -0
- data/doc/.dirmap.md +9 -0
- data/doc/.gitignore +2 -0
- data/doc/Rakefile +109 -0
- data/doc/index.md +166 -0
- data/doc/madowu.css +624 -0
- data/example/.gitignore +2 -0
- data/example/Rakefile +71 -36
- data/example/eq.tex +9 -0
- data/example/index.md +3 -0
- data/example/madowu.css +11 -2
- data/example/subdir/Rakefile +109 -0
- data/example/subdir/madowu.css +624 -0
- data/example/subdir/subdir2/Rakefile +109 -0
- data/example/subdir/subdir2/madowu.css +624 -0
- data/example/tex2image/.gitignore +2 -0
- data/example/tex2image/eq.tex +9 -0
- data/lib/madowu/directorymapper.rb +9 -9
- data/lib/madowu/htmlgenerator.rb +52 -18
- data/madowu.gemspec +26 -13
- data/test/test_directorymapper.rb +24 -15
- data/test/test_htmlgenerator.rb +106 -41
- metadata +31 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3caa7db7adf2f71986d61b394cfed755b9e7bf8
|
4
|
+
data.tar.gz: 3d92c808e7a437ec6e6002c84de71e4eebf205ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 951ddcc593d512e5494804a424b7fd1c1247d529db51bad07a8f514eb622237dc3985aa4a7efd043b9e7d43bef4a85146a54b04b47acb079e8434b91752ba297
|
7
|
+
data.tar.gz: 9604056e05272c4fdc943a1cede76b53107604b572265b50a58d2b3dde76b2210b0d0e414916b133f619377e9a41285074ebfd86eedc380827edfed7cbe2dc0c
|
data/CHANGES
CHANGED
@@ -1,6 +1,25 @@
|
|
1
1
|
= THIS_GEM changelog
|
2
2
|
|
3
|
-
== Master (for 0.0.
|
3
|
+
== Master (for 0.0.4)
|
4
|
+
|
5
|
+
== Version 0.0.3 [2016-02-26]
|
6
|
+
* bin/
|
7
|
+
* modify 'madowu' command
|
8
|
+
* add -O (--outline-selflink) option.
|
9
|
+
* remove '--side-map' option.
|
10
|
+
* modify '--side=file' to deal with Markdown format file instead of HTML.
|
11
|
+
* modify '--outline' to outputs layering itemization.
|
12
|
+
* add 'tex2image' command
|
13
|
+
* modify 'bin/dirmap' command to outputs Markdown format.
|
14
|
+
* 'example/Rakefile'
|
15
|
+
* add 'subdir' target
|
16
|
+
* modify target from **/*.md to *.md in default target
|
17
|
+
* add 'tex2image' target
|
18
|
+
* modify 'default' target to include 'tex2image' target
|
19
|
+
* modify 'md2html' target to detect file existence change.
|
20
|
+
* modify html files to depend on .dirmap.md updated.
|
21
|
+
* doc/ is included( in Japanese).
|
22
|
+
* lib/htmlgenerator.rb, <HTML> header to <html> in HtmlGenerator.generate
|
4
23
|
|
5
24
|
== Version 0.0.2 [2015-10-20]
|
6
25
|
* Add -C (--charset) option and default encoding is set to be 'us-ascii'
|
data/Gemfile
CHANGED
@@ -6,9 +6,9 @@ source "http://rubygems.org"
|
|
6
6
|
# Add dependencies to develop your gem here.
|
7
7
|
# Include everything needed to run rake, tests, features, etc.
|
8
8
|
group :development do
|
9
|
+
gem "test-unit", "~> 3.1"
|
9
10
|
gem "rdoc", "~> 4.2"
|
10
|
-
gem "bundler", "~> 1.
|
11
|
+
gem "bundler", "~> 1.11"
|
11
12
|
gem "jeweler", "~> 2.0"
|
12
|
-
gem "simplecov", "~> 0"
|
13
|
-
gem "test-unit", "~> 3.1"
|
13
|
+
gem "simplecov", "~> 0.11"
|
14
14
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/bin/dirmap
CHANGED
@@ -1,30 +1,54 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
|
+
DEFAULT_OUTFILE = '.dirmap.md'
|
5
|
+
|
4
6
|
require "optparse"
|
5
7
|
require "pathname"
|
6
8
|
require "pp"
|
7
9
|
require "madowu"
|
8
10
|
|
9
11
|
### option analysis
|
10
|
-
|
12
|
+
options = {}
|
11
13
|
op = OptionParser.new
|
12
14
|
op.banner = [
|
13
|
-
"Usage: #{File.basename("#{__FILE__}")} dir_path",
|
14
|
-
" Note that indicate directory, not file."
|
15
|
+
"Usage: #{File.basename("#{__FILE__}")} [dir_path]",
|
16
|
+
" Note that indicate directory, not file.",
|
17
|
+
" Default 'dirpath' is '.'"
|
15
18
|
].join("\n")
|
16
|
-
|
17
|
-
|
18
|
-
#op.
|
19
|
+
op.on("-v" , "--verbose" , "Output to stdout too"){ options[:verbose] = true}
|
20
|
+
op.on("-f" , "--force" , "Force output"){ options[:force] = true}
|
21
|
+
#op.on("-a" , "--aho" , "descriptionA"){ options[:aho] = true}
|
22
|
+
#op.on("-b val", "--bak=val", "descriptionB"){|v| options[:bak] = v}
|
23
|
+
op.parse!(ARGV)
|
19
24
|
|
20
|
-
|
25
|
+
if ARGV.size > 1
|
21
26
|
puts op.banner
|
22
27
|
exit
|
23
28
|
end
|
24
29
|
|
25
|
-
|
30
|
+
dir = ARGV[0] || '.'
|
31
|
+
unless FileTest.directory? dir
|
26
32
|
puts op.banner
|
27
33
|
exit
|
28
34
|
end
|
29
35
|
|
30
|
-
|
36
|
+
def should_update?(options, outfile, new_contents)
|
37
|
+
return true if options[:force]
|
38
|
+
return true unless FileTest.exist? outfile
|
39
|
+
|
40
|
+
old_contents = File.open(outfile, "r").readlines.map{|i| i.chomp}
|
41
|
+
return false if old_contents == new_contents
|
42
|
+
|
43
|
+
return true
|
44
|
+
end
|
45
|
+
|
46
|
+
outfile = DEFAULT_OUTFILE
|
47
|
+
contents = Madowu::DirectoryMapper.dirmap(dir)
|
48
|
+
|
49
|
+
if should_update?(options, outfile, contents)
|
50
|
+
io = File.open(outfile, 'w')
|
51
|
+
io.puts contents
|
52
|
+
puts contents if options[:verbose]
|
53
|
+
end
|
54
|
+
|
data/bin/madowu
CHANGED
@@ -15,13 +15,17 @@ OPTIONS = {}
|
|
15
15
|
op = OptionParser.new
|
16
16
|
op.banner = [
|
17
17
|
"Usage: #{File.basename("#{__FILE__}")} [options] foo.md",
|
18
|
-
"
|
18
|
+
" You can see help with '#{File.basename("#{__FILE__}")} --help'.",
|
19
19
|
].join("\n")
|
20
20
|
op.on("-c css_file", "--css=file", "Indicate css file"){|v| OPTIONS[:css] = v}
|
21
21
|
op.on("-C charset", "--charset=str", "Indicate charset like 'UTF-8'"){|v| OPTIONS[:charset] = v}
|
22
22
|
op.on("-o" , "--outline" , "Embed outline"){ OPTIONS[:outline] = true}
|
23
|
-
op.on("-
|
24
|
-
|
23
|
+
op.on("-O" , "--outline-selflink", "Embed outline with link to the line"){
|
24
|
+
OPTIONS[:outline] = true
|
25
|
+
OPTIONS[:selflink] = true
|
26
|
+
}
|
27
|
+
#op.on("-d" , "--dirmap-side", "Embed sideber of directory map"){OPTIONS[:dirmap] = true}
|
28
|
+
op.on("-s file" , "--side=md_file", "Read Markdown file for sidebar"){|v|OPTIONS[:sidebar] = v}
|
25
29
|
op.on("-m markdown" , "--markdown=command", "Indicate Markdown command"){|v| OPTIONS[:markdown] = v}
|
26
30
|
op.parse!(ARGV)
|
27
31
|
|
data/bin/tex2image
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
#
|
4
|
+
# TODO
|
5
|
+
# 完結した tex としてコンパイル
|
6
|
+
# document 環境としてコンパイル
|
7
|
+
# equation 環境としてコンパイル
|
8
|
+
# eqnarray 環境としてコンパイル。開始式番号指定
|
9
|
+
|
10
|
+
|
11
|
+
DEFAULT_DENSITY = 150
|
12
|
+
|
13
|
+
USAGE = <<HERE
|
14
|
+
Usage: #{File.basename("#{__FILE__}")} tex_file
|
15
|
+
|
16
|
+
Default:
|
17
|
+
- Output png image.
|
18
|
+
- Density for conversion is #{DEFAULT_DENSITY}.
|
19
|
+
HERE
|
20
|
+
|
21
|
+
LATEX = 'latexmk'
|
22
|
+
CONVERT = 'convert'
|
23
|
+
|
24
|
+
require "optparse"
|
25
|
+
require "pp"
|
26
|
+
require "pathname"
|
27
|
+
require "fileutils"
|
28
|
+
|
29
|
+
## option analysis
|
30
|
+
options = {}
|
31
|
+
op = OptionParser.new
|
32
|
+
op.banner = USAGE
|
33
|
+
op.on("-j" , "--jpg" , "Output jpg image, alternative to png."){ options[:img] = :jpg}
|
34
|
+
op.on("-d val", "--density=val", "Set density for raster conversion"){|v| options[:density] = v}
|
35
|
+
op.parse!(ARGV)
|
36
|
+
|
37
|
+
options[:img] ||= :png
|
38
|
+
img_ext = options[:img].to_s
|
39
|
+
|
40
|
+
density = DEFAULT_DENSITY
|
41
|
+
density = options[:density].to_i if options[:density]
|
42
|
+
|
43
|
+
def execute(commands)
|
44
|
+
commands.each do |c|
|
45
|
+
puts c
|
46
|
+
system c
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
if ARGV.empty?
|
51
|
+
puts "Need one tex file in argument. Exit."
|
52
|
+
puts USAGE
|
53
|
+
exit
|
54
|
+
end
|
55
|
+
|
56
|
+
tex_file = ARGV[0]
|
57
|
+
dvi_file = Pathname(tex_file).sub_ext(".dvi").to_s
|
58
|
+
img_file = Pathname(tex_file).sub_ext(".#{img_ext}").to_s
|
59
|
+
|
60
|
+
|
61
|
+
commands = []
|
62
|
+
commands << "#{LATEX} #{tex_file} > /dev/null"
|
63
|
+
commands << "#{CONVERT} -trim -density #{density}x#{density} #{dvi_file} #{img_file}"
|
64
|
+
execute(commands)
|
65
|
+
commands = []
|
66
|
+
|
67
|
+
trash_exts = [ 'aux', 'dvi', 'fdb_latexmk', 'fls', 'log']
|
68
|
+
trash_exts.each do |ext|
|
69
|
+
file = Pathname(tex_file).sub_ext(".#{ext}").to_s
|
70
|
+
FileUtils.rm file if File.exist? file
|
71
|
+
end
|
72
|
+
|
data/doc/.dirmap.md
ADDED
data/doc/.gitignore
ADDED
data/doc/Rakefile
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# Rakefile for Markdown documents.
|
3
|
+
|
4
|
+
DIRMAP_MD = '.dirmap.md'
|
5
|
+
ENCODING = "UTF-8"
|
6
|
+
HTML2PDF = "wkhtmltopdf"
|
7
|
+
TEX2IMAGE = "tex2image"
|
8
|
+
HTML2PDF_OPTIONS = "-B 1cm -L 1.5cm -R 1.5cm -T 1.5cm -s A4 --encoding #{ENCODING} "
|
9
|
+
CONVERT_COMMAND = "convert -alpha deactivate -density 150x150"
|
10
|
+
|
11
|
+
require "pp"
|
12
|
+
require "fileutils"
|
13
|
+
require "pathname"
|
14
|
+
|
15
|
+
## .dirmap.md
|
16
|
+
# dirmap コマンドは必ず実行なので task タスク。
|
17
|
+
# これを file にすると存在するときに実行されない。
|
18
|
+
# 生成物の .dirmap.md から task タスクへの依存を設定すると、
|
19
|
+
# .dirmap.md に依存する file タスクに「必ず実行」が伝播して必ず実行になってしまう。
|
20
|
+
# DIRMAP_MD というファイルに対する file タスクへの依存として扱うことで、
|
21
|
+
# .dirmap.md に依存する file タスクに「必ず実行」が伝播するのを防いでいる。
|
22
|
+
desc "update .dirmap.md if directory changed."
|
23
|
+
file DIRMAP_MD => :dirmap_command
|
24
|
+
task :dirmap_command do
|
25
|
+
sh "dirmap"
|
26
|
+
end
|
27
|
+
|
28
|
+
## *.html
|
29
|
+
md_files = FileList["*.md"]
|
30
|
+
html_files = md_files.ext("html")
|
31
|
+
html_tasks = []
|
32
|
+
html_files.each do |html_file|
|
33
|
+
md_file = html_file.ext("md")
|
34
|
+
md_path = Pathname.new( md_file)
|
35
|
+
dirpath = md_path.dirname
|
36
|
+
src = FileList[md_file, DIRMAP_MD]
|
37
|
+
file html_file => [DIRMAP_MD, md_file] do
|
38
|
+
sh "madowu -O -s .dirmap.md -c madowu.css -C UTF-8 #{md_file}"
|
39
|
+
end
|
40
|
+
html_tasks << html_file
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "make *.html from *.md"
|
44
|
+
task :md2html => [DIRMAP_MD, * html_tasks]
|
45
|
+
|
46
|
+
|
47
|
+
desc "make *.pdf from *.html"
|
48
|
+
pdf_files = html_files.ext("pdf")
|
49
|
+
task :html2pdf => FileList[pdf_files]
|
50
|
+
pdf_files.each do |pdf_file|
|
51
|
+
html_file = pdf_file.ext("html")
|
52
|
+
file pdf_file => html_file do
|
53
|
+
sh "#{HTML2PDF} #{HTML2PDF_OPTIONS} #{html_file} #{pdf_file}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
desc "make .png from .eps."
|
59
|
+
eps_files = FileList["*.eps"]
|
60
|
+
png_files = eps_files.ext("png")
|
61
|
+
task :eps2png => FileList[png_files]
|
62
|
+
png_files.each do |png_file|
|
63
|
+
eps_file = png_file.ext("eps")
|
64
|
+
t = [eps_file]
|
65
|
+
file png_file => t do
|
66
|
+
sh "#{CONVERT_COMMAND} #{eps_file} #{png_file}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
desc "make *.png from *.tex"
|
72
|
+
tex_files = FileList["*.tex"]
|
73
|
+
png_files = tex_files.ext("png")
|
74
|
+
task :tex2png => FileList[png_files]
|
75
|
+
png_files.each do |png_file|
|
76
|
+
tex_file = png_file.ext("tex")
|
77
|
+
file png_file => tex_file do
|
78
|
+
#pp png_file, tex_file; exit
|
79
|
+
sh "#{TEX2IMAGE} #{tex_file}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
# recursive だと、サブディレクトリの Rakefile も
|
85
|
+
# recursive ターゲットを持っているという前提が必要。
|
86
|
+
desc "execute 'rake' in all subdirs with Rakefile"
|
87
|
+
rakefiles = FileList["**/Rakefile"]
|
88
|
+
dirs = rakefiles.map{|path| Pathname.new(path).dirname.to_s}
|
89
|
+
dirs.delete_if {|i| i == '.' }
|
90
|
+
dirs.map!{|path| File.absolute_path(path)}
|
91
|
+
task :subdir do
|
92
|
+
dirs.each do |dir|
|
93
|
+
Dir.chdir dir
|
94
|
+
system "rake"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
task :all => [:md2html, :subdir]
|
99
|
+
|
100
|
+
task :pdf => :html2pdf
|
101
|
+
#task :default => [:tree, :tex2png, :eps2png]
|
102
|
+
task :default => [:md2html, :tex2png, :eps2png]
|
103
|
+
|
104
|
+
require "rake/clean"
|
105
|
+
CLEAN.include( [
|
106
|
+
html_files,
|
107
|
+
pdf_files,
|
108
|
+
])
|
109
|
+
|
data/doc/index.md
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
<!-- vim:syntax=markdown
|
2
|
+
-->
|
3
|
+
|
4
|
+
# Madowu, MArkDOWn to markUp
|
5
|
+
|
6
|
+
「まどう」と読みます。
|
7
|
+
|
8
|
+
Markdown で書かれたドキュメントを、
|
9
|
+
ヘッダフッタ付きのちゃんとした HTML にします。
|
10
|
+
なお、このページは madowu によって生成されています。
|
11
|
+
|
12
|
+
|
13
|
+
## インストール
|
14
|
+
gem install madowu
|
15
|
+
|
16
|
+
## 基本的な動作
|
17
|
+
|
18
|
+
一つの md ファイルを受け取り、
|
19
|
+
拡張子を html に変更したファイルを生成します。
|
20
|
+
元々存在しても、確認なしに上書きします。
|
21
|
+
|
22
|
+
`madowu *.md` のように 複数ファイルを一度に扱えるようにはしていません。
|
23
|
+
今のところ、これは make や rake が分担すべき仕事だと考えています。
|
24
|
+
|
25
|
+
## HTML head の title 要素
|
26
|
+
HTML ではファイルで表現される文書のタイトルを
|
27
|
+
head 要素の title 要素で指定しますが、
|
28
|
+
markdown ではこれを指定する方法がありません。
|
29
|
+
Madowu では、md ファイル内で現れる最初の見出し(「#」で始まる行。レベルは1と限らない)
|
30
|
+
をページ全体のタイトルとして扱います。
|
31
|
+
すなわち、Madowu ではファイル内に h1 要素を生成するレベル1 の
|
32
|
+
「#」が 1つだけであり、これが全ての見出しの中で最初に出現することを想定しています。
|
33
|
+
|
34
|
+
## オプション
|
35
|
+
madowu -h
|
36
|
+
でヘルプが出ます。
|
37
|
+
|
38
|
+
### -o オプション, outline を埋め込む
|
39
|
+
見出しをまとめた outline を body の先頭に埋め込みます。
|
40
|
+
markdown 処理されたマークアップテキストに、さらにアンカーとリンクを追加します。
|
41
|
+
|
42
|
+
スタイルシートを適切に準備しておけば幸せになれるでしょう。
|
43
|
+
example/madowu.css を参考にされると良いでしょう。
|
44
|
+
また、一度 example で rake を実行し、
|
45
|
+
ブラウザで生成された html 群を見てみると良いと思います。
|
46
|
+
|
47
|
+
### -O オプション, タイトル行そのものをその行へのリンクにする。
|
48
|
+
-o の機能に追加して、タイトル行そのものをその行へのリンクにします。
|
49
|
+
|
50
|
+
### -d オプション, sidebar にディレクトリマップを埋め込む
|
51
|
+
ファイルが存在するディレクトリ周囲のファイルへのリンクをまとめ、sidebar に配置します。
|
52
|
+
|
53
|
+
親ディレクトリ、同一ディレクトリ内のエントリの2種類に分類します。
|
54
|
+
ディレクトリへのリンクに関しては、index.html or index.md があれば index.html
|
55
|
+
へのリンクを作り、存在しなければ ディレクトリ自体にリンクします。
|
56
|
+
同一ディレクトリのファイルは、`foo.md` は `foo.html` になるものとして、html の名前でリンクを生成します。
|
57
|
+
また、md もしくは html ファイルでタイトル相当の情報があれば、
|
58
|
+
これを 括弧内で補助的に表示します。
|
59
|
+
|
60
|
+
これも、
|
61
|
+
スタイルシートを適切に準備しておけば幸せになれるでしょう。
|
62
|
+
|
63
|
+
### -c オプション, css ファイル指定
|
64
|
+
html 表示に適用するスタイルシートのパスを指定します。
|
65
|
+
元となる markdown ファイルのパスと指定された css ファイルのパスとの
|
66
|
+
相対パスに変換して埋め込みます。
|
67
|
+
|
68
|
+
### -C オプション, charset 指定
|
69
|
+
HTML ヘッダで指定するファイルの文字エンコーディングを指定します。
|
70
|
+
指定しない場合のデフォルト値は US-ASCII です。
|
71
|
+
|
72
|
+
### -s オプション
|
73
|
+
サイドバーに埋め込む内容のファイルを指定します。
|
74
|
+
このファイルを Markdown 処理して埋め込みます。
|
75
|
+
|
76
|
+
|
77
|
+
### -m オプション
|
78
|
+
使用する markdown コマンドを指定します。
|
79
|
+
方言を含む markdown like な処理系を指定することも可能です。
|
80
|
+
|
81
|
+
## 支援コマンド
|
82
|
+
|
83
|
+
### tex2image
|
84
|
+
|
85
|
+
LaTeX の出力を画像にします。
|
86
|
+
数式の貼り込みなどに便利だと思います。
|
87
|
+
デフォルトでは png 形式で書き出します。
|
88
|
+
|
89
|
+
* -j, --jpg オプション。png ではなく、jpg 形式で書き出します。
|
90
|
+
* -d, --density=val オプション。解像度を指定します。
|
91
|
+
|
92
|
+
### dirmap
|
93
|
+
|
94
|
+
親子関係で隣接したディレクトリへのリンクを表す .dirmap.md ファイルを Markdown
|
95
|
+
形式で書き出します。
|
96
|
+
|
97
|
+
.dirmap.md と内容に変更がなければ書き出さず、タイムスタンプを維持します。
|
98
|
+
|
99
|
+
## example
|
100
|
+
ウェブサイトのように、ディレクトリ丸々 markdown から html に変換するような場合に
|
101
|
+
使える Rakefile のサンプルが example/ 以下にあります。
|
102
|
+
とりあえず rake して生成される index.html と
|
103
|
+
他の html を見るとだいたい感じがつかめると思います。
|
104
|
+
|
105
|
+
|
106
|
+
<!--
|
107
|
+
### ディレクトリ更新の追従
|
108
|
+
この Rakefile では html ファイル生成が md ファイルのみに依存するようになっている
|
109
|
+
ため、
|
110
|
+
ディレクトリへのファイルの追加・削除のみがあった場合には自動的にそれを補うように
|
111
|
+
更新されません。
|
112
|
+
そのため、このような目的のためには手動で強制的に html を生成する必要があります。
|
113
|
+
|
114
|
+
#### このような仕様になっている理由
|
115
|
+
|
116
|
+
ディレクトリに依存するとして Rakefile を記述すると、追加・削除がなくとも、
|
117
|
+
どれか一つのファイルを更新する度にディレクトリ内のファイルが全て madowu 処理
|
118
|
+
されることになります。
|
119
|
+
ディレクトリ内のファイルエントリが変更されなければディレクトリのタイムスタンプ
|
120
|
+
は本来更新されないのですが、
|
121
|
+
vim や emacs は foo.swp のようなスワップファイルを生成・削除するため、
|
122
|
+
ディレクトリのタイムスタンプが更新されてしまいます。
|
123
|
+
ファイル編集は通常エディタで行うことが想定されますので、
|
124
|
+
この挙動は受け入れるべきです。
|
125
|
+
そのため、1つのファイルを更新すると同時にディレクトリの更新時刻も更新され、
|
126
|
+
そのディレクトリに依存する全ての html ファイルの更新が必要と判断されるということになります。
|
127
|
+
ところが、このような挙動は多数の `*.md` ファイルが存在するディレクトリで
|
128
|
+
1つのファイルを更新しても、
|
129
|
+
rake をかけるたびに全てのファイルを更新することになり、
|
130
|
+
確認しながらの編集がストレスフルなものとなってしまいます。
|
131
|
+
このデメリットが
|
132
|
+
ディレクトリ更新を自動的に補足するメリットよりも大きいと判断したため、
|
133
|
+
example/Rakefile ではディレクトリのタイムスタンプは見ない、
|
134
|
+
という仕様に今のところなっています。
|
135
|
+
|
136
|
+
.dirmap.html のようなファイルを生成して
|
137
|
+
これを読み込むようにもしてみたことがありますが、
|
138
|
+
この場合もディレクトリの更新時刻が更新されます。
|
139
|
+
毎回 .dirmap.html が更新されるので、毎回全てのファイルが更新されてしまいます。
|
140
|
+
|
141
|
+
.dirmap.html を生成しておいて、
|
142
|
+
ファイル内容をチェックし、変更があればこれを更新、というのは一つの手かもしれません。
|
143
|
+
しかし、挙動が複雑な割に得られるメリットが少ない気がします。
|
144
|
+
-->
|
145
|
+
|
146
|
+
### 再帰的なターゲッティング
|
147
|
+
この Rakefile では `**.md` のように
|
148
|
+
1つの Rakefile で再帰的にターゲッティングしていますが、
|
149
|
+
運用によってはこのようにせず、各ディレクトリで Rakefile を配置する方が良いかもしれません。
|
150
|
+
|
151
|
+
## 関連プログラム
|
152
|
+
freestyle wiki からのデータ移動を考えている方は、
|
153
|
+
tefil に同梱してある fswiki2md が少し便利かもしれません。
|
154
|
+
|
155
|
+
|
156
|
+
<script>
|
157
|
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
158
|
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
159
|
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
160
|
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
161
|
+
|
162
|
+
ga('create', 'UA-68497868-1', 'auto');
|
163
|
+
ga('send', 'pageview');
|
164
|
+
</script>
|
165
|
+
|
166
|
+
|