diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2016-08-03 13:19:06 +1200 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2016-08-17 10:30:39 +1200 |
| commit | a41454bf651a8629ec4b08365eae65b095504cab (patch) | |
| tree | 4f73294bffafbc9a44a8824b5f52ab63dce05dc7 /src | |
| parent | 7a7cd644cbcf8f57a156a32c7e1312de86682b0d (diff) | |
| download | rust-a41454bf651a8629ec4b08365eae65b095504cab.tar.gz rust-a41454bf651a8629ec4b08365eae65b095504cab.zip | |
rustdoc: add namespaces for items
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/html/item_type.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/librustdoc/html/item_type.rs b/src/librustdoc/html/item_type.rs index c3d38637ab7..039f385d7c5 100644 --- a/src/librustdoc/html/item_type.rs +++ b/src/librustdoc/html/item_type.rs @@ -42,6 +42,14 @@ pub enum ItemType { AssociatedConst = 18, } + +#[derive(Copy, Eq, PartialEq, Clone)] +pub enum NameSpace { + Type, + Value, + Macro, +} + impl ItemType { pub fn from_item(item: &clean::Item) -> ItemType { let inner = match item.inner { @@ -113,6 +121,32 @@ impl ItemType { ItemType::AssociatedConst => "associatedconstant", } } + + pub fn name_space(&self) -> NameSpace { + match *self { + ItemType::Struct | + ItemType::Enum | + ItemType::Module | + ItemType::Typedef | + ItemType::Trait | + ItemType::Primitive | + ItemType::AssociatedType => NameSpace::Type, + + ItemType::ExternCrate | + ItemType::Import | + ItemType::Function | + ItemType::Static | + ItemType::Impl | + ItemType::TyMethod | + ItemType::Method | + ItemType::StructField | + ItemType::Variant | + ItemType::Constant | + ItemType::AssociatedConst => NameSpace::Value, + + ItemType::Macro => NameSpace::Macro, + } + } } impl fmt::Display for ItemType { @@ -120,3 +154,17 @@ impl fmt::Display for ItemType { self.css_class().fmt(f) } } + +pub const NAMESPACE_TYPE: &'static str = "t"; +pub const NAMESPACE_VALUE: &'static str = "v"; +pub const NAMESPACE_MACRO: &'static str = "m"; + +impl NameSpace { + pub fn to_static_str(&self) -> &'static str { + match *self { + NameSpace::Type => NAMESPACE_TYPE, + NameSpace::Value => NAMESPACE_VALUE, + NameSpace::Macro => NAMESPACE_MACRO, + } + } +} |
