2020//! edition: Edition::Edition2015,
2121//! playground: &None,
2222//! heading_offset: HeadingOffset::H2,
23- //! custom_code_classes_in_docs: true,
2423//! };
2524//! let html = md.into_string();
2625//! // ... something using html
@@ -97,8 +96,6 @@ pub struct Markdown<'a> {
9796 /// Offset at which we render headings.
9897 /// E.g. if `heading_offset: HeadingOffset::H2`, then `# something` renders an `<h2>`.
9998 pub heading_offset : HeadingOffset ,
100- /// `true` if the `custom_code_classes_in_docs` feature is enabled.
101- pub custom_code_classes_in_docs : bool ,
10299}
103100/// A struct like `Markdown` that renders the markdown with a table of contents.
104101pub ( crate ) struct MarkdownWithToc < ' a > {
@@ -107,8 +104,6 @@ pub(crate) struct MarkdownWithToc<'a> {
107104 pub ( crate ) error_codes : ErrorCodes ,
108105 pub ( crate ) edition : Edition ,
109106 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 ,
112107}
113108/// A tuple struct like `Markdown` that renders the markdown escaping HTML tags
114109/// and includes no paragraph tags.
@@ -209,7 +204,6 @@ struct CodeBlocks<'p, 'a, I: Iterator<Item = Event<'a>>> {
209204 // Information about the playground if a URL has been specified, containing an
210205 // optional crate name and the URL.
211206 playground : & ' p Option < Playground > ,
212- custom_code_classes_in_docs : bool ,
213207}
214208
215209impl < ' 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> {
218212 error_codes : ErrorCodes ,
219213 edition : Edition ,
220214 playground : & ' p Option < Playground > ,
221- custom_code_classes_in_docs : bool ,
222215 ) -> Self {
223216 CodeBlocks {
224217 inner : iter,
225218 check_error_codes : error_codes,
226219 edition,
227220 playground,
228- custom_code_classes_in_docs,
229221 }
230222 }
231223}
@@ -257,7 +249,6 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
257249 lang,
258250 self . check_error_codes ,
259251 false ,
260- self . custom_code_classes_in_docs ,
261252 ) ;
262253 if !parse_result. rust {
263254 let added_classes = parse_result. added_classes ;
@@ -733,7 +724,6 @@ pub(crate) fn find_testable_code<T: doctest::Tester>(
733724 error_codes : ErrorCodes ,
734725 enable_per_target_ignores : bool ,
735726 extra_info : Option < & ExtraInfo < ' _ > > ,
736- custom_code_classes_in_docs : bool ,
737727) {
738728 find_codes (
739729 doc,
@@ -742,7 +732,6 @@ pub(crate) fn find_testable_code<T: doctest::Tester>(
742732 enable_per_target_ignores,
743733 extra_info,
744734 false ,
745- custom_code_classes_in_docs,
746735 )
747736}
748737
@@ -753,7 +742,6 @@ pub(crate) fn find_codes<T: doctest::Tester>(
753742 enable_per_target_ignores : bool ,
754743 extra_info : Option < & ExtraInfo < ' _ > > ,
755744 include_non_rust : bool ,
756- custom_code_classes_in_docs : bool ,
757745) {
758746 let mut parser = Parser :: new ( doc) . into_offset_iter ( ) ;
759747 let mut prev_offset = 0 ;
@@ -772,7 +760,6 @@ pub(crate) fn find_codes<T: doctest::Tester>(
772760 error_codes,
773761 enable_per_target_ignores,
774762 extra_info,
775- custom_code_classes_in_docs,
776763 )
777764 }
778765 }
@@ -1167,29 +1154,6 @@ impl<'a, 'tcx> Iterator for TagIterator<'a, 'tcx> {
11671154 }
11681155}
11691156
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-
11931157impl Default for LangString {
11941158 fn default ( ) -> Self {
11951159 Self {
@@ -1213,14 +1177,12 @@ impl LangString {
12131177 string : & str ,
12141178 allow_error_code_check : ErrorCodes ,
12151179 enable_per_target_ignores : bool ,
1216- custom_code_classes_in_docs : bool ,
12171180 ) -> Self {
12181181 Self :: parse (
12191182 string,
12201183 allow_error_code_check,
12211184 enable_per_target_ignores,
12221185 None ,
1223- custom_code_classes_in_docs,
12241186 )
12251187 }
12261188
@@ -1229,7 +1191,6 @@ impl LangString {
12291191 allow_error_code_check : ErrorCodes ,
12301192 enable_per_target_ignores : bool ,
12311193 extra : Option < & ExtraInfo < ' _ > > ,
1232- custom_code_classes_in_docs : bool ,
12331194 ) -> Self {
12341195 let allow_error_code_check = allow_error_code_check. as_bool ( ) ;
12351196 let mut seen_rust_tags = false ;
@@ -1266,11 +1227,7 @@ impl LangString {
12661227 seen_rust_tags = true ;
12671228 }
12681229 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 ;
12741231 }
12751232 LangStringToken :: LangToken ( "test_harness" ) => {
12761233 data. test_harness = true ;
@@ -1361,16 +1318,12 @@ impl LangString {
13611318 data. unknown . push ( x. to_owned ( ) ) ;
13621319 }
13631320 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+ ) ) ;
13741327 }
13751328 }
13761329 LangStringToken :: ClassAttribute ( class) => {
@@ -1380,11 +1333,7 @@ impl LangString {
13801333 }
13811334 } ;
13821335
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) ) ;
13881337
13891338 // ignore-foo overrides ignore
13901339 if !ignores. is_empty ( ) {
@@ -1407,7 +1356,6 @@ impl Markdown<'_> {
14071356 edition,
14081357 playground,
14091358 heading_offset,
1410- custom_code_classes_in_docs,
14111359 } = self ;
14121360
14131361 // This is actually common enough to special-case
@@ -1430,7 +1378,7 @@ impl Markdown<'_> {
14301378 let p = Footnotes :: new ( p) ;
14311379 let p = LinkReplacer :: new ( p. map ( |( ev, _) | ev) , links) ;
14321380 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) ;
14341382 html:: push_html ( & mut s, p) ;
14351383
14361384 s
@@ -1445,7 +1393,6 @@ impl MarkdownWithToc<'_> {
14451393 error_codes : codes,
14461394 edition,
14471395 playground,
1448- custom_code_classes_in_docs,
14491396 } = self ;
14501397
14511398 let p = Parser :: new_ext ( md, main_body_opts ( ) ) . into_offset_iter ( ) ;
@@ -1458,7 +1405,7 @@ impl MarkdownWithToc<'_> {
14581405 let p = HeadingLinks :: new ( p, Some ( & mut toc) , ids, HeadingOffset :: H1 ) ;
14591406 let p = Footnotes :: new ( p) ;
14601407 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) ;
14621409 html:: push_html ( & mut s, p) ;
14631410 }
14641411
@@ -1902,7 +1849,6 @@ pub(crate) struct RustCodeBlock {
19021849pub ( crate ) fn rust_code_blocks (
19031850 md : & str ,
19041851 extra_info : & ExtraInfo < ' _ > ,
1905- custom_code_classes_in_docs : bool ,
19061852) -> Vec < RustCodeBlock > {
19071853 let mut code_blocks = vec ! [ ] ;
19081854
@@ -1925,7 +1871,6 @@ pub(crate) fn rust_code_blocks(
19251871 ErrorCodes :: Yes ,
19261872 false ,
19271873 Some ( extra_info) ,
1928- custom_code_classes_in_docs,
19291874 )
19301875 } ;
19311876 if !lang_string. rust {
0 commit comments