Method: RDoc::Markup::PreProcess#include_file
- Defined in:
- lib/rdoc/markup/pre_process.rb
#include_file(name, indent, encoding) ⇒ Object
Handles the :include: filename
directive.
If the first line of the included file starts with ‘#’, and contains an encoding information in the form ‘coding:’ or ‘coding=’, it is removed.
If all lines in the included file start with a ‘#’, this leading ‘#’ is removed before inclusion. The included content is indented like the :include:
directive. – so all content will be verbatim because of the likely space after ‘#’? TODO shift left the whole file content in that case TODO comment stop/start #– and #++ in included file must be processed here
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/rdoc/markup/pre_process.rb', line 282 def include_file name, indent, encoding full_name = find_include_file name unless full_name then warn "Couldn't find file to include '#{name}' from #{@input_file_name}" return '' end content = RDoc::Encoding.read_file full_name, encoding, true content = RDoc::Encoding.remove_magic_comment content # strip magic comment content = content.sub(/\A# .*coding[=:].*$/, '').lstrip # strip leading '#'s, but only if all lines start with them if content =~ /^[^#]/ then content.gsub(/^/, indent) else content.gsub(/^#?/, indent) end end |