Skip to content

Commit 1547caf

Browse files
committed
rustdoc: Fix inclusion of the new fonts
These fonts were moved into place by rust's makefiles, but rustdoc is widely used outside of rustc itself. This moves the fonts into the rustdoc binary, similarly to the other static assets, and writes them to the output location whenever rustdoc generates documentation. Closes #13593 Closes #13787
1 parent 3a321b0 commit 1547caf

File tree

7 files changed

+16
-26
lines changed

7 files changed

+16
-26
lines changed

mk/docs.mk

-20
Original file line numberDiff line numberDiff line change
@@ -141,26 +141,6 @@ doc/footer.inc: $(D)/footer.inc | doc/
141141
@$(call E, cp: $@)
142142
$(Q)cp -a $< $@ 2> /dev/null
143143

144-
doc/FiraSans-Regular.woff: $(D)/FiraSans-Regular.woff | doc/
145-
@$(call E, cp: $@)
146-
$(Q)cp -a $< $@ 2> /dev/null
147-
148-
doc/FiraSans-Medium.woff: $(D)/FiraSans-Medium.woff | doc/
149-
@$(call E, cp: $@)
150-
$(Q)cp -a $< $@ 2> /dev/null
151-
152-
doc/Heuristica-Regular.woff: $(D)/Heuristica-Regular.woff | doc/
153-
@$(call E, cp: $@)
154-
$(Q)cp -a $< $@ 2> /dev/null
155-
156-
doc/Heuristica-Italic.woff: $(D)/Heuristica-Italic.woff | doc/
157-
@$(call E, cp: $@)
158-
$(Q)cp -a $< $@ 2> /dev/null
159-
160-
doc/Heuristica-Bold.woff: $(D)/Heuristica-Bold.woff | doc/
161-
@$(call E, cp: $@)
162-
$(Q)cp -a $< $@ 2> /dev/null
163-
164144
# The (english) documentation for each doc item.
165145

166146
define DEF_SHOULD_BUILD_PDF_DOC

src/librustdoc/html/render.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,21 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
362362
// Add all the static files. These may already exist, but we just
363363
// overwrite them anyway to make sure that they're fresh and up-to-date.
364364
try!(write(cx.dst.join("jquery.js"),
365-
include_str!("static/jquery-2.1.0.min.js")));
366-
try!(write(cx.dst.join("main.js"), include_str!("static/main.js")));
367-
try!(write(cx.dst.join("main.css"), include_str!("static/main.css")));
365+
include_bin!("static/jquery-2.1.0.min.js")));
366+
try!(write(cx.dst.join("main.js"), include_bin!("static/main.js")));
367+
try!(write(cx.dst.join("main.css"), include_bin!("static/main.css")));
368368
try!(write(cx.dst.join("normalize.css"),
369-
include_str!("static/normalize.css")));
369+
include_bin!("static/normalize.css")));
370+
try!(write(cx.dst.join("FiraSans-Regular.woff"),
371+
include_bin!("static/FiraSans-Regular.woff")));
372+
try!(write(cx.dst.join("FiraSans-Medium.woff"),
373+
include_bin!("static/FiraSans-Medium.woff")));
374+
try!(write(cx.dst.join("Heuristica-Regular.woff"),
375+
include_bin!("static/Heuristica-Regular.woff")));
376+
try!(write(cx.dst.join("Heuristica-Italic.woff"),
377+
include_bin!("static/Heuristica-Italic.woff")));
378+
try!(write(cx.dst.join("Heuristica-Bold.woff"),
379+
include_bin!("static/Heuristica-Bold.woff")));
370380

371381
// Update the search index
372382
let dst = cx.dst.join("search-index.js");
@@ -415,8 +425,8 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
415425

416426
/// Writes the entire contents of a string to a destination, not attempting to
417427
/// catch any errors.
418-
fn write(dst: Path, contents: &str) -> io::IoResult<()> {
419-
File::create(&dst).write(contents.as_bytes())
428+
fn write(dst: Path, contents: &[u8]) -> io::IoResult<()> {
429+
File::create(&dst).write(contents)
420430
}
421431

422432
/// Makes a directory on the filesystem, failing the task if an error occurs and

0 commit comments

Comments
 (0)