Module: PublishMyData::DocumentationHelper

Defined in:
app/helpers/publish_my_data/documentation_helper.rb

Instance Method Summary collapse

Instance Method Details

#codeblock(language, &block) ⇒ Object

generate a block level code element - if you want inline code just do whatever note that language isn’t used as yet



39
40
41
42
43
# File 'app/helpers/publish_my_data/documentation_helper.rb', line 39

def codeblock(language, &block)
   :code, class:"block #{language}" do
    capture &block
  end
end

#codeblock_pre(language, &block) ⇒ Object

generate a multiline block of code with indentation. eg

= codeblock_pre "c" do
  = preserve do
   :escaped
      void main(){
        ...indented code ...
      }

use codeblock(language, &block) if you don’t need to preserve whitespace



55
56
57
58
59
# File 'app/helpers/publish_my_data/documentation_helper.rb', line 55

def codeblock_pre(language, &block)
   :code, class:"block #{language} pre" do
    capture &block
  end
end


65
66
67
# File 'app/helpers/publish_my_data/documentation_helper.rb', line 65

def docs_inline_link(clickable,title)
  link_to clickable, "##{section_title_to_id(title)}"
end

#documentation_section(title, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/helpers/publish_my_data/documentation_helper.rb', line 4

def documentation_section(title, &block)
  # update global data structure
  if (@documentation_sections.nil?)
    @documentation_sections = Array.new()
  end
  @documentation_sections.push({name:title,subsections:[]})
  # output html
   :section, id:section_title_to_id(title) do
    concat  :h2, title
    concat capture &block
  end
end

#documentation_subsection(title, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'app/helpers/publish_my_data/documentation_helper.rb', line 17

def documentation_subsection(title, &block)
  # update global data structure
  @documentation_sections.last[:subsections].push({name:title,subsubsections:[]})
  # output html
   :div, class:"subsection", id:section_title_to_id(title) do
    concat  :h3, title
    concat capture &block
  end
end

#documentation_subsubsection(title, &block) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'app/helpers/publish_my_data/documentation_helper.rb', line 27

def documentation_subsubsection(title, &block)
  # update global data structure
  @documentation_sections.last[:subsections].last[:subsubsections].push({name:title,subsubsections:[]})
  # output html
   :div, class:"subsubsection", id:section_title_to_id(title) do
    concat  :h4, title
    concat capture &block
  end
end

#section_title_to_id(title) ⇒ Object



61
62
63
# File 'app/helpers/publish_my_data/documentation_helper.rb', line 61

def section_title_to_id(title)
  title.parameterize
end