Skip to content

Commit bbe61f9

Browse files
David Tolnayfacebook-github-bot
David Tolnay
authored andcommitted
Document private items by default for binaries
Summary: This matches Cargo's behavior. See [rust-lang/cargo#7593](rust-lang/cargo#7593). Documentation for `rust_binary` targets is otherwise useless, since usually there is nothing in them declared `pub`. Reviewed By: zertosh Differential Revision: D36563393 fbshipit-source-id: 9ee64fb3f77caf7376a93eabfb309dc0adc1b45d
1 parent 35c6533 commit bbe61f9

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

prelude/rust/build.bzl

+5-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def generate_rustdoc(
9292
# link style doesn't matter, but caller should pass in build params
9393
# with static-pic (to get best cache hits for deps)
9494
params: BuildParams.type,
95-
default_roots: [str.type]) -> "artifact":
95+
default_roots: [str.type],
96+
document_private_items: bool.type) -> "artifact":
9697
toolchain_info = ctx_toolchain_info(ctx)
9798

9899
common_args = _compute_common_args(
@@ -122,6 +123,9 @@ def generate_rustdoc(
122123
common_args.args,
123124
)
124125

126+
if document_private_items:
127+
rustdoc_cmd.add("--document-private-items")
128+
125129
url_prefix = toolchain_info.extern_html_root_url_prefix
126130
for rust_dependency in resolve_deps(ctx):
127131
dep = rust_dependency.dep

prelude/rust/rust_binary.bzl

+8-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,14 @@ def _rust_binary_common(
109109
)
110110

111111
extra_targets += [
112-
("doc", generate_rustdoc(ctx, compile_ctx, crate, style_param[LinkStyle("static_pic")], default_roots)),
112+
("doc", generate_rustdoc(
113+
ctx = ctx,
114+
compile_ctx = compile_ctx,
115+
crate = crate,
116+
params = style_param[LinkStyle("static_pic")],
117+
default_roots = default_roots,
118+
document_private_items = True,
119+
)),
113120
("expand", expand.outputs[Emit("expand")]),
114121
]
115122
sub_targets = {k: [DefaultInfo(default_outputs = [v])] for k, v in extra_targets}

prelude/rust/rust_library.bzl

+6-5
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,12 @@ def rust_library_impl(ctx: "context") -> ["provider"]:
160160
fail("Unhandled lang {}".format(lang))
161161

162162
rustdoc = generate_rustdoc(
163-
ctx,
164-
compile_ctx,
165-
crate,
166-
lang_style_param[(LinkageLang("rust"), LinkStyle("static_pic"))],
167-
["lib.rs"],
163+
ctx = ctx,
164+
compile_ctx = compile_ctx,
165+
crate = crate,
166+
params = lang_style_param[(LinkageLang("rust"), LinkStyle("static_pic"))],
167+
default_roots = ["lib.rs"],
168+
document_private_items = False,
168169
)
169170

170171
expand = rust_compile(

0 commit comments

Comments
 (0)