From f7aafcced8d7374ddbe50a509cb0bcec959254c4 Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Tue, 24 Feb 2015 23:05:44 +0900 Subject: [PATCH 1/3] Fix duplicate methods in rustdoc --- src/librustdoc/clean/inline.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index d1283d6f46bd8..2bf623b2761e9 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -308,6 +308,9 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt, if method.vis != ast::Public && associated_trait.is_none() { return None } + if method.provided_source.is_some() { + return None + } let mut item = method.clean(cx); item.inner = match item.inner.clone() { clean::TyMethodItem(clean::TyMethod { From 5e1d4fffff1516758f43b22b2e89327e5ec0918c Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Fri, 27 Feb 2015 00:27:57 +0900 Subject: [PATCH 2/3] Add a way to assert the number of occurrences to htmldocck --- src/etc/htmldocck.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/etc/htmldocck.py b/src/etc/htmldocck.py index 22792ff763551..a212e3a04357e 100644 --- a/src/etc/htmldocck.py +++ b/src/etc/htmldocck.py @@ -96,6 +96,9 @@ highlights for example. If you want to simply check the presence of given node or attribute, use an empty string (`""`) as a `PATTERN`. +* `@count PATH XPATH COUNT' checks for the occurrence of given XPath + in the given file. The number of occurrences must match the given count. + All conditions can be negated with `!`. `@!has foo/type.NoSuch.html` checks if the given file does not exist, for example. @@ -333,6 +336,11 @@ def check_tree_text(tree, path, pat, regexp): return ret +def check_tree_count(tree, path, count): + path = normalize_xpath(path) + return len(tree.findall(path)) == count + + def check(target, commands): cache = CachedFiles(target) for c in commands: @@ -360,6 +368,13 @@ def check(target, commands): raise RuntimeError('Invalid number of @{} arguments \ at line {}'.format(c.cmd, c.lineno)) + elif c.cmd == 'count': # count test + if len(c.args) == 3: # @count = count test + ret = check_tree_count(cache.get_tree(c.args[0]), c.args[1], int(c.args[2])) + else: + raise RuntimeError('Invalid number of @{} arguments \ + at line {}'.format(c.cmd, c.lineno)) + elif c.cmd == 'valid-html': raise RuntimeError('Unimplemented @valid-html at line {}'.format(c.lineno)) From 695846331b1f0f39ce2fc6dff90edce03c958d12 Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Fri, 27 Feb 2015 00:28:57 +0900 Subject: [PATCH 3/3] Add a rustdoc test for default methods in external crates --- .../rustdoc-extern-default-method/Makefile | 6 ++++++ .../rustdoc-extern-default-method/ext.rs | 21 +++++++++++++++++++ .../rustdoc-extern-default-method/lib.rs | 14 +++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 src/test/run-make/rustdoc-extern-default-method/Makefile create mode 100644 src/test/run-make/rustdoc-extern-default-method/ext.rs create mode 100644 src/test/run-make/rustdoc-extern-default-method/lib.rs diff --git a/src/test/run-make/rustdoc-extern-default-method/Makefile b/src/test/run-make/rustdoc-extern-default-method/Makefile new file mode 100644 index 0000000000000..ffc4a08f8018b --- /dev/null +++ b/src/test/run-make/rustdoc-extern-default-method/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: lib.rs ext.rs + $(HOST_RPATH_ENV) $(RUSTC) ext.rs + $(HOST_RPATH_ENV) $(RUSTDOC) -L $(TMPDIR) -w html -o $(TMPDIR)/doc lib.rs + $(HTMLDOCCK) $(TMPDIR)/doc lib.rs diff --git a/src/test/run-make/rustdoc-extern-default-method/ext.rs b/src/test/run-make/rustdoc-extern-default-method/ext.rs new file mode 100644 index 0000000000000..861562753f991 --- /dev/null +++ b/src/test/run-make/rustdoc-extern-default-method/ext.rs @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub trait Trait { + fn provided(&self) {} +} + +pub struct Struct; + +impl Trait for Struct { + fn provided(&self) {} +} diff --git a/src/test/run-make/rustdoc-extern-default-method/lib.rs b/src/test/run-make/rustdoc-extern-default-method/lib.rs new file mode 100644 index 0000000000000..df92764dc9aec --- /dev/null +++ b/src/test/run-make/rustdoc-extern-default-method/lib.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate ext; + +// @count lib/struct.Struct.html '//*[@id="method.provided"]' 1 +pub use ext::Struct;