Skip to content

Commit 4fca7ca

Browse files
committed
Check the number of declared figures in each chapter
If the number of declared figures is greater that the number of available figures, processing errors occur while converting to html or pdf. The error messages are not obvious, so it is safer to catch the mistake before.
1 parent b8b947d commit 4fca7ca

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Rakefile

+22
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ namespace :ci do
176176
langs -= excluded_langs
177177
end
178178
error_code = false
179+
chapter_figure = {
180+
"01-introduction" => 7,
181+
"02-git-basics" => 2,
182+
"03-git-branching" => 39,
183+
"04-git-server" => 15,
184+
"05-distributed-git" => 27,
185+
"06-git-tools" => 1,
186+
"07-customizing-git" => 3,
187+
"08-git-and-other-scms" => 0,
188+
"09-git-internals" => 4}
179189
langs.each do |lang|
180190
print "processing #{lang} "
181191
mark = ''
@@ -185,6 +195,7 @@ namespace :ci do
185195
mark+= mk.read.encode("UTF-8")
186196
end
187197
src_file = File.open(mk_filename, 'r')
198+
figure_count = 0
188199
until src_file.eof?
189200
line = src_file.readline
190201
matches = line.match /^#/
@@ -194,6 +205,17 @@ namespace :ci do
194205
error_code = true
195206
end
196207
end
208+
if line.match /^\s*Insert\s(.*)/
209+
figure_count = figure_count + 1
210+
end
211+
end
212+
# This extraction is a bit contorted, because the pl translation renamed
213+
# the files, so the match is done on the directories.
214+
tab_fig_count = chapter_figure[File.basename(File.dirname(mk_filename))]
215+
expected_figure_count = tab_fig_count ? tab_fig_count:0
216+
if figure_count > expected_figure_count
217+
print "\nToo many figures declared in #{mk_filename}\n"
218+
error_code = true
197219
end
198220
end
199221
begin

0 commit comments

Comments
 (0)