Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
takahashim committed Aug 24, 2019
1 parent 37f81b3 commit 4ead5b7
Show file tree
Hide file tree
Showing 4 changed files with 441 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/review/book/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ def update_rubyenv
end
end

def make_indexes
unless catalog
return
end
parts.each do |part|
part.chapters.each(&:make_indexes)
end
end

def bib_file
config['bib_file']
end
Expand Down
6 changes: 6 additions & 0 deletions lib/review/book/chapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ def on_postdef?
on_file?(@book.read_postdef)
end

def make_indexes
index_builder = ReVIEW::IndexBuilder.new
compiler = ReVIEW::Compiler.new(index_builder)
compiler.compile(self)
end

private

def on_file?(contents)
Expand Down
10 changes: 10 additions & 0 deletions lib/review/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
require 'review/preprocessor'
require 'review/exception'
require 'review/location'
require 'review/index_builder'
require 'strscan'

module ReVIEW
Expand All @@ -26,6 +27,14 @@ def compile(chap)
@strategy.result
end

def make_indexes
# ignore when IndexBuilder
return if @strategy.target_name == 'index'

# make indexes for the book (not one chapter)
@chapter.book.make_indexes
end

class SyntaxElement
def initialize(name, type, argc, &block)
@name = name
Expand Down Expand Up @@ -218,6 +227,7 @@ def inline_defined?(name)
def do_compile
f = LineInput.new(StringIO.new(@chapter.content))
@strategy.bind(self, @chapter, Location.new(@chapter.basename, f))
make_indexes
tagged_section_init
while f.next?
case f.peek
Expand Down
Loading

0 comments on commit 4ead5b7

Please sign in to comment.