@@ -84,6 +84,17 @@ def rustdoc_compile_action(
84
84
rustdoc_flags = rustdoc_flags + lints_info .rustdoc_lint_flags
85
85
lint_files = lint_files + lints_info .rustdoc_lint_files
86
86
87
+ # Collect HTML customization files
88
+ html_input_files = []
89
+ if hasattr (ctx .file , "html_in_header" ) and ctx .file .html_in_header :
90
+ html_input_files .append (ctx .file .html_in_header )
91
+ if hasattr (ctx .file , "html_before_content" ) and ctx .file .html_before_content :
92
+ html_input_files .append (ctx .file .html_before_content )
93
+ if hasattr (ctx .file , "html_after_content" ) and ctx .file .html_after_content :
94
+ html_input_files .append (ctx .file .html_after_content )
95
+ if hasattr (ctx .files , "markdown_css" ):
96
+ html_input_files .extend (ctx .files .markdown_css )
97
+
87
98
cc_toolchain , feature_configuration = find_cc_toolchain (ctx )
88
99
89
100
dep_info , build_info , _ = collect_deps (
@@ -149,9 +160,12 @@ def rustdoc_compile_action(
149
160
if "OUT_DIR" in env :
150
161
env .update ({"OUT_DIR" : "${{pwd}}/{}" .format (build_info .out_dir .short_path )})
151
162
163
+ # Create the combined inputs including HTML customization files
164
+ all_inputs = depset ([crate_info .output ], transitive = [compile_inputs , depset (html_input_files )])
165
+
152
166
return struct (
153
167
executable = ctx .executable ._process_wrapper ,
154
- inputs = depset ([ crate_info . output ], transitive = [ compile_inputs ]) ,
168
+ inputs = all_inputs ,
155
169
env = env ,
156
170
arguments = args .all ,
157
171
tools = [toolchain .rust_doc ],
@@ -205,6 +219,21 @@ def _rust_doc_impl(ctx):
205
219
"--extern" ,
206
220
"{}={}" .format (crate_info .name , crate_info .output .path ),
207
221
]
222
+
223
+ # Add HTML customization flags if attributes are provided
224
+ if ctx .attr .html_in_header :
225
+ rustdoc_flags .extend (["--html-in-header" , ctx .file .html_in_header .path ])
226
+
227
+ if ctx .attr .html_before_content :
228
+ rustdoc_flags .extend (["--html-before-content" , ctx .file .html_before_content .path ])
229
+
230
+ if ctx .attr .html_after_content :
231
+ rustdoc_flags .extend (["--html-after-content" , ctx .file .html_after_content .path ])
232
+
233
+ # Add markdown CSS files if provided
234
+ for css_file in ctx .files .markdown_css :
235
+ rustdoc_flags .extend (["--markdown-css" , css_file .path ])
236
+
208
237
rustdoc_flags .extend (ctx .attr .rustdoc_flags )
209
238
210
239
action = rustdoc_compile_action (
@@ -239,7 +268,7 @@ def _rust_doc_impl(ctx):
239
268
rustdoc_zip = depset ([ctx .outputs .rust_doc_zip ]),
240
269
),
241
270
]
242
-
271
+
243
272
rust_doc = rule (
244
273
doc = dedent ("""\
245
274
Generates code documentation.
0 commit comments