RSTBuilder is a builder for reStructuredText (docutils.sourceforge.net/rst.html). reStructuredText is used in Sphinx (www.sphinx-doc.org/).
If you want to use `ruby`, `del` and `column`, you sould use sphinxcontrib-textstyle package (pypi.python.org/pypi/sphinxcontrib-textstyle).
RSTBuilder is a builder for reStructuredText (docutils.sourceforge.net/rst.html). reStructuredText is used in Sphinx (www.sphinx-doc.org/).
If you want to use `ruby`, `del` and `column`, you sould use sphinxcontrib-textstyle package (pypi.python.org/pypi/sphinxcontrib-textstyle).
# File ../../../../../lib/review/rstbuilder.rb, line 211 def base_block(type, lines, caption = nil) blank puts "#{compile_inline(caption)}" unless caption.nil? puts lines.join("\n") blank end
# File ../../../../../lib/review/rstbuilder.rb, line 218 def base_parablock(type, lines, caption = nil) puts ".. #{type}::" blank puts " #{compile_inline(caption)}" unless caption.nil? puts " " + split_paragraph(lines).join("\n") blank end
# File ../../../../../lib/review/rstbuilder.rb, line 600 def best(lines, caption = nil) base_parablock "best", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 748 def bibpaper_bibpaper(id, caption, lines) puts ".. [#{id}] #{compile_inline(caption)} #{split_paragraph(lines).join("")}" end
# File ../../../../../lib/review/rstbuilder.rb, line 745 def bibpaper_header(id, caption) end
# File ../../../../../lib/review/rstbuilder.rb, line 679 def bpo(lines) base_block "bpo", lines, nil end
# File ../../../../../lib/review/rstbuilder.rb, line 612 def caution(lines, caption = nil) base_parablock "caution", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 576 def centering(lines) base_parablock "centering", lines, nil end
# File ../../../../../lib/review/rstbuilder.rb, line 729 def circle_begin(level, label, caption) puts "・\t#{caption}" end
# File ../../../../../lib/review/rstbuilder.rb, line 733 def circle_end(level) end
# File ../../../../../lib/review/rstbuilder.rb, line 264 def cmd(lines, caption = nil) puts ".. code-block:: bash" lines.each do |line| puts " " + detab(line) end end
# File ../../../../../lib/review/rstbuilder.rb, line 508 def column_begin(level, label, caption) common_column_begin("column", caption) end
# File ../../../../../lib/review/rstbuilder.rb, line 512 def column_end(level) common_column_end("column") end
# File ../../../../../lib/review/rstbuilder.rb, line 354 def comment(lines, comment = nil) puts lines.map{|line| " .. #{line}"}.join("") end
# File ../../../../../lib/review/rstbuilder.rb, line 496 def common_column_begin(type, caption) blank puts ".. column:: #{compile_inline(caption)}" blank @in_role = true end
# File ../../../../../lib/review/rstbuilder.rb, line 503 def common_column_end(type) @in_role = false blank end
# File ../../../../../lib/review/rstbuilder.rb, line 378 def compile_href(url, label) label = url if label.blank? " `#{label} <#{url}>`_ " end
# File ../../../../../lib/review/rstbuilder.rb, line 371 def compile_kw(word, alt) if alt then " **#{word}(#{alt.strip})** " else " **#{word}** " end end
# File ../../../../../lib/review/rstbuilder.rb, line 367 def compile_ruby(base, ruby) " :ruby:`#{base}`<#{ruby}>`_ " end
# File ../../../../../lib/review/rstbuilder.rb, line 167 def dd(lines) split_paragraph(lines).each do |paragraph| puts " #{paragraph.gsub(/\n/, '')}" end end
# File ../../../../../lib/review/rstbuilder.rb, line 160 def dl_begin end
# File ../../../../../lib/review/rstbuilder.rb, line 173 def dl_end end
# File ../../../../../lib/review/rstbuilder.rb, line 163 def dt(line) puts "#{line}" end
# File ../../../../../lib/review/rstbuilder.rb, line 675 def dtp(str) # FIXME end
# File ../../../../../lib/review/rstbuilder.rb, line 540 def edition_begin(level, label, caption) common_column_begin("edition", caption) end
# File ../../../../../lib/review/rstbuilder.rb, line 544 def edition_end(level) common_column_end("edition") end
# File ../../../../../lib/review/rstbuilder.rb, line 226 def emlist(lines, caption = nil, lang = nil) blank if caption puts caption print "\n" end lang ||= "none" puts ".. code-block:: #{lang}" blank lines.each do |line| puts " " + detab(line) end blank end
# File ../../../../../lib/review/rstbuilder.rb, line 241 def emlistnum(lines, caption = nil, lang = nil) blank if caption puts caption print "\n" end lang ||= "none" puts ".. code-block:: #{lang}" puts " :linenos:" blank lines.each do |line| puts " " + detab(line) end blank end
# File ../../../../../lib/review/rstbuilder.rb, line 99 def error(msg) $stderr.puts "#{@location.filename}:#{@location.lineno}: error: #{msg}" end
# File ../../../../../lib/review/rstbuilder.rb, line 644 def expert(lines) base_parablock "expert", lines, nil end
# File ../../../../../lib/review/rstbuilder.rb, line 55 def extname '.rst' end
# File ../../../../../lib/review/rstbuilder.rb, line 572 def flushright(lines) base_parablock "flushright", lines, nil end
# File ../../../../../lib/review/rstbuilder.rb, line 358 def footnote(id, str) puts ".. [##{id.sub(" ", "_")}] #{compile_inline(str)}" blank end
# File ../../../../../lib/review/rstbuilder.rb, line 103 def headline(level, label, caption) blank if label puts ".. _#{label}:" blank end p = "=" case level when 1 then unless label puts ".. _#{@chapter.name}:" blank end puts "=" * caption.size * 2 when 2 then p = "=" when 3 then p = "-" when 4 then p = "`" when 5 then p = "~" end puts "#{caption}" puts p * caption.size * 2 blank end
# File ../../../../../lib/review/rstbuilder.rb, line 532 def hood_begin(level, label, caption) common_column_begin("hood", caption) end
# File ../../../../../lib/review/rstbuilder.rb, line 536 def hood_end(level) common_column_end("hood") end
# File ../../../../../lib/review/rstbuilder.rb, line 192 def hr puts "----" end
# File ../../../../../lib/review/rstbuilder.rb, line 300 def image_dummy(id, caption, lines) chapter, id = extract_chapter_id(id) puts ".. _#{id}:" blank puts ".. figure:: images/#{chapter.name}/#{id}.#{image_ext}" blank puts " #{caption}" puts " #{lines.join}" blank end
# File ../../../../../lib/review/rstbuilder.rb, line 51 def image_ext "png" end
# File ../../../../../lib/review/rstbuilder.rb, line 285 def image_image(id, caption, metric) chapter, id = extract_chapter_id(id) if metric scale = metric.split("=")[1].to_f * 100 end puts ".. _#{id}:" blank puts ".. figure:: images/#{chapter.name}/#{id}.#{image_ext}" puts " :scale:#{scale}%" if scale blank puts " #{caption}" blank end
# File ../../../../../lib/review/rstbuilder.rb, line 604 def important(lines, caption = nil) base_parablock "important", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 658 def indepimage(id, caption = "", metric = nil) chapter, id = extract_chapter_id(id) puts ".. _#{id}:" blank puts ".. figure:: images/#{chapter.name}/#{id}.#{image_ext}" blank puts " #{compile_inline(caption)}" blank end
# File ../../../../../lib/review/rstbuilder.rb, line 592 def info(lines, caption = nil) base_parablock "info", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 418 def inline_ami(str) # TODO: ami is not default role " :ami:`#{str}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 427 def inline_b(str) " **#{str.gsub(/\*/, '\*')}** " end
# File ../../../../../lib/review/rstbuilder.rb, line 460 def inline_balloon(str) %Q(\t←#{str.gsub(/@maru\[(\d+)\]/, inline_maru('\1'))}) end
# File ../../../../../lib/review/rstbuilder.rb, line 756 def inline_bib(id) " [#{id}]_ " end
# File ../../../../../lib/review/rstbuilder.rb, line 450 def inline_bou(str) # TODO: bou is not default role " :bou:`#{str}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 695 def inline_br(str) %Q(\n) end
# File ../../../../../lib/review/rstbuilder.rb, line 703 def inline_chap(id) super end
# File ../../../../../lib/review/rstbuilder.rb, line 707 def inline_chapref(id) " :numref:`#{id}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 691 def inline_code(str) " :code:`#{str}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 468 def inline_comment(str) if @book.config["draft"] "#{str}" else "" end end
# File ../../../../../lib/review/rstbuilder.rb, line 687 def inline_del(str) " :del:`str` " end
# File ../../../../../lib/review/rstbuilder.rb, line 683 def inline_dtp(str) "" end
# File ../../../../../lib/review/rstbuilder.rb, line 363 def inline_fn(id) " [##{id.sub(" ", "_")}]_ " end
# File ../../../../../lib/review/rstbuilder.rb, line 480 def inline_hd_chap(chap, id) " :ref:`#{id}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 414 def inline_hidx(str) " :index:`#{str}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 400 def inline_hint(str) # TODO: hint is not default role " :hint:`#{str}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 423 def inline_i(str) " *#{str.gsub(/\*/, '\*')}* " end
# File ../../../../../lib/review/rstbuilder.rb, line 446 def inline_icon(id) " :ref:`#{id}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 410 def inline_idx(str) " :index:`#{str}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 281 def inline_img(id) " :numref:`#{id}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 455 def inline_keytop(str) # TODO: keytop is not default role " :keytop:`#{str}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 720 def inline_labelref(idref) end
# File ../../../../../lib/review/rstbuilder.rb, line 196 def inline_list(id) " :numref:`#{id}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 476 def inline_m(str) " :math:`#{str}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 405 def inline_maru(str) # TODO: maru is not default role " :maru:`#{str}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 725 def inline_pageref(idref) " :ref:`#{idref}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 391 def inline_raw(str) matched = str.match(/\|(.*?)\|(.*)/) if matched matched[2].gsub("\\n", "\n") else str.gsub("\\n", "\n") end end
# File ../../../../../lib/review/rstbuilder.rb, line 387 def inline_sub(str) " :subscript:`str` " end
# File ../../../../../lib/review/rstbuilder.rb, line 383 def inline_sup(str) " :superscript:`str` " end
# File ../../../../../lib/review/rstbuilder.rb, line 277 def inline_table(id) "表 :numref:`#{id}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 433 def inline_tt(str) " ``#{str}`` " end
# File ../../../../../lib/review/rstbuilder.rb, line 715 def inline_ttibold(str) # TODO " **#{str}** " end
# File ../../../../../lib/review/rstbuilder.rb, line 442 def inline_u(str) " :subscript:`str` " end
# File ../../../../../lib/review/rstbuilder.rb, line 464 def inline_uchar(str) [str.to_i(16)].pack("U") end
# File ../../../../../lib/review/rstbuilder.rb, line 752 def inline_warn(str) " :warn:`#{str}` " end
# File ../../../../../lib/review/rstbuilder.rb, line 548 def insideout_begin(level, label, caption) common_column_begin("insideout", caption) end
# File ../../../../../lib/review/rstbuilder.rb, line 552 def insideout_end(level) common_column_end("insideout") end
# File ../../../../../lib/review/rstbuilder.rb, line 648 def insn(lines, caption = nil) base_block "insn", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 670 def label(id) puts ".. _#{id}:" blank end
# File ../../../../../lib/review/rstbuilder.rb, line 620 def link(lines, caption = nil) base_parablock "link", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 205 def list_body(id, lines, lang) lines.each do |line| puts '-' + detab(line) end end
# File ../../../../../lib/review/rstbuilder.rb, line 200 def list_header(id, caption, lang) puts ".. _#{id}:" blank end
# File ../../../../../lib/review/rstbuilder.rb, line 257 def listnum_body(lines, lang) lines.each_with_index do |line, i| puts(i + 1).to_s.rjust(2) + ": #{line}" end blank end
# File ../../../../../lib/review/rstbuilder.rb, line 584 def memo(lines, caption = nil) base_parablock "memo", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 736 def nofunc_text(str) str end
# File ../../../../../lib/review/rstbuilder.rb, line 484 def noindent # TODO end
# File ../../../../../lib/review/rstbuilder.rb, line 488 def nonum_begin(level, label, caption) puts ".. rubric: #{compile_inline(caption)}" blank end
# File ../../../../../lib/review/rstbuilder.rb, line 493 def nonum_end(level) end
# File ../../../../../lib/review/rstbuilder.rb, line 580 def note(lines, caption = nil) base_parablock "note", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 624 def notice(lines, caption = nil) base_parablock "notice", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 146 def ol_begin blank @ol_indent += 1 end
# File ../../../../../lib/review/rstbuilder.rb, line 155 def ol_end @ol_indent -= 1 blank end
# File ../../../../../lib/review/rstbuilder.rb, line 151 def ol_item(lines, num) puts " " * (@ol_indent - 1) + "#. #{lines.join}" end
# File ../../../../../lib/review/rstbuilder.rb, line 176 def paragraph(lines) pre = "" if @in_role == true pre = " " end puts pre + lines.join puts "\n" end
# File ../../../../../lib/review/rstbuilder.rb, line 596 def planning(lines, caption = nil) base_parablock "planning", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 628 def point(lines, caption = nil) base_parablock "point", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 47 def post_paragraph '' end
# File ../../../../../lib/review/rstbuilder.rb, line 640 def practice(lines) base_parablock "practice", lines, nil end
# File ../../../../../lib/review/rstbuilder.rb, line 43 def pre_paragraph '' end
# File ../../../../../lib/review/rstbuilder.rb, line 271 def quote(lines) blank puts lines.map{|line| " #{line}"}.join("") blank end
# File ../../../../../lib/review/rstbuilder.rb, line 185 def read(lines) puts split_paragraph(lines).map{|line| " #{line}"}.join("") blank end
# File ../../../../../lib/review/rstbuilder.rb, line 556 def ref_begin(level, label, caption) common_column_begin("ref", caption) end
# File ../../../../../lib/review/rstbuilder.rb, line 560 def ref_end(level) common_column_end("ref") end
# File ../../../../../lib/review/rstbuilder.rb, line 636 def reference(lines) base_parablock "reference", lines, nil end
# File ../../../../../lib/review/rstbuilder.rb, line 91 def result @output.string end
# File ../../../../../lib/review/rstbuilder.rb, line 608 def security(lines, caption = nil) base_parablock "security", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 632 def shoot(lines, caption = nil) base_parablock "shoot", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 711 def source(lines, caption = nil, lang = nil) base_block "source", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 564 def sup_begin(level, label, caption) common_column_begin("sup", caption) end
# File ../../../../../lib/review/rstbuilder.rb, line 568 def sup_end(level) common_column_end("sup") end
# File ../../../../../lib/review/rstbuilder.rb, line 327 def table_begin(ncols) end
# File ../../../../../lib/review/rstbuilder.rb, line 350 def table_end blank end
# File ../../../../../lib/review/rstbuilder.rb, line 318 def table_header(id, caption) blank puts ".. _#{id}:" blank puts ".. list-table:: #{compile_inline(caption)}" puts " :header-rows: 1" blank end
# File ../../../../../lib/review/rstbuilder.rb, line 346 def td(str) str end
# File ../../../../../lib/review/rstbuilder.rb, line 616 def term(lines) base_parablock "term", lines, nil end
# File ../../../../../lib/review/rstbuilder.rb, line 311 def texequation(lines) puts ".. math::" blank puts lines.map{|line| " #{line}"}.join("") blank end
# File ../../../../../lib/review/rstbuilder.rb, line 699 def text(str) str end
# File ../../../../../lib/review/rstbuilder.rb, line 342 def th(str) str end
# File ../../../../../lib/review/rstbuilder.rb, line 588 def tip(lines, caption = nil) base_parablock "tip", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 330 def tr(rows) first = true rows.each{|row| if first puts " * - #{row}" first = false else puts " - #{row}" end } end
# File ../../../../../lib/review/rstbuilder.rb, line 132 def ul_begin blank @ul_indent += 1 end
# File ../../../../../lib/review/rstbuilder.rb, line 141 def ul_end @ul_indent -= 1 blank end
# File ../../../../../lib/review/rstbuilder.rb, line 137 def ul_item(lines) puts " " * (@ul_indent - 1) + "* #{lines.join}" end
# File ../../../../../lib/review/rstbuilder.rb, line 95 def warn(msg) $stderr.puts "#{@location.filename}:#{@location.lineno}: warning: #{msg}" end
# File ../../../../../lib/review/rstbuilder.rb, line 652 def warning(lines, caption = nil) base_parablock "warning", lines, caption end
# File ../../../../../lib/review/rstbuilder.rb, line 524 def world_begin(level, label, caption) common_column_begin("world", caption) end
# File ../../../../../lib/review/rstbuilder.rb, line 528 def world_end(level) common_column_end("world") end
# File ../../../../../lib/review/rstbuilder.rb, line 516 def xcolumn_begin(level, label, caption) common_column_begin("xcolumn", caption) end
# File ../../../../../lib/review/rstbuilder.rb, line 520 def xcolumn_end(level) common_column_end("xcolumn") end