]> git.lizzy.rs Git - rust.git/commitdiff
Show variadic args in rustdoc output.
authorLee Jeffery <lee@leejeffery.co.uk>
Thu, 20 Aug 2015 17:27:53 +0000 (18:27 +0100)
committerLee Jeffery <lee@leejeffery.co.uk>
Thu, 20 Aug 2015 17:27:53 +0000 (18:27 +0100)
src/librustdoc/clean/mod.rs
src/librustdoc/html/format.rs
src/test/rustdoc/variadic.rs [new file with mode: 0644]

index 04b1f8ee1b1d39f94c0031e425236db6450ce336..c976b7cc6c29dea4e1df0babda0377f7b04e6e76 100644 (file)
@@ -999,6 +999,7 @@ fn clean(&self, cx: &DocContext) -> Method {
                 values: inputs.clean(cx),
             },
             output: self.decl.output.clean(cx),
+            variadic: false,
             attrs: Vec::new()
         };
         Method {
@@ -1032,6 +1033,7 @@ fn clean(&self, cx: &DocContext) -> TyMethod {
                 values: inputs.clean(cx),
             },
             output: self.decl.output.clean(cx),
+            variadic: false,
             attrs: Vec::new()
         };
         TyMethod {
@@ -1098,6 +1100,7 @@ fn clean(&self, cx: &DocContext) -> Item {
 pub struct FnDecl {
     pub inputs: Arguments,
     pub output: FunctionRetTy,
+    pub variadic: bool,
     pub attrs: Vec<Attribute>,
 }
 
@@ -1113,6 +1116,7 @@ fn clean(&self, cx: &DocContext) -> FnDecl {
                 values: self.inputs.clean(cx),
             },
             output: self.output.clean(cx),
+            variadic: self.variadic,
             attrs: Vec::new()
         }
     }
@@ -1141,6 +1145,7 @@ fn clean(&self, cx: &DocContext) -> FnDecl {
         FnDecl {
             output: Return(sig.0.output.clean(cx)),
             attrs: Vec::new(),
+            variadic: sig.0.variadic,
             inputs: Arguments {
                 values: sig.0.inputs.iter().map(|t| {
                     Argument {
index 7d86a547e94e96134cdcf2ec3a69c27e6db3604d..b50e50ddce6bee466ad95c2e267124ac9aa76d5b 100644 (file)
@@ -579,7 +579,11 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 impl fmt::Display for clean::FnDecl {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
+        if self.variadic {
+            write!(f, "({args}, ...){arrow}", args = self.inputs, arrow = self.output)
+        } else {
+            write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
+        }
     }
 }
 
diff --git a/src/test/rustdoc/variadic.rs b/src/test/rustdoc/variadic.rs
new file mode 100644 (file)
index 0000000..1b60c2a
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+extern "C" {
+    // @has variadic/fn.foo.html //pre 'pub unsafe extern fn foo(x: i32, ...)'
+    pub fn foo(x: i32, ...);
+}