Skip to content

Commit 13558ee

Browse files
author
Mukund Lakshman
committed
No need to default offset since we always override it.
1 parent 6518a0a commit 13558ee

File tree

6 files changed

+36
-40
lines changed

6 files changed

+36
-40
lines changed

src/librustdoc/externalfiles.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl ExternalHtml {
4646
error_codes: codes,
4747
edition,
4848
playground,
49-
heading_level: 0
49+
heading_level: 1
5050
}
5151
.into_string()
5252
);
@@ -62,7 +62,7 @@ impl ExternalHtml {
6262
error_codes: codes,
6363
edition,
6464
playground,
65-
heading_level: 0
65+
heading_level: 1
6666
}
6767
.into_string()
6868
);

src/librustdoc/html/markdown.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//! error_codes: ErrorCodes::Yes,
2020
//! edition: Edition::Edition2015,
2121
//! playground: &None,
22-
//! heading_level: 0
22+
//! heading_level: 1
2323
//! };
2424
//! let html = md.into_string();
2525
//! // ... something using html
@@ -544,7 +544,7 @@ impl<'a, 'b, 'ids, I: Iterator<Item = SpannedEvent<'a>>> Iterator
544544
self.buf.push_front((Event::Html(format!("{} ", sec).into()), 0..0));
545545
}
546546

547-
let level = std::cmp::min(level + self.level + 1, MAX_HEADER_LEVEL);
547+
let level = std::cmp::min(level + self.level, MAX_HEADER_LEVEL);
548548
self.buf.push_back((Event::Html(format!("</a></h{}>", level).into()), 0..0));
549549

550550
let start_tags = format!(

src/librustdoc/html/markdown/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn test_header() {
154154
error_codes: ErrorCodes::Yes,
155155
edition: DEFAULT_EDITION,
156156
playground: &None,
157-
heading_level: 0,
157+
heading_level: 1,
158158
}
159159
.into_string();
160160
assert_eq!(output, expect, "original: {}", input);
@@ -196,7 +196,7 @@ fn test_header_ids_multiple_blocks() {
196196
error_codes: ErrorCodes::Yes,
197197
edition: DEFAULT_EDITION,
198198
playground: &None,
199-
heading_level: 0,
199+
heading_level: 1,
200200
}
201201
.into_string();
202202
assert_eq!(output, expect, "original: {}", input);

src/librustdoc/html/render/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,7 @@ fn settings(root_path: &str, suffix: &str, themes: &[StylePath]) -> Result<Strin
470470
))
471471
}
472472

