Skip to content

Commit

Permalink
Use inter/intra-crate links in all documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed Oct 9, 2018
1 parent 2839aca commit 28f2a33
Show file tree
Hide file tree
Showing 51 changed files with 484 additions and 544 deletions.
32 changes: 14 additions & 18 deletions contrib/lib/src/databases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
//! support can be easily extended by implementing the [`Poolable`] trait. See
//! [Extending](#extending) for more.
//!
//! [`r2d2`]: https://crates.io/crates/r2d2
//! [request guards]: [rocket::FromRequest]
//!
//! ## Example
//!
//! Before using this library, the feature corresponding to your database type
Expand Down Expand Up @@ -204,8 +201,6 @@
//! generates an implementation of the [`Deref`](::std::ops::Deref) trait with
//! the internal `Poolable` type as the target.
//!
//! [`FromRequest`]: /rocket/request/trait.FromRequest.html
//!
//! The macro will also generate two inherent methods on the decorated type:
//!
//! * `fn fairing() -> impl Fairing`
Expand Down Expand Up @@ -316,14 +311,14 @@
//! The list below includes all presently supported database adapters and their
//! corresponding [`Poolable`] type.
//!
//! | Kind | Driver | [`Poolable`] Type | Feature |
//! | Kind | Driver | `Poolable` Type | Feature |
//! |----------|-----------------------|--------------------------------|------------------------|
//! | MySQL | [Diesel] | [`diesel::MysqlConnection`] | `diesel_mysql_pool` |
//! | MySQL | [`rust-mysql-simple`] | [`mysql::conn`] | `mysql_pool` |
//! | MySQL | [`rust-mysql-simple`] | [`mysql::Conn`] | `mysql_pool` |
//! | Postgres | [Diesel] | [`diesel::PgConnection`] | `diesel_postgres_pool` |
//! | Postgres | [Rust-Postgres] | [`postgres::Connection`] | `postgres_pool` |
//! | Sqlite | [Diesel] | [`diesel::SqliteConnection`] | `diesel_sqlite_pool` |
//! | Sqlite | [`Rustqlite`] | [`rusqlite::Connection`] | `sqlite_pool` |
//! | Sqlite | [Rustqlite] | [`rusqlite::Connection`] | `sqlite_pool` |
//! | Neo4j | [`rusted_cypher`] | [`rusted_cypher::GraphClient`] | `cypher_pool` |
//! | Redis | [`redis-rs`] | [`redis::Connection`] | `redis_pool` |
//!
Expand All @@ -338,7 +333,7 @@
//! [`diesel::MysqlConnection`]: http://docs.diesel.rs/diesel/mysql/struct.MysqlConnection.html
//! [`redis-rs`]: https://github.com/mitsuhiko/redis-rs
//! [`rusted_cypher`]: https://github.com/livioribeiro/rusted-cypher
//! [`Rustqlite`]: https://github.com/jgallagher/rusqlite
//! [Rustqlite]: https://github.com/jgallagher/rusqlite
//! [Rust-Postgres]: https://github.com/sfackler/rust-postgres
//! [`rust-mysql-simple`]: https://github.com/blackbeam/rust-mysql-simple
//! [`diesel::PgConnection`]: http://docs.diesel.rs/diesel/pg/struct.PgConnection.html
Expand All @@ -355,6 +350,10 @@
//! database-like struct that can be pooled by `r2d2`) is as easy as
//! implementing the [`Poolable`] trait. See the documentation for [`Poolable`]
//! for more details on how to implement it.
//!
//! [`FromRequest`]: rocket::FromRequest
//! [request guards]: rocket::FromRequest
//! [`Poolable`]: databases::Poolable
pub extern crate r2d2;

