doc: Run language ref through prep.js
This is so we can strip out support code needed to make the examples work, and as a bonus it does syntax highlighting.
This commit is contained in:
parent
57281f52e5
commit
0a347e760f
11
doc/prep.js
11
doc/prep.js
@ -40,7 +40,16 @@ var out = outfile ? fs.createWriteStream(outfile) : process.stdout;
|
||||
while ((line = lines[cur++]) != null) {
|
||||
if (/^~~~/.test(line)) {
|
||||
var block = "", bline;
|
||||
var isRust = !/notrust/.test(line);
|
||||
var notRust =
|
||||
/notrust/.test(line)
|
||||
// These are all used by the language ref to indicate things
|
||||
// that are not Rust source code
|
||||
|| /ebnf/.test(line)
|
||||
|| /abnf/.test(line)
|
||||
|| /keyword/.test(line)
|
||||
|| /field/.test(line)
|
||||
|| /precedence/.test(line);
|
||||
var isRust = !notRust;
|
||||
while ((bline = lines[cur++]) != null) {
|
||||
if (/^~~~/.test(bline)) break;
|
||||
if (!/^\s*##? /.test(bline)) block += bline + "\n";
|
||||
|
11
mk/docs.mk
11
mk/docs.mk
@ -12,20 +12,25 @@ ifeq ($(CFG_PANDOC),)
|
||||
$(info cfg: no pandoc found, omitting doc/rust.pdf)
|
||||
else
|
||||
|
||||
ifeq ($(CFG_NODE),)
|
||||
$(info cfg: no node found, omitting doc/tutorial.html)
|
||||
else
|
||||
|
||||
DOCS += doc/rust.html
|
||||
doc/rust.html: rust.md doc/version.md doc/keywords.md $(S)doc/rust.css
|
||||
@$(call E, pandoc: $@)
|
||||
$(Q)"$(CFG_PANDOC)" \
|
||||
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
|
||||
"$(CFG_PANDOC)" \
|
||||
--standalone --toc \
|
||||
--section-divs \
|
||||
--number-sections \
|
||||
--from=markdown --to=html \
|
||||
--css=rust.css \
|
||||
--output=$@ \
|
||||
$<
|
||||
--output=$@
|
||||
@$(call E, cp: $(S)doc/rust.css)
|
||||
-$(Q)cp -a $(S)doc/rust.css doc/rust.css 2> /dev/null
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(CFG_PDFLATEX),)
|
||||
$(info cfg: no pdflatex found, omitting doc/rust.pdf)
|
||||
|
Loading…
Reference in New Issue
Block a user