473-
fn document(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, parent: Option<&clean::Item>) {
474-
document_at_level(w, cx, item, parent, 0)
475-
}
476-
477-
fn document_at_level(
473+
fn document(
478474
w: &mut Buffer,
479475
cx: &Context<'_>,
480476
item: &clean::Item,
@@ -1344,7 +1340,7 @@ fn render_impl(
13441340
// because impls can't have a stability.
13451341
if item.doc_value().is_some() {
13461342
document_item_info(&mut info_buffer, cx, it, Some(parent));
1347-
document_full(&mut doc_buffer, item, cx, 3);
1343+
document_full(&mut doc_buffer, item, cx, 4);
13481344
short_documented = false;
13491345
} else {
13501346
// In case the item isn't documented,
@@ -1362,7 +1358,7 @@ fn render_impl(
13621358
} else {
13631359
document_item_info(&mut info_buffer, cx, item, Some(parent));
13641360
if rendering_params.show_def_docs {
1365-
document_full(&mut doc_buffer, item, cx, 3);
1361+
document_full(&mut doc_buffer, item, cx, 4);
13661362
short_documented = false;
13671363
}
13681364
}
@@ -1603,7 +1599,7 @@ fn render_impl(
16031599
error_codes: cx.shared.codes,
16041600
edition: cx.shared.edition(),
16051601
playground: &cx.shared.playground,
1606-
heading_level: 0
1602+
heading_level: 1
16071603
}
16081604
.into_string()
16091605
);

src/librustdoc/html/render/print_item.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ use rustc_span::symbol::{kw, sym, Symbol};
1616
use rustc_target::abi::{Layout, Primitive, TagEncoding, Variants};
1717

1818
use super::{
19-
collect_paths_for_type, document, document_at_level, ensure_trailing_slash, item_ty_to_strs,
20-
notable_traits_decl, render_assoc_item, render_assoc_items, render_attributes_in_code,
21-
render_attributes_in_pre, render_impl, render_stability_since_raw, write_srclink,
22-
AssocItemLink, Context, ImplRenderingParameters,
19+
collect_paths_for_type, document, ensure_trailing_slash, item_ty_to_strs, notable_traits_decl,
20+
render_assoc_item, render_assoc_items, render_attributes_in_code, render_attributes_in_pre,
21+
render_impl, render_stability_since_raw, write_srclink, AssocItemLink, Context,
22+
ImplRenderingParameters,
2323
};
2424
use crate::clean::{self, GetDefId};
2525
use crate::formats::item_type::ItemType;
@@ -173,7 +173,7 @@ fn toggle_close(w: &mut Buffer) {
173173
}
174174

175175
fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) {
176-
document(w, cx, item, None);
176+
document(w, cx, item, None, 1);
177177

178178
let mut indices = (0..items.len()).filter(|i| !items[*i].is_stripped()).collect::<Vec<usize>>();
179179

@@ -485,7 +485,7 @@ fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean::
485485
notable_traits = notable_traits_decl(&f.decl, cx),
486486
);
487487
});
488-
document(w, cx, it, None)
488+
document(w, cx, it, None, 1)
489489
}
490490

491491
fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) {
@@ -608,7 +608,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
608608
});
609609

610610
// Trait documentation
611-
document(w, cx, it, None);
611+
document(w, cx, it, None, 1);
612612

613613
fn write_small_section_header(w: &mut Buffer, id: &str, title: &str, extra_content: &str) {
614614
write!(
@@ -626,7 +626,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra
626626
let item_type = m.type_();
627627
let id = cx.derive_id(format!("{}.{}", item_type, name));
628628
let mut content = Buffer::empty_from(w);
629-
document_at_level(&mut content, cx, m, Some(t), 3);
629+
document(&mut content, cx, m, Some(t), 4);
630630
let toggled = !content.is_empty();
631631
if toggled {
632632
write!(w, "<details class=\"rustdoc-toggle\" open><summary>");
@@ -840,7 +840,7 @@ fn item_trait_alias(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clea
840840
);
841841
});
842842

843-
document(w, cx, it, None);
843+
document(w, cx, it, None, 1);
844844

845845
// Render any items associated directly to this alias, as otherwise they
846846
// won't be visible anywhere in the docs. It would be nice to also show
@@ -862,7 +862,7 @@ fn item_opaque_ty(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean:
862862
);
863863
});
864864

865-
document(w, cx, it, None);
865+
document(w, cx, it, None, 1);
866866

867867
// Render any items associated directly to this alias, as otherwise they
868868
// won't be visible anywhere in the docs. It would be nice to also show
@@ -893,7 +893,7 @@ fn item_typedef(
893893
);
894894
});
895895

896-
document(w, cx, it, None);
896+
document(w, cx, it, None, 1);
897897

898898
let def_id = it.def_id.expect_def_id();
899899
// Render any items associated directly to this alias, as otherwise they
@@ -911,7 +911,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni
911911
});
912912
});
913913

914-
document(w, cx, it, None);
914+
document(w, cx, it, None, 1);
915915

916916
let mut fields = s
917917
.fields
@@ -944,7 +944,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni
944944
if let Some(stability_class) = field.stability_class(cx.tcx()) {
945945
write!(w, "<span class=\"stab {stab}\"></span>", stab = stability_class);
946946
}
947-
document(w, cx, field, Some(it));
947+
document(w, cx, field, Some(it), 1);
948948
}
949949
}
950950
let def_id = it.def_id.expect_def_id();
@@ -1026,7 +1026,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
10261026
});
10271027
});
10281028

