Class: Bookbinder::Subnav::JsonFromMarkdownToc

Inherits:
Object
  • Object
show all
Defined in:
lib/bookbinder/subnav/json_from_markdown_toc.rb

Constant Summary collapse

Class.new(RuntimeError)
Class.new(RuntimeError)
Class.new(RuntimeError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fs) ⇒ JsonFromMarkdownToc

Returns a new instance of JsonFromMarkdownToc.



12
13
14
15
# File 'lib/bookbinder/subnav/json_from_markdown_toc.rb', line 12

def initialize(fs)
  @fs = fs
  @renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



30
31
32
# File 'lib/bookbinder/subnav/json_from_markdown_toc.rb', line 30

def config
  @config
end

#fsObject (readonly)

Returns the value of attribute fs.



30
31
32
# File 'lib/bookbinder/subnav/json_from_markdown_toc.rb', line 30

def fs
  @fs
end

#rendererObject (readonly)

Returns the value of attribute renderer.



30
31
32
# File 'lib/bookbinder/subnav/json_from_markdown_toc.rb', line 30

def renderer
  @renderer
end

#source_for_site_genObject (readonly)

Returns the value of attribute source_for_site_gen.



30
31
32
# File 'lib/bookbinder/subnav/json_from_markdown_toc.rb', line 30

def source_for_site_gen
  @source_for_site_gen
end

Instance Method Details



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bookbinder/subnav/json_from_markdown_toc.rb', line 17

def get_links(product_config, output_locations)
  @source_for_site_gen = output_locations.source_for_site_generator
  @config = product_config

  root = absolute_source_from_path(Pathname(config.subnav_root))

  raise SubnavRootMissingError.new('Subnav root not found at: ' + config.subnav_root) if root.nil?

  @parsed_files = { Pathname(root) => '(root)'}

  {links: gather_urls_and_texts(root)}.to_json
end