20
20
//! edition: Edition::Edition2015,
21
21
//! playground: &None,
22
22
//! heading_offset: HeadingOffset::H2,
23
- //! custom_code_classes_in_docs: true,
24
23
//! };
25
24
//! let html = md.into_string();
26
25
//! // ... something using html
@@ -97,8 +96,6 @@ pub struct Markdown<'a> {
97
96
/// Offset at which we render headings.
98
97
/// E.g. if `heading_offset: HeadingOffset::H2`, then `# something` renders an `<h2>`.
99
98
pub heading_offset : HeadingOffset ,
100
- /// `true` if the `custom_code_classes_in_docs` feature is enabled.
101
- pub custom_code_classes_in_docs : bool ,
102
99
}
103
100
/// A struct like `Markdown` that renders the markdown with a table of contents.
104
101
pub ( crate ) struct MarkdownWithToc < ' a > {
@@ -107,8 +104,6 @@ pub(crate) struct MarkdownWithToc<'a> {
107
104
pub ( crate ) error_codes : ErrorCodes ,
108
105
pub ( crate ) edition : Edition ,
109
106
pub ( crate ) playground : & ' a Option < Playground > ,
110
- /// `true` if the `custom_code_classes_in_docs` feature is enabled.
111
- pub ( crate ) custom_code_classes_in_docs : bool ,
112
107
}
113
108
/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags
114
109
/// and includes no paragraph tags.
@@ -209,7 +204,6 @@ struct CodeBlocks<'p, 'a, I: Iterator<Item = Event<'a>>> {
209
204
// Information about the playground if a URL has been specified, containing an
210
205
// optional crate name and the URL.
211
206
playground : & ' p Option < Playground > ,
212
- custom_code_classes_in_docs : bool ,
213
207
}
214
208
215
209
impl < ' p , ' a , I : Iterator < Item = Event < ' a > > > CodeBlocks < ' p , ' a , I > {
@@ -218,14 +212,12 @@ impl<'p, 'a, I: Iterator<Item = Event<'a>>> CodeBlocks<'p, 'a, I> {
218
212
error_codes : ErrorCodes ,
219
213
edition : Edition ,
220
214
playground : & ' p Option < Playground > ,
221
- custom_code_classes_in_docs : bool ,
222
215
) -> Self {
223
216
CodeBlocks {
224
217
inner : iter,
225
218
check_error_codes : error_codes,
226
219
edition,
227
220
playground,
228
- custom_code_classes_in_docs,
229
221
}
230
222
}
231
223
}
@@ -257,7 +249,6 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
257
249
lang,
258
250
self . check_error_codes ,
259
251
false ,
260
- self . custom_code_classes_in_docs ,
261
252
) ;
262
253
if !parse_result. rust {
263
254
let added_classes = parse_result. added_classes ;
@@ -733,7 +724,6 @@ pub(crate) fn find_testable_code<T: doctest::Tester>(
733
724
error_codes : ErrorCodes ,
734
725
enable_per_target_ignores : bool ,
735
726
extra_info : Option < & ExtraInfo < ' _ > > ,
736
- custom_code_classes_in_docs : bool ,
737
727
) {
738
728
find_codes (
739
729
doc,
@@ -742,7 +732,6 @@ pub(crate) fn find_testable_code<T: doctest::Tester>(
742
732
enable_per_target_ignores,
743
733
extra_info,
744
734
false ,
745
- custom_code_classes_in_docs,
746
735
)
747
736
}
748
737
@@ -753,7 +742,6 @@ pub(crate) fn find_codes<T: doctest::Tester>(
753
742
enable_per_target_ignores : bool ,
754
743
extra_info : Option < & ExtraInfo < ' _ > > ,
755
744
include_non_rust : bool ,
756
- custom_code_classes_in_docs : bool ,
757
745
) {
758
746
let mut parser = Parser :: new ( doc) . into_offset_iter ( ) ;
759
747
let mut prev_offset = 0 ;
@@ -772,7 +760,6 @@ pub(crate) fn find_codes<T: doctest::Tester>(
772
760
error_codes,
773
761
enable_per_target_ignores,
774
762
extra_info,
775
- custom_code_classes_in_docs,
776
763
)
777
764
}
778
765
}
@@ -1167,29 +1154,6 @@ impl<'a, 'tcx> Iterator for TagIterator<'a, 'tcx> {
1167
1154
}
1168
1155
}
1169
1156
1170
- fn tokens ( string : & str ) -> impl Iterator < Item = LangStringToken < ' _ > > {
1171
- // Pandoc, which Rust once used for generating documentation,
1172
- // expects lang strings to be surrounded by `{}` and for each token
1173
- // to be proceeded by a `.`. Since some of these lang strings are still
1174
- // loose in the wild, we strip a pair of surrounding `{}` from the lang
1175
- // string and a leading `.` from each token.
1176
-
1177
- let string = string. trim ( ) ;
1178
-
1179
- let first = string. chars ( ) . next ( ) ;
1180
- let last = string. chars ( ) . last ( ) ;
1181
-
1182
- let string =
1183
- if first == Some ( '{' ) && last == Some ( '}' ) { & string[ 1 ..string. len ( ) - 1 ] } else { string } ;
1184
-
1185
- string
1186
- . split ( |c| c == ',' || c == ' ' || c == '\t' )
1187
- . map ( str:: trim)
1188
- . map ( |token| token. strip_prefix ( '.' ) . unwrap_or ( token) )
1189
- . filter ( |token| !token. is_empty ( ) )
1190
- . map ( |token| LangStringToken :: LangToken ( token) )
1191
- }
1192
-
1193
1157
impl Default for LangString {
1194
1158
fn default ( ) -> Self {
1195
1159
Self {
@@ -1213,14 +1177,12 @@ impl LangString {
1213
1177
string : & str ,
1214
1178
allow_error_code_check : ErrorCodes ,
1215
1179
enable_per_target_ignores : bool ,
1216
- custom_code_classes_in_docs : bool ,
1217
1180
) -> Self {
1218
1181
Self :: parse (
1219
1182
string,
1220
1183
allow_error_code_check,
1221
1184
enable_per_target_ignores,
1222
1185
None ,
1223
- custom_code_classes_in_docs,
1224
1186
)
1225
1187
}
1226
1188
@@ -1229,7 +1191,6 @@ impl LangString {
1229
1191
allow_error_code_check : ErrorCodes ,
1230
1192
enable_per_target_ignores : bool ,
1231
1193
extra : Option < & ExtraInfo < ' _ > > ,
1232
- custom_code_classes_in_docs : bool ,
1233
1194
) -> Self {
1234
1195
let allow_error_code_check = allow_error_code_check. as_bool ( ) ;
1235
1196
let mut seen_rust_tags = false ;
@@ -1266,11 +1227,7 @@ impl LangString {
1266
1227
seen_rust_tags = true ;
1267
1228
}
1268
1229
LangStringToken :: LangToken ( "custom" ) => {
1269
- if custom_code_classes_in_docs {
1270
- seen_custom_tag = true ;
1271
- } else {
1272
- seen_other_tags = true ;
1273
- }
1230
+ seen_custom_tag = true ;
1274
1231
}
1275
1232
LangStringToken :: LangToken ( "test_harness" ) => {
1276
1233
data. test_harness = true ;
@@ -1361,16 +1318,12 @@ impl LangString {
1361
1318
data. unknown . push ( x. to_owned ( ) ) ;
1362
1319
}
1363
1320
LangStringToken :: KeyValueAttribute ( key, value) => {
1364
- if custom_code_classes_in_docs {
1365
- if key == "class" {
1366
- data. added_classes . push ( value. to_owned ( ) ) ;
1367
- } else if let Some ( extra) = extra {
1368
- extra. error_invalid_codeblock_attr ( format ! (
1369
- "unsupported attribute `{key}`"
1370
- ) ) ;
1371
- }
1372
- } else {
1373
- seen_other_tags = true ;
1321
+ if key == "class" {
1322
+ data. added_classes . push ( value. to_owned ( ) ) ;
1323
+ } else if let Some ( extra) = extra {
1324
+ extra. error_invalid_codeblock_attr ( format ! (
1325
+ "unsupported attribute `{key}`"
1326
+ ) ) ;
1374
1327
}
1375
1328
}
1376
1329
LangStringToken :: ClassAttribute ( class) => {
@@ -1380,11 +1333,7 @@ impl LangString {
1380
1333
}
1381
1334
} ;
1382
1335
1383
- if custom_code_classes_in_docs {
1384
- call ( & mut TagIterator :: new ( string, extra) )
1385
- } else {
1386
- call ( & mut tokens ( string) )
1387
- }
1336
+ call ( & mut TagIterator :: new ( string, extra) ) ;
1388
1337
1389
1338
// ignore-foo overrides ignore
1390
1339
if !ignores. is_empty ( ) {
@@ -1407,7 +1356,6 @@ impl Markdown<'_> {
1407
1356
edition,
1408
1357
playground,
1409
1358
heading_offset,
1410
- custom_code_classes_in_docs,
1411
1359
} = self ;
1412
1360
1413
1361
// This is actually common enough to special-case
@@ -1430,7 +1378,7 @@ impl Markdown<'_> {
1430
1378
let p = Footnotes :: new ( p) ;
1431
1379
let p = LinkReplacer :: new ( p. map ( |( ev, _) | ev) , links) ;
1432
1380
let p = TableWrapper :: new ( p) ;
1433
- let p = CodeBlocks :: new ( p, codes, edition, playground, custom_code_classes_in_docs ) ;
1381
+ let p = CodeBlocks :: new ( p, codes, edition, playground) ;
1434
1382
html:: push_html ( & mut s, p) ;
1435
1383
1436
1384
s
@@ -1445,7 +1393,6 @@ impl MarkdownWithToc<'_> {
1445
1393
error_codes : codes,
1446
1394
edition,
1447
1395
playground,
1448
- custom_code_classes_in_docs,
1449
1396
} = self ;
1450
1397
1451
1398
let p = Parser :: new_ext ( md, main_body_opts ( ) ) . into_offset_iter ( ) ;
@@ -1458,7 +1405,7 @@ impl MarkdownWithToc<'_> {
1458
1405
let p = HeadingLinks :: new ( p, Some ( & mut toc) , ids, HeadingOffset :: H1 ) ;
1459
1406
let p = Footnotes :: new ( p) ;
1460
1407
let p = TableWrapper :: new ( p. map ( |( ev, _) | ev) ) ;
1461
- let p = CodeBlocks :: new ( p, codes, edition, playground, custom_code_classes_in_docs ) ;
1408
+ let p = CodeBlocks :: new ( p, codes, edition, playground) ;
1462
1409
html:: push_html ( & mut s, p) ;
1463
1410
}
1464
1411
@@ -1902,7 +1849,6 @@ pub(crate) struct RustCodeBlock {
1902
1849
pub ( crate ) fn rust_code_blocks (
1903
1850
md : & str ,
1904
1851
extra_info : & ExtraInfo < ' _ > ,
1905
- custom_code_classes_in_docs : bool ,
1906
1852
) -> Vec < RustCodeBlock > {
1907
1853
let mut code_blocks = vec ! [ ] ;
1908
1854
@@ -1925,7 +1871,6 @@ pub(crate) fn rust_code_blocks(
1925
1871
ErrorCodes :: Yes ,
1926
1872
false ,
1927
1873
Some ( extra_info) ,
1928
- custom_code_classes_in_docs,
1929
1874
)
1930
1875
} ;
1931
1876
if !lang_string. rust {
0 commit comments