-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: move @doc_status
into compiler
#1701
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,14 +28,16 @@ def initialize(builder) | |
## to decide escaping/non-escaping for text | ||
@command_name_stack = [] | ||
|
||
@doc_status = nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. なるほどです、とりあえず上記の参照は追加しておきます。 |
||
|
||
@logger = ReVIEW.logger | ||
|
||
@ignore_errors = builder.is_a?(ReVIEW::IndexBuilder) | ||
|
||
@compile_errors = nil | ||
end | ||
|
||
attr_reader :builder, :previous_list_type | ||
attr_reader :builder, :previous_list_type, :doc_status | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 書きたいこともありそうなので、attr_accessorにしていただけると… There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ここで書きたいのはおそらく There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. そうですね。なるほど、ではこれはこのままでOKです |
||
|
||
def strategy | ||
error 'Compiler#strategy is obsoleted. Use Compiler#builder.' | ||
|
@@ -52,6 +54,7 @@ def non_escaped_commands | |
|
||
def compile(chap) | ||
@chapter = chap | ||
@doc_status = {} | ||
do_compile | ||
if @compile_errors | ||
raise ApplicationError, "#{location.filename} cannot be compiled." | ||
|
@@ -269,6 +272,18 @@ def inline_defined?(name) | |
definline :w | ||
definline :wb | ||
|
||
def in_minicolumn? | ||
@doc_status[:minicolumn] | ||
end | ||
|
||
def in_column? | ||
@doc_status[:column] | ||
end | ||
|
||
def in_dt? | ||
@doc_status[:dt] | ||
end | ||
|
||
private | ||
|
||
def do_compile | ||
|
@@ -362,6 +377,7 @@ def compile_minicolumn_begin(name, caption = nil) | |
return | ||
end | ||
@minicolumn_name = name | ||
@doc_status[:minicolumn] = name | ||
|
||
@builder.__send__(mid, caption) | ||
end | ||
|
@@ -375,6 +391,8 @@ def compile_minicolumn_end | |
|
||
mid = "#{name}_end" | ||
@builder.__send__(mid) | ||
|
||
@doc_status[:minicolumn] = nil | ||
@minicolumn_name = nil | ||
end | ||
|
||
|
@@ -443,12 +461,19 @@ def open_tagged_section(tag, level, label, caption) | |
return | ||
end | ||
@tagged_section.push([tag, level]) | ||
if tag == 'column' | ||
@doc_status[:column] = true | ||
end | ||
@builder.__send__(mid, level, label, caption) | ||
end | ||
|
||
def close_tagged_section(tag, level) | ||
mid = "#{tag}_end" | ||
if @builder.respond_to?(mid) | ||
if tag == 'column' | ||
@doc_status[:column] = nil | ||
end | ||
|
||
@builder.__send__(mid, level) | ||
else | ||
error "builder does not support block op: #{mid}", location: location | ||
|
@@ -523,9 +548,9 @@ def compile_dlist(f) | |
@builder.dl_begin | ||
while /\A\s*:/ =~ f.peek | ||
# defer compile_inline to handle footnotes | ||
@builder.doc_status[:dt] = true | ||
@doc_status[:dt] = true | ||
@builder.dt(text(f.gets.sub(/\A\s*:/, '').strip)) | ||
@builder.doc_status[:dt] = nil | ||
@doc_status[:dt] = nil | ||
desc = [] | ||
f.until_match(/\A(\S|\s*:|\s+\d+\.\s|\s+\*\s)/) do |line| | ||
desc << text(line.strip) | ||
|
@@ -553,9 +578,9 @@ def read_command(f) | |
ignore_inline = @non_parsed_commands.include?(name) | ||
@command_name_stack.push(name) | ||
args = parse_args(line.sub(%r{\A//[a-z]+}, '').rstrip.chomp('{'), name) | ||
@builder.doc_status[name] = true | ||
@doc_status[name] = true | ||
lines = block_open?(line) ? read_block(f, ignore_inline) : nil | ||
@builder.doc_status[name] = nil | ||
@doc_status[name] = nil | ||
[name, args, lines] | ||
end | ||
|
||
|
@@ -698,10 +723,6 @@ def compile_inline(str) | |
@builder.nofunc_text(str) | ||
end | ||
|
||
def in_minicolumn? | ||
@builder.in_minicolumn? | ||
end | ||
|
||
def minicolumn_block_name?(name) | ||
@builder.minicolumn_block_name?(name) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あ、もうしわけない。
builder側については私の手元のextをこのように直すほうで対処しますので、compilerのattrだけでOKです。ただし、(compilerのほうのコメントへ)