From 0a347e760f4757fc75e63f005857c63894fc9e1e Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 20 Mar 2012 17:50:32 -0700 Subject: [PATCH] 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. --- doc/prep.js | 11 ++++++++++- mk/docs.mk | 11 ++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/doc/prep.js b/doc/prep.js index 89dfd5ef085..1cd5bec81b2 100755 --- a/doc/prep.js +++ b/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"; diff --git a/mk/docs.mk b/mk/docs.mk index 5efd5c4678e..8582b4c58e7 100644 --- a/mk/docs.mk +++ b/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) -- GitLab