user guide: add warning when viewing markdown source file directly

This commit is contained in:
Josh Holtrop 2019-07-07 21:38:17 -04:00
parent b39fd80d8c
commit 4fd822fb95
2 changed files with 20 additions and 0 deletions

View File

@ -24,6 +24,15 @@ custom build operations as well.
Rscons is written in Ruby, and is inspired by [SCons](https://scons.org/) and [waf](https://waf.io/).
${remove}
WARNING: This user guide is meant to be preprocessed and rendered by a custom
script.
The markdown source file is not intended to be viewed directly and will not
include all intended content.
Visit [https://holtrop.github.io/rscons/index.html](https://holtrop.github.io/rscons/index.html)
to view the properly rendered version.
${/remove}
## Design Principles
### Build Correctness

View File

@ -59,6 +59,8 @@ class Generator
line = @lines.slice!(0)
if line =~ /^```(.*)$/
@sections.last.append(gather_code_section($1))
elsif line.chomp == "${remove}"
remove_section
elsif line =~ /^(#+)(>)?\s*(.*)$/
level_text, new_page_text, title_text = $1, $2, $3
level = $1.size
@ -196,6 +198,15 @@ class Generator
end
end
def remove_section
loop do
line = @lines.slice!(0)
if line.chomp == "${/remove}"
break
end
end
end
def get_next_section_number(level)
if @current_section_number.size == level - 1
@current_section_number << 1