From 862acedf514fe806d2ab7d337fc0e156faf1d7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20T=C3=A9tar?= Date: Sun, 9 Mar 2014 11:06:03 +0100 Subject: [PATCH 1/5] doc: remove node.js dependency `prep.js` outputs its own HTML directives, which `pandoc` cannot recognize when converting the document into LaTeX (this is why the PDF docs have never been highlighted as of now). Note that if we were to add the `.rust` class to snippets, we could probably use pandoc's native highlighting capatibilities i.e. Kate. --- configure | 1 - mk/docs.mk | 13 +- src/doc/README.md | 8 +- src/doc/lib/codemirror-node.js | 146 ----------- src/doc/lib/codemirror-rust.js | 453 --------------------------------- src/doc/prep.js | 87 ------- src/etc/licenseck.py | 2 - 7 files changed, 5 insertions(+), 705 deletions(-) delete mode 100644 src/doc/lib/codemirror-node.js delete mode 100644 src/doc/lib/codemirror-rust.js delete mode 100644 src/doc/prep.js diff --git a/configure b/configure index a69069183e7..873ff54722e 100755 --- a/configure +++ b/configure @@ -457,7 +457,6 @@ probe CFG_PANDOC pandoc probe CFG_PDFLATEX pdflatex probe CFG_XETEX xetex probe CFG_LUATEX luatex -probe CFG_NODE nodejs node probe CFG_GDB gdb if [ "$CFG_OSTYPE" = "unknown-linux-gnu" ] then diff --git a/mk/docs.mk b/mk/docs.mk index 00832e08216..58a62b47aa0 100644 --- a/mk/docs.mk +++ b/mk/docs.mk @@ -93,11 +93,6 @@ $(info cfg: no pandoc found, omitting PDF and EPUB docs) ONLY_HTML_DOCS = 1 endif -ifeq ($(CFG_NODE),) -$(info cfg: no node found, omitting PDF and EPUB docs) -ONLY_HTML_DOCS = 1 -endif - ###################################################################### # Rust version @@ -118,7 +113,7 @@ doc/version_info.html: $(D)/version_info.html.template $(MKFILE_DEPS) \ GENERATED += doc/version.md doc/version_info.html ###################################################################### -# Docs, from rustdoc and sometimes pandoc & node +# Docs, from rustdoc and sometimes pandoc ###################################################################### doc/: @@ -168,15 +163,13 @@ ifneq ($(ONLY_HTML_DOCS),1) DOC_TARGETS += doc/$(1).epub doc/$(1).epub: $$(D)/$(1).md | doc/ @$$(call E, pandoc: $$@) - $$(Q)$$(CFG_NODE) $$(D)/prep.js --highlight $$< | \ - $$(CFG_PANDOC) $$(PANDOC_EPUB_OPTS) --output=$$@ + $$(CFG_PANDOC) $$(PANDOC_EPUB_OPTS) $$< --output=$$@ # PDF (md =(pandoc)=> tex =(pdflatex)=> pdf) DOC_TARGETS += doc/$(1).tex doc/$(1).tex: $$(D)/$(1).md doc/footer.tex doc/version.md | doc/ @$$(call E, pandoc: $$@) - $$(Q)$$(CFG_NODE) $$(D)/prep.js $$< | \ - $$(CFG_PANDOC) $$(PANDOC_TEX_OPTS) --output=$$@ + $$(CFG_PANDOC) $$(PANDOC_TEX_OPTS) $$< --output=$$@ ifneq ($(NO_PDF_DOCS),1) ifeq ($$(SHOULD_BUILD_PDF_DOC_$(1)),1) diff --git a/src/doc/README.md b/src/doc/README.md index d76f25e4e3d..be0938022d2 100644 --- a/src/doc/README.md +++ b/src/doc/README.md @@ -4,10 +4,6 @@ document converter, is required to generate docs as HTML from Rust's source code. -[Node.js](http://nodejs.org/) is also required for generating HTML from -the Markdown docs (reference manual, tutorials, etc.) distributed with -this git repository. - [po4a](http://po4a.alioth.debian.org/) is required for generating translated docs from the master (English) docs. @@ -30,8 +26,8 @@ rustdoc --output-dir html-doc/ --output-format html ../src/libstd/path.rs # Additional notes -To generate an HTML version of a doc from Markdown without having Node.js -installed, you can do something like: +To generate an HTML version of a doc from Markdown manually, you can do +something like: ~~~~ pandoc --from=markdown --to=html5 --number-sections -o rust.html rust.md diff --git a/src/doc/lib/codemirror-node.js b/src/doc/lib/codemirror-node.js deleted file mode 100644 index 6818ae8b125..00000000000 --- a/src/doc/lib/codemirror-node.js +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (C) 2013 by Marijn Haverbeke and others -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -exports.htmlEscape = function(text) { - var replacements = {"<": "<", ">": ">", - "&": "&", "\"": """}; - return text.replace(/[<>&"]/g, function(character) { - return replacements[character]; - }); -}; - -exports.splitLines = function(string){return string.split(/\r?\n/);}; - -// Counts the column offset in a string, taking tabs into account. -// Used mostly to find indentation. -function countColumn(string, end) { - tabSize = 4; - if (end == null) { - end = string.search(/[^\s\u00a0]/); - if (end == -1) end = string.length; - } - for (var i = 0, n = 0; i < end; ++i) { - if (string.charAt(i) == "\t") n += tabSize - (n % tabSize); - else ++n; - } - return n; -} - -function StringStream(string) { - this.pos = this.start = 0; - this.string = string; -} -StringStream.prototype = { - eol: function() {return this.pos >= this.string.length;}, - sol: function() {return this.pos == 0;}, - peek: function() {return this.string.charAt(this.pos);}, - next: function() { - if (this.pos < this.string.length) - return this.string.charAt(this.pos++); - }, - eat: function(match) { - var ch = this.string.charAt(this.pos); - if (typeof match == "string") var ok = ch == match; - else var ok = ch && (match.test ? match.test(ch) : match(ch)); - if (ok) {++this.pos; return ch;} - }, - eatWhile: function(match) { - var start = this.pos; - while (this.eat(match)){} - return this.pos > start; - }, - eatSpace: function() { - var start = this.pos; - while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos; - return this.pos > start; - }, - skipToEnd: function() {this.pos = this.string.length;}, - skipTo: function(ch) { - var found = this.string.indexOf(ch, this.pos); - if (found > -1) {this.pos = found; return true;} - }, - backUp: function(n) {this.pos -= n;}, - column: function() {return countColumn(this.string, this.start);}, - indentation: function() {return countColumn(this.string);}, - match: function(pattern, consume, caseInsensitive) { - if (typeof pattern == "string") { - function cased(str) {return caseInsensitive ? str.toLowerCase() : str;} - if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) { - if (consume !== false) this.pos += pattern.length; - return true; - } - } - else { - var match = this.string.slice(this.pos).match(pattern); - if (match && consume !== false) this.pos += match[0].length; - return match; - } - }, - current: function(){return this.string.slice(this.start, this.pos);} -}; -exports.StringStream = StringStream; - -exports.startState = function(mode, a1, a2) { - return mode.startState ? mode.startState(a1, a2) : true; -}; - -var modes = {}, mimeModes = {}; -exports.defineMode = function(name, mode) { modes[name] = mode; }; -exports.defineMIME = function(mime, spec) { mimeModes[mime] = spec; }; -exports.getMode = function(options, spec) { - if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) - spec = mimeModes[spec]; - if (typeof spec == "string") - var mname = spec, config = {}; - else if (spec != null) - var mname = spec.name, config = spec; - var mfactory = modes[mname]; - if (!mfactory) throw new Error("Unknown mode: " + spec); - return mfactory(options, config || {}); -}; - -exports.runMode = function(string, modespec, callback) { - var mode = exports.getMode({indentUnit: 2}, modespec); - var isNode = callback.nodeType == 1; - if (isNode) { - var node = callback, accum = []; - callback = function(string, style) { - if (string == "\n") - accum.push("
"); - else if (style) - accum.push("" + - exports.htmlEscape(string) + ""); - else - accum.push(exports.htmlEscape(string)); - } - } - var lines = exports.splitLines(string), state = exports.startState(mode); - for (var i = 0, e = lines.length; i < e; ++i) { - if (i) callback("\n"); - var stream = new exports.StringStream(lines[i]); - while (!stream.eol()) { - var style = mode.token(stream, state); - callback(stream.current(), style, i, stream.start); - stream.start = stream.pos; - } - } - if (isNode) - node.innerHTML = accum.join(""); -}; diff --git a/src/doc/lib/codemirror-rust.js b/src/doc/lib/codemirror-rust.js deleted file mode 100644 index 7f933d6b82e..00000000000 --- a/src/doc/lib/codemirror-rust.js +++ /dev/null @@ -1,453 +0,0 @@ -// Copyright (C) 2013 by Marijn Haverbeke and others -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -CodeMirror.defineMode("rust", function() { - var indentUnit = 4, altIndentUnit = 2; - var valKeywords = { - "if": "if-style", "while": "if-style", "loop": "if-style", "else": "else-style", - "do": "else-style", "return": "else-style", - "break": "atom", "cont": "atom", "const": "let", "resource": "fn", - "let": "let", "fn": "fn", "for": "for", "match": "match", "trait": "trait", - "impl": "impl", "type": "type", "enum": "enum", "struct": "atom", "mod": "mod", - "as": "op", "true": "atom", "false": "atom", "assert": "op", "check": "op", - "claim": "op", "extern": "ignore", "unsafe": "ignore", "import": "else-style", - "export": "else-style", "copy": "op", "log": "op", - "use": "op", "self": "atom", "pub": "atom", "priv": "atom" - }; - var typeKeywords = function() { - var keywords = {"fn": "fn"}; - var atoms = "bool uint int i8 i16 i32 i64 u8 u16 u32 u64 float f32 f64 str char".split(" "); - for (var i = 0, e = atoms.length; i < e; ++i) keywords[atoms[i]] = "atom"; - return keywords; - }(); - var operatorChar = /[+\-*&%=<>!?|\.@]/; - - // Tokenizer - - // Used as scratch variable to communicate multiple values without - // consing up tons of objects. - var tcat, content; - function r(tc, style) { - tcat = tc; - return style; - } - - function tokenBase(stream, state) { - var ch = stream.next(); - if (ch == '"') { - state.tokenize = tokenString; - return state.tokenize(stream, state); - } - if (ch == "'") { - tcat = "atom"; - if (stream.eat("\\")) { - if (stream.skipTo("'")) { stream.next(); return "string"; } - else { return "error"; } - } else { - stream.next(); - return stream.eat("'") ? "string" : "error"; - } - } - if (ch == "/") { - if (stream.eat("/")) { stream.skipToEnd(); return "comment"; } - if (stream.eat("*")) { - state.tokenize = tokenComment(1); - return state.tokenize(stream, state); - } - } - if (ch == "#") { - if (stream.eat("[")) { tcat = "open-attr"; return null; } - stream.eatWhile(/\w/); - return r("macro", "meta"); - } - if (ch == ":" && stream.match(":<")) { - return r("op", null); - } - if (ch.match(/\d/) || (ch == "." && stream.eat(/\d/))) { - var flp = false; - if (!stream.match(/^x[\da-f]+/i) && !stream.match(/^b[01]+/)) { - stream.eatWhile(/\d/); - if (stream.eat(".")) { flp = true; stream.eatWhile(/\d/); } - if (stream.match(/^e[+\-]?\d+/i)) { flp = true; } - } - if (flp) stream.match(/^f(?:32|64)/); - else stream.match(/^[ui](?:8|16|32|64)/); - return r("atom", "number"); - } - if (ch.match(/[()\[\]{}:;,]/)) return r(ch, null); - if (ch == "-" && stream.eat(">")) return r("->", null); - if (ch.match(operatorChar)) { - stream.eatWhile(operatorChar); - return r("op", null); - } - stream.eatWhile(/\w/); - content = stream.current(); - if (stream.match(/^::\w/)) { - stream.backUp(1); - return r("prefix", "variable-2"); - } - if (state.keywords.propertyIsEnumerable(content)) - return r(state.keywords[content], content.match(/true|false/) ? "atom" : "keyword"); - return r("name", "variable"); - } - - function tokenString(stream, state) { - var ch, escaped = false; - while (ch = stream.next()) { - if (ch == '"' && !escaped) { - state.tokenize = tokenBase; - return r("atom", "string"); - } - escaped = !escaped && ch == "\\"; - } - // Hack to not confuse the parser when a string is split in - // pieces. - return r("op", "string"); - } - - function tokenComment(depth) { - return function(stream, state) { - var lastCh = null, ch; - while (ch = stream.next()) { - if (ch == "/" && lastCh == "*") { - if (depth == 1) { - state.tokenize = tokenBase; - break; - } else { - state.tokenize = tokenComment(depth - 1); - return state.tokenize(stream, state); - } - } - if (ch == "*" && lastCh == "/") { - state.tokenize = tokenComment(depth + 1); - return state.tokenize(stream, state); - } - lastCh = ch; - } - return "comment"; - }; - } - - // Parser - - var cx = {state: null, stream: null, marked: null, cc: null}; - function pass() { - for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]); - } - function cont() { - pass.apply(null, arguments); - return true; - } - - function pushlex(type, info) { - var result = function() { - var state = cx.state; - state.lexical = {indented: state.indented, column: cx.stream.column(), - type: type, prev: state.lexical, info: info}; - }; - result.lex = true; - return result; - } - function poplex() { - var state = cx.state; - if (state.lexical.prev) { - if (state.lexical.type == ")") - state.indented = state.lexical.indented; - state.lexical = state.lexical.prev; - } - } - function typecx() { cx.state.keywords = typeKeywords; } - function valcx() { cx.state.keywords = valKeywords; } - poplex.lex = typecx.lex = valcx.lex = true; - - function commasep(comb, end) { - function more(type) { - if (type == ",") return cont(comb, more); - if (type == end) return cont(); - return cont(more); - } - return function(type) { - if (type == end) return cont(); - return pass(comb, more); - }; - } - - function stat_of(comb, tag) { - return cont(pushlex("stat", tag), comb, poplex, block); - } - function block(type) { - if (type == "}") return cont(); - if (type == "let") return stat_of(letdef1, "let"); - if (type == "fn") return stat_of(fndef); - if (type == "type") return cont(pushlex("stat"), tydef, endstatement, poplex, block); - if (type == "enum") return stat_of(tagdef); - if (type == "mod") return stat_of(mod); - if (type == "trait") return stat_of(trait); - if (type == "impl") return stat_of(impl); - if (type == "open-attr") return cont(pushlex("]"), commasep(expression, "]"), poplex); - if (type == "ignore" || type.match(/[\]\);,]/)) return cont(block); - return pass(pushlex("stat"), expression, poplex, endstatement, block); - } - function endstatement(type) { - if (type == ";") return cont(); - return pass(); - } - function expression(type) { - if (type == "atom" || type == "name") return cont(maybeop); - if (type == "{") return cont(pushlex("}"), exprbrace, poplex); - if (type.match(/[\[\(]/)) return matchBrackets(type, expression); - if (type.match(/[\]\)\};,]/)) return pass(); - if (type == "if-style") return cont(expression, expression); - if (type == "else-style" || type == "op") return cont(expression); - if (type == "for") return cont(pattern, maybetype, inop, expression, expression); - if (type == "match") return cont(expression, altbody); - if (type == "fn") return cont(fndef); - if (type == "macro") return cont(macro); - return cont(); - } - function maybeop(type) { - if (content == ".") return cont(maybeprop); - if (content == "::<"){return cont(typarams, maybeop);} - if (type == "op" || content == ":") return cont(expression); - if (type == "(" || type == "[") return matchBrackets(type, expression); - return pass(); - } - function maybeprop(type) { - if (content.match(/^\w+$/)) {cx.marked = "variable"; return cont(maybeop);} - return pass(expression); - } - function exprbrace(type) { - if (type == "op") { - if (content == "|") return cont(blockvars, poplex, pushlex("}", "block"), block); - if (content == "||") return cont(poplex, pushlex("}", "block"), block); - } - if (content == "mut" || (content.match(/^\w+$/) && cx.stream.peek() == ":" - && !cx.stream.match("::", false))) - return pass(record_of(expression)); - return pass(block); - } - function record_of(comb) { - function ro(type) { - if (content == "mut" || content == "with") {cx.marked = "keyword"; return cont(ro);} - if (content.match(/^\w*$/)) {cx.marked = "variable"; return cont(ro);} - if (type == ":") return cont(comb, ro); - if (type == "}") return cont(); - return cont(ro); - } - return ro; - } - function blockvars(type) { - if (type == "name") {cx.marked = "def"; return cont(blockvars);} - if (type == "op" && content == "|") return cont(); - return cont(blockvars); - } - - function letdef1(type) { - if (type.match(/[\]\)\};]/)) return cont(); - if (content == "=") return cont(expression, letdef2); - if (type == ",") return cont(letdef1); - return pass(pattern, maybetype, letdef1); - } - function letdef2(type) { - if (type.match(/[\]\)\};,]/)) return pass(letdef1); - else return pass(expression, letdef2); - } - function maybetype(type) { - if (type == ":") return cont(typecx, rtype, valcx); - return pass(); - } - function inop(type) { - if (type == "name" && content == "in") {cx.marked = "keyword"; return cont();} - return pass(); - } - function fndef(type) { - if (content == "@" || content == "~") {cx.marked = "keyword"; return cont(fndef);} - if (type == "name") {cx.marked = "def"; return cont(fndef);} - if (content == "<") return cont(typarams, fndef); - if (type == "{") return pass(expression); - if (type == "(") return cont(pushlex(")"), commasep(argdef, ")"), poplex, fndef); - if (type == "->") return cont(typecx, rtype, valcx, fndef); - if (type == ";") return cont(); - return cont(fndef); - } - function tydef(type) { - if (type == "name") {cx.marked = "def"; return cont(tydef);} - if (content == "<") return cont(typarams, tydef); - if (content == "=") return cont(typecx, rtype, valcx); - return cont(tydef); - } - function tagdef(type) { - if (type == "name") {cx.marked = "def"; return cont(tagdef);} - if (content == "<") return cont(typarams, tagdef); - if (content == "=") return cont(typecx, rtype, valcx, endstatement); - if (type == "{") return cont(pushlex("}"), typecx, tagblock, valcx, poplex); - return cont(tagdef); - } - function tagblock(type) { - if (type == "}") return cont(); - if (type == "(") return cont(pushlex(")"), commasep(rtype, ")"), poplex, tagblock); - if (content.match(/^\w+$/)) cx.marked = "def"; - return cont(tagblock); - } - function mod(type) { - if (type == "name") {cx.marked = "def"; return cont(mod);} - if (type == "{") return cont(pushlex("}"), block, poplex); - return pass(); - } - function trait(type) { - if (type == "name") {cx.marked = "def"; return cont(trait);} - if (content == "<") return cont(typarams, trait); - if (type == "{") return cont(pushlex("}"), block, poplex); - return pass(); - } - function impl(type) { - if (content == "<") return cont(typarams, impl); - if (content == "of" || content == "for") {cx.marked = "keyword"; return cont(rtype, impl);} - if (type == "name") {cx.marked = "def"; return cont(impl);} - if (type == "{") return cont(pushlex("}"), block, poplex); - return pass(); - } - function typarams(type) { - if (content == ">") return cont(); - if (content == ",") return cont(typarams); - if (content == ":") return cont(rtype, typarams); - return pass(rtype, typarams); - } - function argdef(type) { - if (type == "name") {cx.marked = "def"; return cont(argdef);} - if (type == ":") return cont(typecx, rtype, valcx); - return pass(); - } - function rtype(type) { - if (type == "name") {cx.marked = "variable-3"; return cont(rtypemaybeparam); } - if (content == "mut") {cx.marked = "keyword"; return cont(rtype);} - if (type == "atom") return cont(rtypemaybeparam); - if (type == "op" || type == "obj") return cont(rtype); - if (type == "fn") return cont(fntype); - if (type == "{") return cont(pushlex("{"), record_of(rtype), poplex); - return matchBrackets(type, rtype); - } - function rtypemaybeparam(type) { - if (content == "<") return cont(typarams); - return pass(); - } - function fntype(type) { - if (type == "(") return cont(pushlex("("), commasep(rtype, ")"), poplex, fntype); - if (type == "->") return cont(rtype); - return pass(); - } - function pattern(type) { - if (type == "name") {cx.marked = "def"; return cont(patternmaybeop);} - if (type == "atom") return cont(patternmaybeop); - if (type == "op") return cont(pattern); - if (type.match(/[\]\)\};,]/)) return pass(); - return matchBrackets(type, pattern); - } - function patternmaybeop(type) { - if (type == "op" && content == ".") return cont(); - if (content == "to") {cx.marked = "keyword"; return cont(pattern);} - else return pass(); - } - function altbody(type) { - if (type == "{") return cont(pushlex("}", "match"), altblock1, poplex); - return pass(); - } - function altblock1(type) { - if (type == "}") return cont(); - if (type == "|") return cont(altblock1); - if (content == "when") {cx.marked = "keyword"; return cont(expression, altblock2);} - if (type.match(/[\]\);,]/)) return cont(altblock1); - return pass(pattern, altblock2); - } - function altblock2(type) { - if (type == "{") return cont(pushlex("}", "match"), block, poplex, altblock1); - else return pass(altblock1); - } - - function macro(type) { - if (type.match(/[\[\(\{]/)) return matchBrackets(type, expression); - return pass(); - } - function matchBrackets(type, comb) { - if (type == "[") return cont(pushlex("]"), commasep(comb, "]"), poplex); - if (type == "(") return cont(pushlex(")"), commasep(comb, ")"), poplex); - if (type == "{") return cont(pushlex("}"), commasep(comb, "}"), poplex); - return cont(); - } - - function parse(state, stream, style) { - var cc = state.cc; - // Communicate our context to the combinators. - // (Less wasteful than consing up a hundred closures on every call.) - cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; - - while (true) { - var combinator = cc.length ? cc.pop() : block; - if (combinator(tcat)) { - while(cc.length && cc[cc.length - 1].lex) - cc.pop()(); - return cx.marked || style; - } - } - } - - return { - startState: function() { - return { - tokenize: tokenBase, - cc: [], - lexical: {indented: -indentUnit, column: 0, type: "top", align: false}, - keywords: valKeywords, - indented: 0 - }; - }, - - token: function(stream, state) { - if (stream.sol()) { - if (!state.lexical.hasOwnProperty("align")) - state.lexical.align = false; - state.indented = stream.indentation(); - } - if (stream.eatSpace()) return null; - tcat = content = null; - var style = state.tokenize(stream, state); - if (style == "comment") return style; - if (!state.lexical.hasOwnProperty("align")) - state.lexical.align = true; - if (tcat == "prefix") return style; - if (!content) content = stream.current(); - return parse(state, stream, style); - }, - - indent: function(state, textAfter) { - if (state.tokenize != tokenBase) return 0; - var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, - type = lexical.type, closing = firstChar == type; - if (type == "stat") return lexical.indented + indentUnit; - if (lexical.align) return lexical.column + (closing ? 0 : 1); - return lexical.indented + - (closing ? 0 : (lexical.info == "match" ? altIndentUnit : indentUnit)); - }, - - electricChars: "{}" - }; -}); - -CodeMirror.defineMIME("text/x-rustsrc", "rust"); diff --git a/src/doc/prep.js b/src/doc/prep.js deleted file mode 100644 index 850a0bc7db7..00000000000 --- a/src/doc/prep.js +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/local/bin/node - -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/*** - * Pandoc-style markdown preprocessor that drops extra directives - * included for running doc code, and that optionally, when - * --highlight is provided, replaces code blocks that are Rust code - * with highlighted HTML blocks. The directives recognized are: - * - * '## ignore' tells the test extractor (extract-tests.js) to ignore - * the block completely. - * '## notrust' makes the test extractor ignore the block, makes - * this script not highlight the block. - * '# [any text]' is a line that is stripped out by this script, and - * converted to a normal line of code (without the leading #) by - * the test extractor. - */ - -var fs = require("fs"); -CodeMirror = require("./lib/codemirror-node"); -require("./lib/codemirror-rust"); - -function help() { - console.log("usage: " + process.argv[0] + " [--highlight] [-o outfile] [infile]"); - process.exit(1); -} - -var highlight = false, infile, outfile; - -for (var i = 2; i < process.argv.length; ++i) { - var arg = process.argv[i]; - if (arg == "--highlight") highlight = true; - else if (arg == "-o" && outfile == null && ++i < process.argv.length) outfile = process.argv[i]; - else if (arg[0] != "-") infile = arg; - else help(); -} - -var lines = fs.readFileSync(infile || "/dev/stdin").toString().split(/\n\r?/g), cur = 0, line; -var out = outfile ? fs.createWriteStream(outfile) : process.stdout; - -while ((line = lines[cur++]) != null) { - if (/^~~~/.test(line)) { - var block = "", bline; - 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"; - } - if (!highlight || !isRust) - out.write(line + "\n" + block + bline + "\n"); - else { - var html = '
', curstr = "", curstyle = null;
-      function add(str, style) {
-        if (style != curstyle) {
-          if (curstyle) html +=
-            '' +
-            CodeMirror.htmlEscape(curstr) + "";
-          else if (curstr) html += CodeMirror.htmlEscape(curstr);
-          curstr = str; curstyle = style;
-        } else curstr += str;
-      }
-      CodeMirror.runMode(block, "rust", add);
-      add("", "bogus"); // Flush pending string.
-      out.write(html + "
\n"); - } - } else { - out.write(line + "\n"); - } -} diff --git a/src/etc/licenseck.py b/src/etc/licenseck.py index ec4c60c21ee..1e599125e89 100644 --- a/src/etc/licenseck.py +++ b/src/etc/licenseck.py @@ -33,8 +33,6 @@ license4 = """ The Rust Project Developers. See the COPYRIGHT """ exceptions = [ - "doc/lib/codemirror-node.js", # MIT - "doc/lib/codemirror-rust.js", # MIT "rt/rust_android_dummy.cpp", # BSD, chromium "rt/rust_android_dummy.h", # BSD, chromium "rt/isaac/randport.cpp", # public domain From 9eadcacdd76d12c72284ddc122625488f297dea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20T=C3=A9tar?= Date: Sun, 9 Mar 2014 11:21:05 +0100 Subject: [PATCH 2/5] doc: have a real switch b/w LaTeX compilers --- configure | 4 ++-- mk/docs.mk | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/configure b/configure index 873ff54722e..f470fd6f26c 100755 --- a/configure +++ b/configure @@ -455,8 +455,8 @@ probe CFG_ISCC iscc probe CFG_LLNEXTGEN LLnextgen probe CFG_PANDOC pandoc probe CFG_PDFLATEX pdflatex -probe CFG_XETEX xetex -probe CFG_LUATEX luatex +probe CFG_XELATEX xelatex +probe CFG_LUALATEX lualatex probe CFG_GDB gdb if [ "$CFG_OSTYPE" = "unknown-linux-gnu" ] then diff --git a/mk/docs.mk b/mk/docs.mk index 58a62b47aa0..7a8dfd2d58f 100644 --- a/mk/docs.mk +++ b/mk/docs.mk @@ -73,18 +73,20 @@ endif # Check for the various external utilities for the EPUB/PDF docs: ifeq ($(CFG_PDFLATEX),) - $(info cfg: no pdflatex found, omitting doc/rust.pdf) - NO_PDF_DOCS = 1 -else - ifeq ($(CFG_XETEX),) - $(info cfg: no xetex found, disabling doc/rust.pdf) - NO_PDF_DOCS = 1 + $(info cfg: no pdflatex found, deferring to xelatex) + ifeq ($(CFG_XELATEX),) + $(info cfg: no xelatex found, deferring to lualatex) + ifeq ($(CFG_LUALATEX),) + $(info cfg: no lualatex found, disabling LaTeX docs) + NO_PDF_DOCS = 1 + else + CFG_LATEX := $(CFG_LUALATEX) + endif else - ifeq ($(CFG_LUATEX),) - $(info cfg: lacking luatex, disabling pdflatex) - NO_PDF_DOCS = 1 - endif + CFG_LATEX := $(CFG_XELATEX) endif +else + CFG_LATEX := $(CFG_PDFLATEX) endif @@ -175,8 +177,8 @@ ifneq ($(NO_PDF_DOCS),1) ifeq ($$(SHOULD_BUILD_PDF_DOC_$(1)),1) DOC_TARGETS += doc/$(1).pdf doc/$(1).pdf: doc/$(1).tex - @$$(call E, pdflatex: $$@) - $$(Q)$$(CFG_PDFLATEX) \ + @$$(call E, latex compiler: $$@) + $$(Q)$$(CFG_LATEX) \ -interaction=batchmode \ -output-directory=doc \ $$< From 7979ae53678e6d1a1f8455ee543986498afa270f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20T=C3=A9tar?= Date: Sun, 9 Mar 2014 12:29:25 +0100 Subject: [PATCH 3/5] doc: CSS fixes - fixup and refactor highlighting code - have a proper print stylesheet --- src/doc/rust.css | 34 ++++++++++++++++++++--------- src/librustdoc/html/static/main.css | 17 ++++++--------- src/librustdoc/markdown.rs | 2 +- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/doc/rust.css b/src/doc/rust.css index 26681adad6d..c69b59855a7 100644 --- a/src/doc/rust.css +++ b/src/doc/rust.css @@ -75,6 +75,14 @@ p { margin: 0 0 10px; } +strong { + font-weight: bold; +} + +em { + font-style: italic; +} + footer { border-top: 1px solid #ddd; font-size: 12px; @@ -107,6 +115,8 @@ a:hover, a:active { h1 a:link, h1 a:visited, h2 a:link, h2 a:visited, h3 a:link, h3 a:visited, h4 a:link, h4 a:visited, h5 a:link, h5 a:visited {color: black;} +h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, +h5 a:hover {text-decoration: none;} /* Code ========================================================================== */ @@ -144,16 +154,14 @@ pre code { /* Code highlighting */ pre.rust .kw { color: #8959A8; } pre.rust .kw-2, pre.rust .prelude-ty { color: #4271AE; } -pre.rust .number { color: #718C00; } -pre.rust .self { color: #C13928; } -pre.rust .boolval { color: #C13928; } -pre.rust .prelude-val { color: #C13928; } +pre.rust .number, pre.rust .string { color: #718C00; } +pre.rust .self, pre.rust .boolval, pre.rust .prelude-val, +pre.rust .attribute, pre.rust .attribute .ident { color: #C82829; } pre.rust .comment { color: #8E908C; } pre.rust .doccomment { color: #4D4D4C; } -pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999f; } -pre.rust .string { color: #718C00; } -pre.rust .lifetime { color: #C13928; } -pre.rust .attribute, pre.rust .attribute .ident { color: #C82829; } +pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999F; } +pre.rust .lifetime { color: #B76514; } + /* The rest ========================================================================== */ @@ -162,7 +170,7 @@ pre.rust .attribute, pre.rust .attribute .ident { color: #C82829; } margin: 0.5em; font-size: 1.1em; } -@media (min-width: 768px) { +@media only screen, handheld and (min-width: 768px) { #versioninfo { position: fixed; bottom: 0px; @@ -262,9 +270,12 @@ table th { a, a:visited { text-decoration: underline; } - a[href]:after { + p a[href]:after { content: " (" attr(href) ")"; } + footer a[href]:after { + content: ""; + } a[href^="javascript:"]:after, a[href^="#"]:after { content: ""; } @@ -275,6 +286,9 @@ table th { @page { margin: 2cm .5cm; } + h1:not(.title), h2, h3 { + border-bottom: 0px none; + } p, h2, h3 { orphans: 3; widows: 3; diff --git a/src/librustdoc/html/static/main.css b/src/librustdoc/html/static/main.css index 0efee51a219..f2c10f053c2 100644 --- a/src/librustdoc/html/static/main.css +++ b/src/librustdoc/html/static/main.css @@ -126,7 +126,7 @@ nav.sub { .content pre.line-numbers { float: left; border: none; } .line-numbers span { color: #c67e2d; } .line-numbers .line-highlighted { - background-color: #fff871; + background-color: #f6fdb0; } .content .highlighted { @@ -306,19 +306,16 @@ a { pre.rust, pre.line-numbers { background-color: #FDFDFD; } -/* Code Highlighting */ +/* Code highlighting */ pre.rust .kw { color: #8959A8; } pre.rust .kw-2, pre.rust .prelude-ty { color: #4271AE; } -pre.rust .number { color: #718C00; } -pre.rust .self { color: #C13928; } -pre.rust .boolval { color: #C13928; } -pre.rust .prelude-val { color: #C13928; } +pre.rust .number, pre.rust .string { color: #718C00; } +pre.rust .self, pre.rust .boolval, pre.rust .prelude-val, +pre.rust .attribute, pre.rust .attribute .ident { color: #C82829; } pre.rust .comment { color: #8E908C; } pre.rust .doccomment { color: #4D4D4C; } -pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999f; } -pre.rust .string { color: #718C00; } -pre.rust .lifetime { color: #C13928; } -pre.rust .attribute, pre.rust .attribute .ident { color: #C82829; } +pre.rust .macro, pre.rust .macro-nonterminal { color: #3E999F; } +pre.rust .lifetime { color: #B76514; } h1:hover a:after, h2:hover a:after, diff --git a/src/librustdoc/markdown.rs b/src/librustdoc/markdown.rs index 5d8e0008b87..7ab3fe017b9 100644 --- a/src/librustdoc/markdown.rs +++ b/src/librustdoc/markdown.rs @@ -117,7 +117,7 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches) -> int let err = write!( &mut out, - r#" + r#" From 7ec1eb8ab373ad5dfd3d9229c6f89a02424d2b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20T=C3=A9tar?= Date: Sun, 9 Mar 2014 12:41:27 +0100 Subject: [PATCH 4/5] doc: auto-generate LaTeX includes --- mk/docs.mk | 16 ++++++++-------- src/doc/footer.tex | 7 ------- 2 files changed, 8 insertions(+), 15 deletions(-) delete mode 100644 src/doc/footer.tex diff --git a/mk/docs.mk b/mk/docs.mk index 7a8dfd2d58f..236af406bc6 100644 --- a/mk/docs.mk +++ b/mk/docs.mk @@ -46,7 +46,7 @@ RUSTDOC_HTML_OPTS = --markdown-css rust.css \ --markdown-in-header=doc/favicon.inc --markdown-after-content=doc/footer.inc PANDOC_BASE_OPTS := --standalone --toc --number-sections -PANDOC_TEX_OPTS = $(PANDOC_BASE_OPTS) --include-before-body=doc/version.md \ +PANDOC_TEX_OPTS = $(PANDOC_BASE_OPTS) --include-before-body=doc/version.tex \ --from=markdown --include-before-body=doc/footer.tex --to=latex PANDOC_EPUB_OPTS = $(PANDOC_BASE_OPTS) --to=epub @@ -100,7 +100,7 @@ endif # Rust version ###################################################################### -doc/version.md: $(MKFILE_DEPS) $(wildcard $(D)/*.*) | doc/ +doc/version.tex: $(MKFILE_DEPS) $(wildcard $(D)/*.*) | doc/ @$(call E, version-stamp: $@) $(Q)echo "$(CFG_VERSION)" >$@ @@ -112,7 +112,7 @@ doc/version_info.html: $(D)/version_info.html.template $(MKFILE_DEPS) \ $(CFG_VER_HASH) | head -c 8)/;\ s/STAMP/$(CFG_VER_HASH)/;" $< >$@ -GENERATED += doc/version.md doc/version_info.html +GENERATED += doc/version.tex doc/version_info.html ###################################################################### # Docs, from rustdoc and sometimes pandoc @@ -140,10 +140,6 @@ doc/footer.inc: $(D)/footer.inc | doc/ @$(call E, cp: $@) $(Q)cp -a $< $@ 2> /dev/null -doc/footer.tex: $(D)/footer.tex | doc/ - @$(call E, cp: $@) - $(Q)cp -a $< $@ 2> /dev/null - # The (english) documentation for each doc item. define DEF_SHOULD_BUILD_PDF_DOC @@ -167,9 +163,13 @@ doc/$(1).epub: $$(D)/$(1).md | doc/ @$$(call E, pandoc: $$@) $$(CFG_PANDOC) $$(PANDOC_EPUB_OPTS) $$< --output=$$@ +doc/footer.tex: $(D)/footer.inc | doc/ + @$$(call E, pandoc: $$@) + $$(CFG_PANDOC) --from=html --to=latex $$< --output=$$@ + # PDF (md =(pandoc)=> tex =(pdflatex)=> pdf) DOC_TARGETS += doc/$(1).tex -doc/$(1).tex: $$(D)/$(1).md doc/footer.tex doc/version.md | doc/ +doc/$(1).tex: $$(D)/$(1).md doc/footer.tex doc/version.tex | doc/ @$$(call E, pandoc: $$@) $$(CFG_PANDOC) $$(PANDOC_TEX_OPTS) $$< --output=$$@ diff --git a/src/doc/footer.tex b/src/doc/footer.tex deleted file mode 100644 index 9f9ceb6ba9a..00000000000 --- a/src/doc/footer.tex +++ /dev/null @@ -1,7 +0,0 @@ -Copyright © 2011-2014 The Rust Project Developers. Licensed under the -\href{http://www.apache.org/licenses/LICENSE-2.0}{Apache License, -Version 2.0} or the \href{http://opensource.org/licenses/MIT}{MIT -license}, at your option. - -This file may not be copied, modified, or distributed except according -to those terms. From 840a2701accbaeb6d4537db79e47150313c74d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20T=C3=A9tar?= Date: Sun, 9 Mar 2014 13:52:16 +0100 Subject: [PATCH 5/5] doc: remove outdated tutorial entry, restore removed Makefile entries --- mk/docs.mk | 6 +++--- src/doc/tutorial.md | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/mk/docs.mk b/mk/docs.mk index 236af406bc6..703c0f44461 100644 --- a/mk/docs.mk +++ b/mk/docs.mk @@ -27,9 +27,9 @@ # translated. ###################################################################### DOCS := index tutorial guide-ffi guide-macros guide-lifetimes \ - guide-tasks guide-container guide-pointers \ - complement-cheatsheet guide-runtime \ - rust rustdoc + guide-tasks guide-container guide-pointers guide-testing \ + guide-runtime complement-bugreport complement-cheatsheet \ + complement-lang-faq complement-project-faq rust rustdoc PDF_DOCS := tutorial rust diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index d103b9356d9..de3f39ef81d 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -57,7 +57,7 @@ they don't contain references to names that aren't actually defined. # Getting started -> **WARNING**: The tarball and installer links are for the most recent +> ***Warning:*** The tarball and installer links are for the most recent > release, not master. To use master, you **must** build from [git]. The Rust compiler currently must be built from a [tarball] or [git], unless @@ -80,13 +80,10 @@ You may find that other platforms work, but these are our "tier 1" supported build environments that are most likely to work. > ***Note:*** Windows users should read the detailed -> "[getting started][wiki-start]" notes on the wiki. Even when using +> [Getting started][wiki-start] notes on the wiki. Even when using > the binary installer, the Windows build requires a MinGW installation, -> the precise details of which are not discussed here. Finally, `rustc` may -> need to be [referred to as `rustc.exe`][bug-3319]. It's a bummer, we -> know. +> the precise details of which are not discussed here. -[bug-3319]: https://github.com/mozilla/rust/issues/3319 [wiki-start]: https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust [git]: https://github.com/mozilla/rust.git