Skip to content

Commit a7c6d3e

Browse files
Improve function naming
1 parent 286a51d commit a7c6d3e

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

src/librustdoc/html/markdown.rs

+22-23
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@
1010

1111
//! Markdown formatting for rustdoc
1212
//!
13-
//! This module implements markdown formatting through the hoedown C-library
14-
//! (bundled into the rust runtime). This module self-contains the C bindings
15-
//! and necessary legwork to render markdown, and exposes all of the
13+
//! This module implements markdown formatting through the pulldown-cmark
14+
//! rust-library. This module exposes all of the
1615
//! functionality through a unit-struct, `Markdown`, which has an implementation
1716
//! of `fmt::Display`. Example usage:
1817
//!
1918
//! ```rust,ignore
20-
//! use rustdoc::html::markdown::Markdown;
19+
//! use rustdoc::html::markdown::{Markdown, MarkdownOutputStyle};
2120
//!
2221
//! let s = "My *markdown* _text_";
23-
//! let html = format!("{}", Markdown(s));
22+
//! let html = format!("{}", Markdown(s, MarkdownOutputStyle::Fancy));
2423
//! // ... something using html
2524
//! ```
2625
@@ -138,7 +137,7 @@ pub fn render(w: &mut fmt::Formatter,
138137
s: &str,
139138
print_toc: bool,
140139
shorter: MarkdownOutputStyle) -> fmt::Result {
141-
fn block(parser: &mut Parser, buffer: &mut String, lang: &str) {
140+
fn code_block(parser: &mut Parser, buffer: &mut String, lang: &str) {
142141
let mut origtext = String::new();
143142
while let Some(event) = parser.next() {
144143
match event {
@@ -216,8 +215,8 @@ pub fn render(w: &mut fmt::Formatter,
216215
});
217216
}
218217

219-
fn header(parser: &mut Parser, buffer: &mut String, toc_builder: &mut Option<TocBuilder>,
220-
shorter: MarkdownOutputStyle, level: i32) {
218+
fn heading(parser: &mut Parser, buffer: &mut String, toc_builder: &mut Option<TocBuilder>,
219+
shorter: MarkdownOutputStyle, level: i32) {
221220
let mut ret = String::new();
222221
let mut id = String::new();
223222
event_loop_break!(parser, toc_builder, shorter, ret, true, &mut Some(&mut id),
@@ -250,8 +249,8 @@ pub fn render(w: &mut fmt::Formatter,
250249
ret, lvl = level, id = id, sec = sec));
251250
}
252251

253-
fn codespan(parser: &mut Parser, buffer: &mut String, toc_builder: &mut Option<TocBuilder>,
254-
shorter: MarkdownOutputStyle, id: &mut Option<&mut String>) {
252+
fn inline_code(parser: &mut Parser, buffer: &mut String, toc_builder: &mut Option<TocBuilder>,
253+
shorter: MarkdownOutputStyle, id: &mut Option<&mut String>) {
255254
let mut content = String::new();
256255
event_loop_break!(parser, toc_builder, shorter, content, false, id, Event::End(Tag::Code));
257256
buffer.push_str(&format!("<code>{}</code>",
@@ -274,8 +273,8 @@ pub fn render(w: &mut fmt::Formatter,
274273
buffer.push_str(&format!("<p>{}</p>", content.trim_right()));
275274
}
276275

277-
fn cell(parser: &mut Parser, buffer: &mut String, toc_builder: &mut Option<TocBuilder>,
278-
shorter: MarkdownOutputStyle) {
276+
fn table_cell(parser: &mut Parser, buffer: &mut String, toc_builder: &mut Option<TocBuilder>,
277+
shorter: MarkdownOutputStyle) {
279278
let mut content = String::new();
280279
event_loop_break!(parser, toc_builder, shorter, content, true, &mut None,
281280
Event::End(Tag::TableHead) |
@@ -285,16 +284,16 @@ pub fn render(w: &mut fmt::Formatter,
285284
buffer.push_str(&format!("<td>{}</td>", content.trim()));
286285
}
287286

288-
fn row(parser: &mut Parser, buffer: &mut String, toc_builder: &mut Option<TocBuilder>,
289-
shorter: MarkdownOutputStyle) {
287+
fn table_row(parser: &mut Parser, buffer: &mut String, toc_builder: &mut Option<TocBuilder>,
288+
shorter: MarkdownOutputStyle) {
290289
let mut content = String::new();
291290
while let Some(event) = parser.next() {
292291
match event {
293292
Event::End(Tag::TableHead) |
294293
Event::End(Tag::Table(_)) |
295294
Event::End(Tag::TableRow) => break,
296295
Event::Start(Tag::TableCell) => {
297-
cell(parser, &mut content, toc_builder, shorter);
296+
table_cell(parser, &mut content, toc_builder, shorter);
298297
}
299298
x => {
300299
looper(parser, &mut content, Some(x), toc_builder, shorter, &mut None);
@@ -304,14 +303,14 @@ pub fn render(w: &mut fmt::Formatter,
304303
buffer.push_str(&format!("<tr>{}</tr>", content));
305304
}
306305

307-
fn head(parser: &mut Parser, buffer: &mut String, toc_builder: &mut Option<TocBuilder>,
308-
shorter: MarkdownOutputStyle) {
306+
fn table_head(parser: &mut Parser, buffer: &mut String, toc_builder: &mut Option<TocBuilder>,
307+
shorter: MarkdownOutputStyle) {
309308
let mut content = String::new();
310309
while let Some(event) = parser.next() {
311310
match event {
312311
Event::End(Tag::TableHead) | Event::End(Tag::Table(_)) => break,
313312
Event::Start(Tag::TableCell) => {
314-
cell(parser, &mut content, toc_builder, shorter);
313+
table_cell(parser, &mut content, toc_builder, shorter);
315314
}
316315
x => {
317316
looper(parser, &mut content, Some(x), toc_builder, shorter, &mut None);
@@ -331,10 +330,10 @@ pub fn render(w: &mut fmt::Formatter,
331330
match event {
332331
Event::End(Tag::Table(_)) => break,
333332
Event::Start(Tag::TableHead) => {
334-
head(parser, &mut content, toc_builder, shorter);
333+
table_head(parser, &mut content, toc_builder, shorter);
335334
}
336335
Event::Start(Tag::TableRow) => {
337-
row(parser, &mut rows, toc_builder, shorter);
336+
table_row(parser, &mut rows, toc_builder, shorter);
338337
}
339338
_ => {}
340339
}
@@ -412,13 +411,13 @@ pub fn render(w: &mut fmt::Formatter,
412411
if let Some(event) = next_event {
413412
match event {
414413
Event::Start(Tag::CodeBlock(lang)) => {
415-
block(parser, buffer, &*lang);
414+
code_block(parser, buffer, &*lang);
416415
}
417416
Event::Start(Tag::Header(level)) => {
418-
header(parser, buffer, toc_builder, shorter, level);
417+
heading(parser, buffer, toc_builder, shorter, level);
419418
}
420419
Event::Start(Tag::Code) => {
421-
codespan(parser, buffer, toc_builder, shorter, id);
420+
inline_code(parser, buffer, toc_builder, shorter, id);
422421
}
423422
Event::Start(Tag::Paragraph) => {
424423
paragraph(parser, buffer, toc_builder, shorter, id);

0 commit comments

Comments
 (0)