Skip to content

Commit 440c0f0

Browse files
committed
rustdoc: Added issue tracker option and issue data to clean::Stability
1 parent e822a18 commit 440c0f0

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2688,7 +2688,8 @@ pub struct Stability {
26882688
pub feature: String,
26892689
pub since: String,
26902690
pub deprecated_since: String,
2691-
pub reason: String
2691+
pub reason: String,
2692+
pub issue: Option<u32>
26922693
}
26932694

26942695
impl Clean<Stability> for attr::Stability {
@@ -2702,6 +2703,7 @@ impl Clean<Stability> for attr::Stability {
27022703
|istr| istr.to_string()),
27032704
reason: self.reason.as_ref().map_or("".to_string(),
27042705
|interned| interned.to_string()),
2706+
issue: self.issue,
27052707
}
27062708
}
27072709
}
@@ -2717,6 +2719,7 @@ impl<'a> Clean<Stability> for &'a attr::Stability {
27172719
|istr| istr.to_string()),
27182720
reason: self.reason.as_ref().map_or("".to_string(),
27192721
|interned| interned.to_string()),
2722+
issue: self.issue,
27202723
}
27212724
}
27222725
}

src/librustdoc/html/render.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ pub struct Context {
103103
pub render_redirect_pages: bool,
104104
/// All the passes that were run on this crate.
105105
pub passes: HashSet<String>,
106+
/// The base-URL of the issue tracker for when an item has been tagged with
107+
/// an issue number.
108+
pub issue_tracker_base_url: Option<String>,
106109
}
107110

108111
/// Indicates where an external crate can be found.
@@ -303,7 +306,8 @@ thread_local!(pub static CURRENT_LOCATION_KEY: RefCell<Vec<String>> =
303306
pub fn run(mut krate: clean::Crate,
304307
external_html: &ExternalHtml,
305308
dst: PathBuf,
306-
passes: HashSet<String>) -> io::Result<()> {
309+
passes: HashSet<String>,
310+
issue_tracker_base_url: Option<String>) -> io::Result<()> {
307311
let src_root = match krate.src.parent() {
308312
Some(p) => p.to_path_buf(),
309313
None => PathBuf::new(),
@@ -323,6 +327,7 @@ pub fn run(mut krate: clean::Crate,
323327
},
324328
include_sources: true,
325329
render_redirect_pages: false,
330+
issue_tracker_base_url: issue_tracker_base_url,
326331
};
327332

328333
try!(mkdir(&cx.dst));
@@ -352,6 +357,10 @@ pub fn run(mut krate: clean::Crate,
352357
}
353358
});
354359
}
360+
clean::NameValue(ref x, ref s)
361+
if "issue_tracker_base_url" == *x => {
362+
cx.issue_tracker_base_url = Some(s.to_string());
363+
}
355364
clean::Word(ref x)
356365
if "html_no_source" == *x => {
357366
cx.include_sources = false;

src/librustdoc/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ pub fn opts() -> Vec<getopts::OptGroup> {
178178
"FILES"),
179179
optopt("", "markdown-playground-url",
180180
"URL to send code snippets to", "URL"),
181+
optopt("", "issue-tracker-base-url",
182+
"base URL for issue tracker", "URL"),
181183
optflag("", "markdown-no-toc", "don't include table of contents")
182184
)
183185
}
@@ -284,7 +286,8 @@ pub fn main_args(args: &[String]) -> isize {
284286
Some("html") | None => {
285287
match html::render::run(krate, &external_html,
286288
output.unwrap_or(PathBuf::from("doc")),
287-
passes.into_iter().collect()) {
289+
passes.into_iter().collect(),
290+
matches.opt_str("issue-tracker-base-url")) {
288291
Ok(()) => {}
289292
Err(e) => panic!("failed to generate documentation: {}", e),
290293
}

0 commit comments

Comments
 (0)