Skip to content

Commit

Permalink
Switch to intra rustdoc links
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 20, 2019
1 parent f5aced6 commit a21b147
Show file tree
Hide file tree
Showing 23 changed files with 108 additions and 64 deletions.
17 changes: 9 additions & 8 deletions src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ast_struct! {
/// into the structured representation that is used by convention across
/// most Rust libraries.
///
/// [`parse_meta`]: #method.parse_meta
/// [`parse_meta`]: Attribute::parse_meta
///
/// # Parsing
///
Expand All @@ -63,11 +63,9 @@ ast_struct! {
/// [`Attribute::parse_outer`] or [`Attribute::parse_inner`] depending on
/// which you intend to parse.
///
/// [`Parse`]: parse/trait.Parse.html
/// [`ParseStream::parse`]: parse/struct.ParseBuffer.html#method.parse
/// [`ParseStream::call`]: parse/struct.ParseBuffer.html#method.call
/// [`Attribute::parse_outer`]: #method.parse_outer
/// [`Attribute::parse_inner`]: #method.parse_inner
/// [`Parse`]: parse::Parse
/// [`ParseStream::parse`]: parse::ParseBuffer::parse
/// [`ParseStream::call`]: parse::ParseBuffer::call
///
/// ```edition2018
/// use syn::{Attribute, Ident, Result, Token};
Expand Down Expand Up @@ -134,7 +132,7 @@ impl Hash for Attribute {

impl Attribute {
/// Parses the content of the attribute, consisting of the path and tts, as
/// a [`Meta`](enum.Meta.html) if possible.
/// a [`Meta`] if possible.
///
/// Deprecated; use `parse_meta` instead.
#[doc(hidden)]
Expand Down Expand Up @@ -175,7 +173,7 @@ impl Attribute {
}

/// Parses the content of the attribute, consisting of the path and tts, as
/// a [`Meta`](enum.Meta.html) if possible.
/// a [`Meta`] if possible.
#[cfg(feature = "parsing")]
pub fn parse_meta(&self) -> Result<Meta> {
if let Some(ref colon) = self.path.leading_colon {
Expand Down Expand Up @@ -412,6 +410,9 @@ ast_enum_of_structs! {
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
pub enum Meta {
pub Word(Ident),
/// A structured list within an attribute, like `derive(Copy, Clone)`.
Expand Down
8 changes: 4 additions & 4 deletions src/custom_keyword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
///
/// - Field access to its span — `let sp = whatever_token.span`
///
/// [Peeking]: parse/struct.ParseBuffer.html#method.peek
/// [Parsing]: parse/struct.ParseBuffer.html#method.parse
/// [Printing]: https://docs.rs/quote/0.6/quote/trait.ToTokens.html
/// [`Span`]: https://docs.rs/proc-macro2/0.4/proc_macro2/struct.Span.html
/// [Peeking]: parse::ParseBuffer::peek
/// [Parsing]: parse::ParseBuffer::parse
/// [Printing]: quote::ToTokens
/// [`Span`]: proc_macro2::Span
///
/// # Example
///
Expand Down
8 changes: 4 additions & 4 deletions src/custom_punctuation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
///
/// - Field access to its spans — `let spans = lrarrow.spans`
///
/// [Peeking]: parse/struct.ParseBuffer.html#method.peek
/// [Parsing]: parse/struct.ParseBuffer.html#method.parse
/// [Printing]: https://docs.rs/quote/0.6/quote/trait.ToTokens.html
/// [`Span`]: https://docs.rs/proc-macro2/0.4/proc_macro2/struct.Span.html
/// [Peeking]: parse::ParseBuffer::peek
/// [Parsing]: parse::ParseBuffer::parse
/// [Printing]: quote::ToTokens
/// [`Span`]: proc_macro2::Span
///
/// # Example
///
Expand Down
10 changes: 6 additions & 4 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ ast_enum_of_structs! {
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
pub enum Fields {
/// Named fields of a struct or struct variant such as `Point { x: f64,
/// y: f64 }`.
Expand Down Expand Up @@ -61,8 +64,6 @@ impl Fields {
/// Get an iterator over the borrowed [`Field`] items in this object. This
/// iterator can be used to iterate over a named or unnamed struct or
/// variant's fields uniformly.
///
/// [`Field`]: struct.Field.html
pub fn iter(&self) -> punctuated::Iter<Field> {
match *self {
Fields::Unit => private::empty_punctuated_iter(),
Expand All @@ -74,8 +75,6 @@ impl Fields {
/// Get an iterator over the mutably borrowed [`Field`] items in this
/// object. This iterator can be used to iterate over a named or unnamed
/// struct or variant's fields uniformly.
///
/// [`Field`]: struct.Field.html
pub fn iter_mut(&mut self) -> punctuated::IterMut<Field> {
match *self {
Fields::Unit => private::empty_punctuated_iter_mut(),
Expand Down Expand Up @@ -139,6 +138,9 @@ ast_enum_of_structs! {
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
pub enum Visibility {
/// A public visibility level: `pub`.
///
Expand Down
3 changes: 3 additions & 0 deletions src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ ast_enum_of_structs! {
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
pub enum Data {
/// A struct input to a `proc_macro_derive` macro.
///
Expand Down
4 changes: 2 additions & 2 deletions src/discouraged.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub trait Speculative {
/// repetition, bypassing the need to involve the downsides associated with
/// speculative parsing.
///
/// [`ParseStream::fork`]: ../struct.ParseBuffer.html#method.fork
/// [`ParseStream::fork`]: ParseBuffer::fork
///
/// # Example
///
Expand Down Expand Up @@ -143,7 +143,7 @@ pub trait Speculative {
/// possible, displaying reasonable errors becomes much more simple.
///
/// [RFC 2544]: https://github.com/rust-lang/rfcs/pull/2544
/// [`PathSegment`]: ../../struct.PathSegment.html
/// [`PathSegment`]: crate::PathSegment
///
/// # Performance
///
Expand Down
6 changes: 4 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ pub type Result<T> = std::result::Result<T, Error>;
/// [module documentation]: index.html
///
/// *This type is available if Syn is built with the `"parsing"` feature.*
//
// TODO: change the parse module link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62830
pub struct Error {
// Span is implemented as an index into a thread-local interner to keep the
// size small. It is not safe to access from a different thread. We want
Expand All @@ -48,7 +51,7 @@ impl Error {
/// Use `Error::new` when the error needs to be triggered on some span other
/// than where the parse stream is currently positioned.
///
/// [`ParseStream::error`]: struct.ParseBuffer.html#method.error
/// [`ParseStream::error`]: crate::parse::ParseBuffer::error
///
/// # Example
///
Expand Down Expand Up @@ -135,7 +138,6 @@ impl Error {
/// this method correctly in a procedural macro.
///
/// [`compile_error!`]: https://doc.rust-lang.org/std/macro.compile_error.html
/// [`parse_macro_input!`]: ../macro.parse_macro_input.html
pub fn to_compile_error(&self) -> TokenStream {
let start = self
.start_span
Expand Down
3 changes: 3 additions & 0 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,9 @@ ast_enum_of_structs! {
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
pub enum Pat {
/// A pattern that matches any value: `_`.
///
Expand Down
2 changes: 1 addition & 1 deletion src/gen/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ macro_rules! full {
///
/// See the [module documentation] for details.
///
/// [module documentation]: index.html
/// [module documentation]: self
///
/// *This trait is available if Syn is built with the `"fold"` feature.*
pub trait Fold {
Expand Down
2 changes: 1 addition & 1 deletion src/gen/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ macro_rules! skip {
///
/// See the [module documentation] for details.
///
/// [module documentation]: index.html
/// [module documentation]: self
///
/// *This trait is available if Syn is built with the `"visit"` feature.*
pub trait Visit<'ast> {
Expand Down
2 changes: 1 addition & 1 deletion src/gen/visit_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ macro_rules! skip {
///
/// See the [module documentation] for details.
///
/// [module documentation]: index.html
/// [module documentation]: self
///
/// *This trait is available if Syn is built with the `"visit-mut"` feature.*
pub trait VisitMut {
Expand Down
6 changes: 6 additions & 0 deletions src/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ ast_enum_of_structs! {
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
pub enum GenericParam {
/// A generic type parameter: `T: Into<String>`.
///
Expand Down Expand Up @@ -432,6 +435,9 @@ ast_enum_of_structs! {
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
pub enum WherePredicate {
/// A type predicate in a `where` clause: `for<'c> Foo<'c>: Trait<'c>`.
///
Expand Down
18 changes: 18 additions & 0 deletions src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ ast_enum_of_structs! {
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
pub enum Item {
/// An `extern crate` item: `extern crate serde`.
///
Expand Down Expand Up @@ -361,6 +364,9 @@ ast_enum_of_structs! {
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
pub enum UseTree {
/// A path prefix of imports in a `use` item: `std::...`.
///
Expand Down Expand Up @@ -414,6 +420,9 @@ ast_enum_of_structs! {
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
pub enum ForeignItem {
/// A foreign function in an `extern` block.
///
Expand Down Expand Up @@ -499,6 +508,9 @@ ast_enum_of_structs! {
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
pub enum TraitItem {
/// An associated constant within the definition of a trait.
///
Expand Down Expand Up @@ -585,6 +597,9 @@ ast_enum_of_structs! {
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
pub enum ImplItem {
/// An associated constant within an impl block.
///
Expand Down Expand Up @@ -719,6 +734,9 @@ ast_enum_of_structs! {
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
pub enum FnArg {
/// Self captured by reference in a function signature: `&self` or `&mut
/// self`.
Expand Down
11 changes: 5 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ mod gen {
/// default, every method recursively visits the substructure of the input
/// by invoking the right visitor method of each of its fields.
///
/// [`Visit`]: trait.Visit.html
/// [`Visit`]: visit::Visit
///
/// ```edition2018
/// # use syn::{Attribute, BinOp, Expr, ExprBinary};
Expand Down Expand Up @@ -475,7 +475,7 @@ mod gen {
/// By default, every method recursively visits the substructure of the
/// input by invoking the right visitor method of each of its fields.
///
/// [`VisitMut`]: trait.VisitMut.html
/// [`VisitMut`]: visit_mut::VisitMut
///
/// ```edition2018
/// # use syn::{Attribute, BinOp, Expr, ExprBinary};
Expand Down Expand Up @@ -511,7 +511,7 @@ mod gen {
/// By default, every method recursively visits the substructure of the
/// input by invoking the right visitor method of each of its fields.
///
/// [`Fold`]: trait.Fold.html
/// [`Fold`]: fold::Fold
///
/// ```edition2018
/// # use syn::{Attribute, BinOp, Expr, ExprBinary};
Expand Down Expand Up @@ -591,7 +591,7 @@ pub use error::{Error, Result};
/// interop with the compiler in a procedural macro. To parse a
/// `proc_macro2::TokenStream`, use [`syn::parse2`] instead.
///
/// [`syn::parse2`]: fn.parse2.html
/// [`syn::parse2`]: parse2
///
/// *This function is available if Syn is built with both the `"parsing"` and
/// `"proc-macro"` features.*
Expand Down Expand Up @@ -638,8 +638,7 @@ pub fn parse<T: parse::Parse>(tokens: proc_macro::TokenStream) -> Result<T> {
/// `proc_macro::TokenStream` provided by the compiler, use [`syn::parse`]
/// instead.
///
/// [`Macro`]: struct.Macro.html
/// [`syn::parse`]: fn.parse.html
/// [`syn::parse`]: parse()
///
/// *This function is available if Syn is built with the `"parsing"` feature.*
#[cfg(feature = "parsing")]
Expand Down
5 changes: 4 additions & 1 deletion src/lit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ ast_enum_of_structs! {
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
pub enum Lit {
/// A UTF-8 string literal: `"foo"`.
///
Expand Down Expand Up @@ -644,7 +647,7 @@ mod value {
/// doc comments are considered by proc-macro2 to be literals but in Syn
/// they are [`Attribute`].
///
/// [`Attribute`]: struct.Attribute.html
/// [`Attribute`]: crate::Attribute
///
/// # Panics
///
Expand Down
6 changes: 3 additions & 3 deletions src/lookahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use token::Token;
///
/// Use [`ParseStream::lookahead1`] to construct this object.
///
/// [`ParseStream::peek`]: struct.ParseBuffer.html#method.peek
/// [`ParseStream::lookahead1`]: struct.ParseBuffer.html#method.lookahead1
/// [`ParseStream::peek`]: crate::parse::ParseBuffer::peek
/// [`ParseStream::lookahead1`]: crate::parse::ParseBuffer::lookahead1
///
/// # Example
///
Expand Down Expand Up @@ -142,7 +142,7 @@ impl<'a> Lookahead1<'a> {
///
/// This trait is sealed and cannot be implemented for types outside of Syn.
///
/// [`ParseStream::peek`]: struct.ParseBuffer.html#method.peek
/// [`ParseStream::peek`]: crate::parse::ParseBuffer::peek
pub trait Peek: Sealed {
// Not public API.
#[doc(hidden)]
Expand Down
Loading

0 comments on commit a21b147

Please sign in to comment.