diff options
| author | Pietro Albini <pietro@pietroalbini.org> | 2018-08-01 10:12:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-01 10:12:35 +0200 |
| commit | 03df573c57b331df37fc3304c4d96293b069b522 (patch) | |
| tree | 5935541e59f1d319841fdaba83ca0e67474255c2 /src/tools | |
| parent | b7ee110ea2c739e1819b437754b345deda3f3606 (diff) | |
| parent | 0f680b38d0be7e2621c288a8e77a7177a7ae3189 (diff) | |
| download | rust-03df573c57b331df37fc3304c4d96293b069b522.tar.gz rust-03df573c57b331df37fc3304c4d96293b069b522.zip | |
Rollup merge of #52628 - Mark-Simulacrum:rustdoc-cleanup-1, r=QuietMisdreavus
Cleanup some rustdoc code Commits are mostly individual though some do depend on others.
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/error_index_generator/main.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index e72f90554d3..40917cc5db0 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -21,10 +21,11 @@ use std::fs::{read_dir, File}; use std::io::{Read, Write}; use std::path::Path; use std::path::PathBuf; +use std::cell::RefCell; use syntax::diagnostics::metadata::{get_metadata_dir, ErrorMetadataMap, ErrorMetadata}; -use rustdoc::html::markdown::{Markdown, PLAYGROUND}; +use rustdoc::html::markdown::{Markdown, IdMap, ErrorCodes, PLAYGROUND}; use rustc_serialize::json; enum OutputFormat { @@ -36,7 +37,7 @@ enum OutputFormat { impl OutputFormat { fn from(format: &str) -> OutputFormat { match &*format.to_lowercase() { - "html" => OutputFormat::HTML(HTMLFormatter), + "html" => OutputFormat::HTML(HTMLFormatter(RefCell::new(IdMap::new()))), "markdown" => OutputFormat::Markdown(MarkdownFormatter), s => OutputFormat::Unknown(s.to_owned()), } @@ -51,7 +52,7 @@ trait Formatter { fn footer(&self, output: &mut dyn Write) -> Result<(), Box<dyn Error>>; } -struct HTMLFormatter; +struct HTMLFormatter(RefCell<IdMap>); struct MarkdownFormatter; impl Formatter for HTMLFormatter { @@ -100,7 +101,11 @@ impl Formatter for HTMLFormatter { // Description rendered as markdown. match info.description { - Some(ref desc) => write!(output, "{}", Markdown(desc, &[]))?, + Some(ref desc) => { + let mut id_map = self.0.borrow_mut(); + write!(output, "{}", + Markdown(desc, &[], RefCell::new(&mut id_map), ErrorCodes::Yes))? + }, None => write!(output, "<p>No description.</p>\n")?, } |
