提交 772a8028 编写于 作者: G Guillaume Gomez

Rename main theme into light theme

上级 14ac1b5f
...@@ -305,7 +305,7 @@ $ rustdoc src/lib.rs -Z unstable-options --themes theme.css ...@@ -305,7 +305,7 @@ $ rustdoc src/lib.rs -Z unstable-options --themes theme.css
Giving this flag to `rustdoc` will make it copy your theme into the generated crate docs and enable Giving this flag to `rustdoc` will make it copy your theme into the generated crate docs and enable
it in the theme selector. Note that `rustdoc` will reject your theme file if it doesn't style it in the theme selector. Note that `rustdoc` will reject your theme file if it doesn't style
everything the "main" theme does. See `--theme-checker` below for details. everything the "light" theme does. See `--theme-checker` below for details.
### `--theme-checker`: verify theme CSS for validity ### `--theme-checker`: verify theme CSS for validity
...@@ -316,7 +316,7 @@ $ rustdoc -Z unstable-options --theme-checker theme.css ...@@ -316,7 +316,7 @@ $ rustdoc -Z unstable-options --theme-checker theme.css
``` ```
Before including your theme in crate docs, `rustdoc` will compare all the CSS rules it contains Before including your theme in crate docs, `rustdoc` will compare all the CSS rules it contains
against the "main" theme included by default. Using this flag will allow you to see which rules are against the "light" theme included by default. Using this flag will allow you to see which rules are
missing if `rustdoc` rejects your theme. missing if `rustdoc` rejects your theme.
### `--resource-suffix`: modifying the name of CSS/JavaScript in crate docs ### `--resource-suffix`: modifying the name of CSS/JavaScript in crate docs
...@@ -330,7 +330,7 @@ $ rustdoc src/lib.rs -Z unstable-options --resource-suffix suf ...@@ -330,7 +330,7 @@ $ rustdoc src/lib.rs -Z unstable-options --resource-suffix suf
When rendering docs, `rustdoc` creates several CSS and JavaScript files as part of the output. Since When rendering docs, `rustdoc` creates several CSS and JavaScript files as part of the output. Since
all these files are linked from every page, changing where they are can be cumbersome if you need to all these files are linked from every page, changing where they are can be cumbersome if you need to
specially cache them. This flag will rename all these files in the output to include the suffix in specially cache them. This flag will rename all these files in the output to include the suffix in
the filename. For example, `main.css` would become `main-suf.css` with the above command. the filename. For example, `light.css` would become `light-suf.css` with the above command.
### `--display-warnings`: display warnings when documenting or running documentation tests ### `--display-warnings`: display warnings when documenting or running documentation tests
......
...@@ -53,7 +53,7 @@ pub fn render<T: fmt::Display, S: fmt::Display>( ...@@ -53,7 +53,7 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
id="mainThemeStyle"> id="mainThemeStyle">
{themes} {themes}
<link rel="stylesheet" type="text/css" href="{root_path}dark{suffix}.css"> <link rel="stylesheet" type="text/css" href="{root_path}dark{suffix}.css">
<link rel="stylesheet" type="text/css" href="{root_path}main{suffix}.css" id="themeStyle"> <link rel="stylesheet" type="text/css" href="{root_path}light{suffix}.css" id="themeStyle">
<script src="{root_path}storage{suffix}.js"></script> <script src="{root_path}storage{suffix}.js"></script>
{css_extension} {css_extension}
......
...@@ -129,8 +129,8 @@ pub struct SharedContext { ...@@ -129,8 +129,8 @@ pub struct SharedContext {
pub sort_modules_alphabetically: bool, pub sort_modules_alphabetically: bool,
/// Additional themes to be added to the generated docs. /// Additional themes to be added to the generated docs.
pub themes: Vec<PathBuf>, pub themes: Vec<PathBuf>,
/// Suffix to be added on resource files (if suffix is "-v2" then "main.css" becomes /// Suffix to be added on resource files (if suffix is "-v2" then "light.css" becomes
/// "main-v2.css"). /// "light-v2.css").
pub resource_suffix: String, pub resource_suffix: String,
} }
...@@ -743,7 +743,7 @@ fn write_shared(cx: &Context, ...@@ -743,7 +743,7 @@ fn write_shared(cx: &Context,
write(cx.dst.join(&format!("rustdoc{}.css", cx.shared.resource_suffix)), write(cx.dst.join(&format!("rustdoc{}.css", cx.shared.resource_suffix)),
include_bytes!("static/rustdoc.css"))?; include_bytes!("static/rustdoc.css"))?;
// To avoid "main.css" to be overwritten, we'll first run over the received themes and only // To avoid "light.css" to be overwritten, we'll first run over the received themes and only
// then we'll run over the "official" styles. // then we'll run over the "official" styles.
let mut themes: HashSet<String> = HashSet::new(); let mut themes: HashSet<String> = HashSet::new();
...@@ -761,9 +761,9 @@ fn write_shared(cx: &Context, ...@@ -761,9 +761,9 @@ fn write_shared(cx: &Context,
write(cx.dst.join(&format!("brush{}.svg", cx.shared.resource_suffix)), write(cx.dst.join(&format!("brush{}.svg", cx.shared.resource_suffix)),
include_bytes!("static/brush.svg"))?; include_bytes!("static/brush.svg"))?;
write(cx.dst.join(&format!("main{}.css", cx.shared.resource_suffix)), write(cx.dst.join(&format!("light{}.css", cx.shared.resource_suffix)),
include_bytes!("static/themes/main.css"))?; include_bytes!("static/themes/light.css"))?;
themes.insert("main".to_owned()); themes.insert("light".to_owned());
write(cx.dst.join(&format!("dark{}.css", cx.shared.resource_suffix)), write(cx.dst.join(&format!("dark{}.css", cx.shared.resource_suffix)),
include_bytes!("static/themes/dark.css"))?; include_bytes!("static/themes/dark.css"))?;
themes.insert("dark".to_owned()); themes.insert("dark".to_owned());
......
...@@ -67,4 +67,4 @@ function switchTheme(styleElem, mainStyleElem, newTheme) { ...@@ -67,4 +67,4 @@ function switchTheme(styleElem, mainStyleElem, newTheme) {
} }
} }
switchTheme(currentTheme, mainTheme, getCurrentValue('rustdoc-theme') || 'main'); switchTheme(currentTheme, mainTheme, getCurrentValue('rustdoc-theme') || 'light');
...@@ -266,8 +266,8 @@ pub fn opts() -> Vec<RustcOptGroup> { ...@@ -266,8 +266,8 @@ pub fn opts() -> Vec<RustcOptGroup> {
unstable("resource-suffix", |o| { unstable("resource-suffix", |o| {
o.optopt("", o.optopt("",
"resource-suffix", "resource-suffix",
"suffix to add to CSS and JavaScript files, e.g. \"main.css\" will become \ "suffix to add to CSS and JavaScript files, e.g. \"light.css\" will become \
\"main-suffix.css\"", \"light-suffix.css\"",
"PATH") "PATH")
}), }),
] ]
...@@ -321,7 +321,7 @@ pub fn main_args(args: &[String]) -> isize { ...@@ -321,7 +321,7 @@ pub fn main_args(args: &[String]) -> isize {
let to_check = matches.opt_strs("theme-checker"); let to_check = matches.opt_strs("theme-checker");
if !to_check.is_empty() { if !to_check.is_empty() {
let paths = theme::load_css_paths(include_bytes!("html/static/themes/main.css")); let paths = theme::load_css_paths(include_bytes!("html/static/themes/light.css"));
let mut errors = 0; let mut errors = 0;
println!("rustdoc: [theme-checker] Starting tests!"); println!("rustdoc: [theme-checker] Starting tests!");
...@@ -392,7 +392,7 @@ pub fn main_args(args: &[String]) -> isize { ...@@ -392,7 +392,7 @@ pub fn main_args(args: &[String]) -> isize {
let mut themes = Vec::new(); let mut themes = Vec::new();
if matches.opt_present("themes") { if matches.opt_present("themes") {
let paths = theme::load_css_paths(include_bytes!("html/static/themes/main.css")); let paths = theme::load_css_paths(include_bytes!("html/static/themes/light.css"));
for (theme_file, theme_s) in matches.opt_strs("themes") for (theme_file, theme_s) in matches.opt_strs("themes")
.iter() .iter()
......
...@@ -61,8 +61,8 @@ fn header(&self, output: &mut Write) -> Result<(), Box<Error>> { ...@@ -61,8 +61,8 @@ fn header(&self, output: &mut Write) -> Result<(), Box<Error>> {
<head> <head>
<title>Rust Compiler Error Index</title> <title>Rust Compiler Error Index</title>
<meta charset="utf-8"> <meta charset="utf-8">
<!-- Include rust.css after main.css so its rules take priority. --> <!-- Include rust.css after light.css so its rules take priority. -->
<link rel="stylesheet" type="text/css" href="main.css"/> <link rel="stylesheet" type="text/css" href="light.css"/>
<link rel="stylesheet" type="text/css" href="rust.css"/> <link rel="stylesheet" type="text/css" href="rust.css"/>
<style> <style>
.error-undescribed {{ .error-undescribed {{
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
use std::path::Path; use std::path::Path;
use std::process::{Command, exit}; use std::process::{Command, exit};
const FILES_TO_IGNORE: &[&str] = &["main.css"]; const FILES_TO_IGNORE: &[&str] = &["light.css"];
fn get_folders<P: AsRef<Path>>(folder_path: P) -> Vec<String> { fn get_folders<P: AsRef<Path>>(folder_path: P) -> Vec<String> {
let mut ret = Vec::with_capacity(10); let mut ret = Vec::with_capacity(10);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册