Skip to content

Commit

Permalink
Rename CrateSpecific -> InvocationSpecific
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Mar 31, 2021
1 parent d4f3f91 commit 1086d9b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ crate struct RenderOptions {
crate enum EmitType {
Unversioned,
Toolchain,
CrateSpecific,
InvocationSpecific,
}

impl FromStr for EmitType {
Expand All @@ -285,15 +285,15 @@ impl FromStr for EmitType {
match s {
"unversioned-shared-resources" => Ok(Unversioned),
"toolchain-shared-resources" => Ok(Toolchain),
"crate-specific" => Ok(CrateSpecific),
"invocation-specific" => Ok(InvocationSpecific),
_ => Err(()),
}
}
}

impl RenderOptions {
crate fn should_emit_crate(&self) -> bool {
self.emit.is_empty() || self.emit.contains(&EmitType::CrateSpecific)
self.emit.is_empty() || self.emit.contains(&EmitType::InvocationSpecific)
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/librustdoc/html/render/write_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ enum SharedResource<'a> {
///
/// It has a resource suffix.
ToolchainSpecific { basename: &'static str },
/// This file may change for any crate within a build.
/// This file may change for any crate within a build, or based on the CLI arguments.
///
/// This differs from normal crate-specific files because it has a resource suffix.
CrateSpecific { basename: &'a str },
/// This differs from normal invocation-specific files because it has a resource suffix.
InvocationSpecific { basename: &'a str },
}

impl SharedResource<'_> {
Expand All @@ -61,15 +61,15 @@ impl SharedResource<'_> {
match self {
Unversioned { name }
| ToolchainSpecific { basename: name }
| CrateSpecific { basename: name } => Path::new(name).extension(),
| InvocationSpecific { basename: name } => Path::new(name).extension(),
}
}

fn path(&self, cx: &Context<'_>) -> PathBuf {
match self {
SharedResource::Unversioned { name } => cx.dst.join(name),
SharedResource::ToolchainSpecific { basename } => cx.suffix_path(basename),
SharedResource::CrateSpecific { basename } => cx.suffix_path(basename),
SharedResource::InvocationSpecific { basename } => cx.suffix_path(basename),
}
}

Expand All @@ -80,7 +80,7 @@ impl SharedResource<'_> {
let kind = match self {
SharedResource::Unversioned { .. } => EmitType::Unversioned,
SharedResource::ToolchainSpecific { .. } => EmitType::Toolchain,
SharedResource::CrateSpecific { .. } => EmitType::CrateSpecific,
SharedResource::InvocationSpecific { .. } => EmitType::InvocationSpecific,
};
emit.contains(&kind)
}
Expand Down Expand Up @@ -165,7 +165,7 @@ pub(super) fn write_shared(
// Crate resources should always be dynamic.
let write_crate = |p: &_, make_content: &dyn Fn() -> Result<Vec<u8>, Error>| {
let content = make_content()?;
cx.write_shared(SharedResource::CrateSpecific { basename: p }, content, &options.emit)
cx.write_shared(SharedResource::InvocationSpecific { basename: p }, content, &options.emit)
};

// Add all the static files. These may already exist, but we just
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ fn opts() -> Vec<RustcOptGroup> {
"",
"emit",
"Comma separated list of types of output for rustdoc to emit",
"[unversioned-shared-resources,toolchain-shared-resources,crate-specific]",
"[unversioned-shared-resources,toolchain-shared-resources,invocation-specific]",
)
}),
]
Expand Down
22 changes: 11 additions & 11 deletions src/test/run-make/emit-shared-files/Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
-include ../../run-make-fulldeps/tools.mk

CRATE_ONLY = $(TMPDIR)/crate-only
INVOCATION_ONLY = $(TMPDIR)/invocation-only
TOOLCHAIN_ONLY = $(TMPDIR)/toolchain-only
ALL_SHARED = $(TMPDIR)/all-shared

all: crate-only toolchain-only all-shared
all: invocation-only toolchain-only all-shared

crate-only:
$(RUSTDOC) -Z unstable-options --emit=crate-specific --output $(CRATE_ONLY) --resource-suffix=-xxx --theme y.css x.rs
[ -e $(CRATE_ONLY)/search-index-xxx.js ]
[ -e $(CRATE_ONLY)/settings.html ]
[ -e $(CRATE_ONLY)/x/all.html ]
[ -e $(CRATE_ONLY)/x/index.html ]
invocation-only:
$(RUSTDOC) -Z unstable-options --emit=invocation-specific --output $(INVOCATION_ONLY) --resource-suffix=-xxx --theme y.css x.rs
[ -e $(INVOCATION_ONLY)/search-index-xxx.js ]
[ -e $(INVOCATION_ONLY)/settings.html ]
[ -e $(INVOCATION_ONLY)/x/all.html ]
[ -e $(INVOCATION_ONLY)/x/index.html ]
# FIXME: this probably shouldn't have a suffix
[ -e $(CRATE_ONLY)/y-xxx.css ]
! [ -e $(CRATE_ONLY)/storage-xxx.js ]
! [ -e $(CRATE_ONLY)/SourceSerifPro-It.ttf.woff ]
[ -e $(INVOCATION_ONLY)/y-xxx.css ]
! [ -e $(INVOCATION_ONLY)/storage-xxx.js ]
! [ -e $(INVOCATION_ONLY)/SourceSerifPro-It.ttf.woff ]

toolchain-only:
$(RUSTDOC) -Z unstable-options --emit=toolchain-shared-resources --output $(TOOLCHAIN_ONLY) --resource-suffix=-xxx x.rs
Expand Down

0 comments on commit 1086d9b

Please sign in to comment.