user guide: implement section links
This commit is contained in:
parent
fcb686ac5f
commit
e4b96b759f
@ -77,8 +77,8 @@ source files.
|
|||||||
|
|
||||||
To use Rscons on your project, you must:
|
To use Rscons on your project, you must:
|
||||||
|
|
||||||
1. Install the `rscons` script in your project (See [#Installation]).
|
1. Install the `rscons` script in your project (See ${#Installation}).
|
||||||
2. Write the `Rsconscript` build script for your project (See [#The Build Script]).
|
2. Write the `Rsconscript` build script for your project (See ${#The Build Script}).
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
@ -418,7 +418,7 @@ found recursively under the `src` or `test` directory.
|
|||||||
|
|
||||||
Construction variables are values assigned to keys within an Environment.
|
Construction variables are values assigned to keys within an Environment.
|
||||||
Construction variables are used by Builders to produce output files.
|
Construction variables are used by Builders to produce output files.
|
||||||
See [#Default Construction Variables] for a reference of all built-in
|
See ${#Default Construction Variables} for a reference of all built-in
|
||||||
construction variables.
|
construction variables.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
@ -79,6 +79,11 @@ class Generator
|
|||||||
end
|
end
|
||||||
changelog = @markdown_renderer.render(File.read("CHANGELOG.md"))
|
changelog = @markdown_renderer.render(File.read("CHANGELOG.md"))
|
||||||
content.gsub!("${changelog}", changelog)
|
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")
|
template = File.read("rb/assets/user_guide.html.erb")
|
||||||
erb = ERB.new(template, nil, "<>")
|
erb = ERB.new(template, nil, "<>")
|
||||||
@ -92,6 +97,14 @@ class Generator
|
|||||||
"s" + ("#{section_number} #{section_title}").gsub(/[^a-zA-Z0-9]/, "_")
|
"s" + ("#{section_number} #{section_title}").gsub(/[^a-zA-Z0-9]/, "_")
|
||||||
end
|
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)
|
def gather_code_section(syntax)
|
||||||
code = ""
|
code = ""
|
||||||
loop do
|
loop do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user