Expand Down Expand Up @@ -455,7 +454,7 @@ pub enum DatabaseConfigError {
/// configuration.
MissingKey,
/// The configuration associated with the key isn't a
/// [Table](/rocket/config/type.Table.html).
/// [Table](::rocket::config::Table).
MalformedConfiguration,
/// The required `url` key is missing.
MissingUrl,
Expand Down Expand Up @@ -612,20 +611,16 @@ impl<'a> Display for DatabaseConfigError {
/// `foo::ConnectionManager`
/// * `foo::Error`, errors resulting from manager instantiation
///
/// [`r2d2`]: https://crates.io/crates/r2d2
/// [`r2d2::ManageConnection`]: http://docs.rs/r2d2/0.8/r2d2/trait.ManageConnection.html
///
/// In order for Rocket to generate the required code to automatically provision
/// a r2d2 connection pool into application state, the `Poolable` trait needs to
/// be implemented for the connection type. The following example implements
/// `Poolable` for `foo::Connection`:
///
/// ```rust
/// use rocket_contrib::databases::{r2d2, DbError, DatabaseConfig, Poolable};
///
/// # mod foo {
/// # use rocket_contrib::databases::r2d2;
/// # use std::fmt;
/// # use rocket_contrib::databases::r2d2;
/// # #[derive(Debug)] pub struct Error;
/// # impl ::std::error::Error for Error { }
/// # impl fmt::Display for Error {
Expand All @@ -637,6 +632,10 @@ impl<'a> Display for DatabaseConfigError {
/// #
/// # type Result<T> = ::std::result::Result<T, Error>;
/// #
/// # impl ConnectionManager {
/// # pub fn new(url: &str) -> Result<Self> { Err(Error) }
/// # }
/// #
/// # impl self::r2d2::ManageConnection for ConnectionManager {
/// # type Connection = Connection;
/// # type Error = Error;
Expand All @@ -651,16 +650,13 @@ impl<'a> Display for DatabaseConfigError {
/// type Error = DbError<foo::Error>;
///
/// fn pool(config: DatabaseConfig) -> Result<r2d2::Pool<Self::Manager>, Self::Error> {
/// # let _ = config; /*
/// let manager = foo::ConnectionManager::new(config.url)
/// .map_err(DbError::Custom)?;
///
/// r2d2::Pool::builder()
/// .max_size(config.pool_size)
/// .build(manager)
/// .map_err(DbError::PoolError)
/// # */
/// # Err(DbError::Custom(foo::Error))
/// }
/// }
/// ```
Expand Down
32 changes: 18 additions & 14 deletions contrib/lib/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ impl<T> DerefMut for Json<T> {
/// this type implements [`Responder`], allowing a value of this type to be
/// returned directly from a handler.
///
/// [`Value`]: https://docs.rs/serde_json/1.0.2/serde_json/value/enum.Value.html
/// [`Responder`]: /rocket/response/trait.Responder.html
/// [`Value`]: serde_json::value
/// [`Responder`]: rocket::response::Responder
///
/// # `Responder`
///
Expand All @@ -175,16 +175,18 @@ impl<T> DerefMut for Json<T> {
///
/// # Usage
///
/// A value of this type is constructed via the
/// [`json!`](/rocket_contrib/macro.json.html) macro. The macro and this type
/// are typically used to construct JSON values in an ad-hoc fashion during
/// request handling. This looks something like:
/// A value of this type is constructed via the [`json!`](json) macro. The macro
/// and this type are typically used to construct JSON values in an ad-hoc
/// fashion during request handling. This looks something like:
///
/// ```rust,ignore
/// ```rust
/// # #![feature(proc_macro_hygiene, decl_macro)]
/// # #[macro_use] extern crate rocket;
/// # #[macro_use] extern crate rocket_contrib;
/// use rocket_contrib::JsonValue;
///
/// #[get("/item")]
/// fn get_item() -> JsonValue {
/// #[get("/json")]
/// fn get_json() -> JsonValue {
/// json!({
/// "id": 83,
/// "values": [1, 2, 3, 4]
Expand Down Expand Up @@ -259,15 +261,17 @@ impl<'a> Responder<'a> for JsonValue {
/// To import the macro, add the `#[macro_use]` attribute to the `extern crate
/// rocket_contrib` invocation:
///
/// ```rust,ignore
/// ```rust
/// #[macro_use] extern crate rocket_contrib;
/// ```
///
/// The return type of a `json!` invocation is
/// [`JsonValue`](/rocket_contrib/struct.JsonValue.html). A value created with
/// this macro can be returned from a handler as follows:
/// The return type of a `json!` invocation is [`JsonValue`]. A value created
/// with this macro can be returned from a handler as follows:
///
/// ```rust,ignore
/// ```rust
/// # #![feature(proc_macro_hygiene, decl_macro)]
/// # #[macro_use] extern crate rocket;
/// # #[macro_use] extern crate rocket_contrib;
/// use rocket_contrib::JsonValue;
///
/// #[get("/json")]
Expand Down
18 changes: 8 additions & 10 deletions contrib/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,26 @@
//!
//! These libraries are always kept in-sync with the core Rocket library. They
//! provide common, but not fundamental, abstractions to be used by Rocket
//! applications. In particular, contributor libraries typically export types
//! implementing a combination of the `FromRequest`, `FromParam`, and
//! `Responder` traits.
//! applications.
//!
//! Each module in this library is held behind a feature flag, with the most
//! common modules exposed by default. The present feature list is below, with
//! an asterisk next to the features that are enabled by default:
//!
//! * [json*](struct.Json.html)
//! * [json*](Json)
//! * [static_files*](static_files)
//! * [msgpack](struct.MsgPack.html)
//! * [handlebars_templates](struct.Template.html)
//! * [tera_templates](struct.Template.html)
//! * [uuid](struct.Uuid.html)
//! * [${database}_pool](databases/index.html)
//! * [msgpack](MsgPack)
//! * [handlebars_templates](Template)
//! * [tera_templates](Template)
//! * [uuid](Uuid)
//! * [${database}_pool](databases)
//!
//! The recommend way to include features from this crate via Cargo in your
//! project is by adding a `[dependencies.rocket_contrib]` section to your
//! `Cargo.toml` file, setting `default-features` to false, and specifying
//! features manually. For example, to use the JSON module, you would add:
//!
//! ```toml,ignore
//! ```toml
//! [dependencies.rocket_contrib]
//! version = "*"
//! default-features = false
Expand Down
9 changes: 4 additions & 5 deletions contrib/lib/src/templates/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,23 @@ pub trait Engine: Send + Sync + 'static {
/// });
/// ```
///
/// [`tera::Value`]: https://docs.rs/tera/0.10.10/tera/enum.Value.html
/// [`tera::Result`]: https://docs.rs/tera/0.10.10/tera/type.Result.html
/// [`tera::Value`]: ::tera::Value
/// [`tera::Result`]: ::tera::Result
pub struct Engines {
#[cfg(feature = "tera_templates")]
/// A [`Tera`] structure. This field is only available when the
/// `tera_templates` feature is enabled. When calling methods on the `Tera`
/// instance, ensure you use types imported from `rocket_contrib::tera` to
/// avoid version mismatches.
///
/// [`Tera`]: https://docs.rs/tera/0.10.10/tera/struct.Tera.html
/// [`Tera`]: tera::Tera
pub tera: Tera,
/// A [`Handlebars`] structure. This field is only available when the
/// `handlebars_templates` feature is enabled. When calling methods on the
/// `Tera` instance, ensure you use types
/// imported from `rocket_contrib::handlebars` to avoid version mismatches.
///
/// [`Handlebars`]:
/// https://docs.rs/handlebars/0.29.1/handlebars/struct.Handlebars.html
/// [`Handlebars`]: handlebars::Handlebars
#[cfg(feature = "handlebars_templates")]
pub handlebars: Handlebars,
}
Expand Down
8 changes: 4 additions & 4 deletions contrib/lib/src/templates/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use rocket::request::{self, FromRequest};

use super::ContextManager;

/// The `TemplateMetadata` type: implements `FromRequest`, allowing dynamic
/// queries about template metadata.
/// Implements [`FromRequest`] for dynamiclly querying template metadata.
///
/// # Usage
///
/// First, ensure that the template [fairing](`rocket::fairing`),
/// [`Template::fairing()`] is attached to your Rocket application:
/// First, ensure that the template [fairing](rocket::fairing),
/// [`Template::fairing()`](::Template::fairing()) is attached to your Rocket
/// application:
///
/// ```rust
/// # extern crate rocket;
Expand Down
24 changes: 8 additions & 16 deletions contrib/lib/src/templates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@ const DEFAULT_TEMPLATE_DIR: &str = "templates";
/// Template discovery is actualized by the template fairing, which itself is
/// created via the [`Template::fairing()`] or [`Template::custom()`] method. In
/// order for _any_ templates to be rendered, the template fairing _must_ be
/// [attached](/rocket/struct.Rocket.html#method.attach) to the running Rocket
/// instance. Failure to do so will result in an error.
/// [attached](rocket::Rocket::attach()) to the running Rocket instance. Failure
/// to do so will result in an error.
///
/// Templates are rendered with the `render` method. The method takes in the
/// name of a template and a context to render the template with. The context
/// can be any type that implements `Serialize` from
/// [Serde](https://github.com/serde-rs/json) and would serialize to an `Object`
/// value.
/// can be any type that implements [`Serialize`] from [`serde`] and would
/// serialize to an `Object` value.
///
/// In debug mode (without the `--release` flag passed to `cargo`), templates
/// will be automatically reloaded from disk if any changes have been made to
Expand All @@ -89,15 +88,15 @@ const DEFAULT_TEMPLATE_DIR: &str = "templates";
/// feature, or both, to the `rocket_contrib` dependencies section of your
/// `Cargo.toml`:
///
/// ```toml,ignore
/// ```toml
/// [dependencies.rocket_contrib]
/// version = "*"
/// default-features = false
/// features = ["handlebars_templates", "tera_templates"]
/// ```
///
/// Then, ensure that the template [fairing](/rocket/fairing/) is attached to
/// your Rocket application:
/// Then, ensure that the template [`Fairing`] is attached to your Rocket
/// application:
///
/// ```rust
/// extern crate rocket;
Expand All @@ -114,7 +113,7 @@ const DEFAULT_TEMPLATE_DIR: &str = "templates";
/// }
/// ```
///
/// The `Template` type implements Rocket's `Responder` trait, so it can be
/// The `Template` type implements Rocket's [`Responder`] trait, so it can be
/// returned from a request handler directly:
///
/// ```rust,ignore
Expand All @@ -130,9 +129,6 @@ const DEFAULT_TEMPLATE_DIR: &str = "templates";
/// You can use the [`Template::custom()`] method to construct a fairing with
/// customized templating engines. Among other things, this method allows you to
/// register template helpers and register templates from strings.
///
/// [`Template::custom()`]: /rocket_contrib/struct.Template.html#method.custom
/// [`Template::fairing()`]: /rocket_contrib/struct.Template.html#method.fairing
#[derive(Debug)]
pub struct Template {
name: Cow<'static, str>,
Expand Down Expand Up @@ -161,8 +157,6 @@ impl Template {
/// If you wish to customize the internal templating engines, use
/// [`Template::custom()`] instead.
///
/// [`Template::custom()`]: /rocket_contrib/struct.Template.html#method.custom
///
/// # Example
///
/// To attach this fairing, simple call `attach` on the application's
Expand Down Expand Up @@ -192,8 +186,6 @@ impl Template {
/// templating engines via the parameter `f`. Note that only the enabled
/// templating engines will be accessible from the `Engines` type.
///
/// [`Template::fairing()`]: /rocket_contrib/struct.Template.html#method.fairing
///
/// # Example
///
/// ```rust
Expand Down
4 changes: 2 additions & 2 deletions contrib/lib/src/uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use rocket::http::RawStr;

pub use self::uuid_ext::parser::ParseError as UuidParseError;

/// Implements `FromParam` and `FormFormValue` for accepting UUID values from
/// the [uuid](https://github.com/rust-lang-nursery/uuid) crate.
/// Implements [`FromParam`] and [`FromFormValue`] for accepting UUID values
/// from the [`uuid`] crate.
///
/// # Usage
///
Expand Down
16 changes: 8 additions & 8 deletions core/codegen_next/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
//! field name is expected. In this case, the `field` name in the attribute is
//! used instead of the structure's actual field name when parsing a form.
//!
//! [`FromForm`]: /rocket/request/trait.FromForm.html
//! [`FromFormValue`]: /rocket/request/trait.FromFormValue.html
//! [`FromForm`]: rocket::request::FromForm
//! [`FromFormValue`]: rocket::request::FromFormValue
//!
//! ### `FromFormValue`
//!
Expand Down Expand Up @@ -306,9 +306,9 @@
//! The [`Response`] produced from the generated implementation will have its
//! content-type overriden to this value.
//!
//! [`Responder`]: /rocket/response/trait.Responder.html
//! [`Response`]: /rocket/struct.Response.html
//! [`Response::set_header()`]: /rocket/struct.Response.html#method.set_header
//! [`Responder`]: rocket::response::Responder
//! [`Response`]: rocket::Response
//! [`Response::set_header()`]: rocket::Response::set_header()
//!
//! ## Procedural Macros
//!
Expand Down Expand Up @@ -404,9 +404,9 @@
//! If a mount-point is provided, the mount-point is prepended to the route's
//! URI.
//!
//! [`Uri`]: /rocket/http/uri/struct.URI.html
//! [`FromUriParam`]: /rocket/http/uri/trait.FromUriParam.html
//! [`UriDisplay`]: /rocket/http/uri/trait.UriDisplay.html
//! [`Uri`]: http::uri::URI
//! [`FromUriParam`]: http::uri::FromUriParam
//! [`UriDisplay`]: http::uri::UriDisplay
//!
//! # Debugging Codegen
//!
Expand Down
Loading

3 comments on commit 28f2a33

@jhpratt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergioBenitez Are you positive this commit is safe? When running cargo doc on a server, I get a few errors relating to intra-crate links. The source code is available at r-spacex/Enceladus-API-rs if you'd like to try to repro. Compiling on 1.33.0-nightly (2cf1f5dda 2018-12-11); I'm unable to update to the current nightly (2019-01-21) because clippy and rls aren't present for some reason.

@jebrosen
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jhpratt I do see a few doc warnings which are turned into errors by #[deny(warnings)]. Despite the warnings, the links seem to be generated correctly. rust-lang/rust#54316 looks relevant, but I don't see an open issue about false positives for that lint.

@jyn514
Copy link

@jyn514 jyn514 commented on 28f2a33 Dec 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running cargo doc on a server, I get a few errors relating to intra-crate links.

This was probably rust-lang/rust#65983.

Please sign in to comment.