user guide: implement section links
This commit is contained in:
1 parent
fcb686ac5f
commit
e4b96b759f
2 files changed
+16
-3
No files matched your search
@@ -79,6 +79,11 @@ class Generator
|
||||
end
|
||||
changelog = @markdown_renderer.render(File.read("CHANGELOG.md"))
|
||||
content.gsub!("${changelog}", changelog)
|
||||
content.gsub!(%r{\$\{#(.+?)\}}) do |match|
|
||||
section_name = $1
|
||||
href = get_link_to_section(section_name)
|
||||
%[<a href="#{href}">#{section_name}</a>]
|
||||
end
|
||||
|
||||
template = File.read("rb/assets/user_guide.html.erb")
|
||||
erb = ERB.new(template, nil, "<>")
|
||||
@@ -92,6 +97,14 @@ class Generator
|
||||
"s" + ("#{section_number} #{section_title}").gsub(/[^a-zA-Z0-9]/, "_")
|
||||
end
|
||||
|
||||
def get_link_to_section(section_name)
|
||||
section = @sections.find do |section|
|
||||
section.title == section_name
|
||||
end
|
||||
raise "Could not find section #{section_name}" unless section
|
||||
"#{section.page}##{section.anchor}"
|
||||
end
|
||||
|
||||
def gather_code_section(syntax)
|
||||
code = ""
|
||||
loop do
|
||||
|
||||
Reference in new issue
Block a user