1029-
document(w, cx, it, None);
1029+
document(w, cx, it, None, 1);
10301030

10311031
if !e.variants.is_empty() {
10321032
write!(
@@ -1055,7 +1055,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
10551055
w.write_str("</code>");
10561056
render_stability_since(w, variant, it, cx.tcx());
10571057
w.write_str("</div>");
1058-
document(w, cx, variant, Some(it));
1058+
document(w, cx, variant, Some(it), 1);
10591059
document_non_exhaustive(w, variant);
10601060

10611061
use crate::clean::Variant;
@@ -1095,7 +1095,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
10951095
f = field.name.as_ref().unwrap(),
10961096
t = ty.print(cx)
10971097
);
1098-
document(w, cx, field, Some(variant));
1098+
document(w, cx, field, Some(variant), 1);
10991099
}
11001100
_ => unreachable!(),
11011101
}
@@ -1122,7 +1122,7 @@ fn item_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Mac
11221122
None,
11231123
);
11241124
});
1125-
document(w, cx, it, None)
1125+
document(w, cx, it, None, 1)
11261126
}
11271127

11281128
fn item_proc_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, m: &clean::ProcMacro) {
@@ -1152,11 +1152,11 @@ fn item_proc_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, m: &clean
11521152
});
11531153
}
11541154
}
1155-
document(w, cx, it, None)
1155+
document(w, cx, it, None, 1)
11561156
}
11571157

11581158
fn item_primitive(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) {
1159-
document(w, cx, it, None);
1159+
document(w, cx, it, None, 1);
11601160
render_assoc_items(w, cx, it, it.def_id.expect_def_id(), AssocItemRender::All)
11611161
}
11621162

@@ -1195,7 +1195,7 @@ fn item_constant(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, c: &clean::
11951195
}
11961196
});
11971197

1198-
document(w, cx, it, None)
1198+
document(w, cx, it, None, 1)
11991199
}
12001200

12011201
fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Struct) {
@@ -1206,7 +1206,7 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
12061206
});
12071207
});
12081208

1209-
document(w, cx, it, None);
1209+
document(w, cx, it, None, 1);
12101210

12111211
let mut fields = s
12121212
.fields
@@ -1242,7 +1242,7 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
12421242
name = field_name,
12431243
ty = ty.print(cx)
12441244
);
1245-
document(w, cx, field, Some(it));
1245+
document(w, cx, field, Some(it), 1);
12461246
}
12471247
}
12481248
}
@@ -1263,7 +1263,7 @@ fn item_static(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
12631263
typ = s.type_.print(cx)
12641264
);
12651265
});
1266-
document(w, cx, it, None)
1266+
document(w, cx, it, None, 1)
12671267
}
12681268

12691269
fn item_foreign_type(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) {
@@ -1278,13 +1278,13 @@ fn item_foreign_type(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) {
12781278
);
12791279
});
12801280

1281-
document(w, cx, it, None);
1281+
document(w, cx, it, None, 1);
12821282

12831283
render_assoc_items(w, cx, it, it.def_id.expect_def_id(), AssocItemRender::All)
12841284
}
12851285

12861286
fn item_keyword(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) {
1287-
document(w, cx, it, None)
1287+
document(w, cx, it, None, 1)
12881288
}
12891289

12901290
/// Compare two strings treating multi-digit numbers as single units (i.e. natural sort order).

src/tools/error_index_generator/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl Formatter for HTMLFormatter {
126126
error_codes: ErrorCodes::Yes,
127127
edition: DEFAULT_EDITION,
128128
playground: &Some(playground),
129-
heading_level: 0
129+
heading_level: 1
130130
}
131131
.into_string()
132132
)?

0 commit comments

Comments
 (0)