Skip to content

Commit

Permalink
Do not integrate the ToC in the left sidebar on the documentation web…
Browse files Browse the repository at this point in the history
…site. We adjusted the allowed width for pavex errors accordingly.
  • Loading branch information
LukeMathWalker committed Mar 30, 2024
1 parent ab45cc3 commit 6b4eae4
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 58 deletions.
27 changes: 7 additions & 20 deletions doc_examples/guide/dependency_injection/kit/project/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use std::future::IntoFuture;

use pavex::middleware::Next;
use pavex::middleware::Processing;
use pavex::response::Response;

use crate::user::User;

pub async fn reject_anonymous<C>(user: &User, next: Next<C>) -> Response
where
C: IntoFuture<Output=Response>,
pub fn reject_anonymous(user: &User) -> Processing
{
if let User::Anonymous = user {
return Response::unauthorized();
let r = Response::unauthorized();
Processing::EarlyReturn(r)
} else {
Processing::Continue
}
next.into_future().await
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use pavex::f;
pub fn blueprint() -> Blueprint {
let mut bp = Blueprint::new();
bp.constructor(f!(crate::User::extract), Lifecycle::RequestScoped);
bp.wrap(f!(crate::authentication::reject_anonymous));
bp.pre_process(f!(crate::authentication::reject_anonymous));
bp.route(GET, "/greet", f!(crate::routes::greet));
bp
}
9 changes: 5 additions & 4 deletions doc_examples/quickstart/05-error.snap
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
ERROR:
× I can't invoke your request handler, `app::routes::greet::get`, because it needs an instance
│ of `app::user_agent::UserAgent` as input, but I can't find a constructor for that type.
× I can't invoke your request handler, `app::routes::greet::get`, because
│ it needs an instance of `app::user_agent::UserAgent` as input, but I can't
│ find a constructor for that type.
│
│ ╭─[app/src/routes/mod.rs:8:1]
│  8bp.route(GET, "/api/ping", f!(self::ping::get));
│  9bp.route(GET, "/api/greet/:name", f!(self::greet::get));
│ ·  ──────────┬─────────
[31m│[0m · [35;1m╰── The request handler was registered here[0m
[31m│[0m · [35;1mThe request handler was registered here ──╯[0m
│ 10 │ }
│ ╰────
│ ╭─[app/src/routes/greet.rs:10:1]
│ 10
│ 11pub fn get(params: PathParams<GreetParams>, user_agent: UserAgent) -> Response {
│ ·  ──────────┬──────────
[31m│[0m · [35;1mI don't know how to construct an instance of this input parameter[0m
[31m│[0m · [35;1mI don't know how to construct an instance of this input parameter[0m
│ 12if let UserAgent::Unknown = user_agent {
│ ╰────
│  help: Register a constructor for `app::user_agent::UserAgent`
Expand Down
8 changes: 4 additions & 4 deletions doc_examples/quickstart/07-error.snap
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ERROR:
[31m×[0m You registered a constructor that returns a `Result`, but you did not register an error
[31m│[0m handler for it. If I don't have an error handler, I don't know what to do with the error when
[31m│[0m the constructor fails!
[31m×[0m You registered a constructor that returns a `Result`, but you did not
[31m│[0m register an error handler for it. If I don't have an error handler, I
[31m│[0m don't know what to do with the error when the constructor fails!
│
│ ╭─[app/src/blueprint.rs:12:1]
│ 12configuration::register(&mut bp);
│ 13bp.request_scoped(f!(crate::user_agent::UserAgent::extract));
│ ·  ────────────────────┬────────────────────
[31m│[0m · [35;1m╰── The fallible constructor was registered here[0m
[31m│[0m · [35;1mThe fallible constructor was registered here[0m
│ 14
│ ╰────
│  help: Add an error handler via `.error_handler`
Expand Down
2 changes: 1 addition & 1 deletion doc_examples/tutorial_generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl ScriptRunner {
) -> Result<ScriptOutcome, anyhow::Error> {
let mut options = ScriptOptions::new();
let env_vars = HashMap::from([
("PAVEX_TTY_WIDTH".to_string(), "100".to_string()),
("PAVEX_TTY_WIDTH".to_string(), "80".to_string()),
("PAVEX_COLOR".to_string(), "always".to_string()),
("CARGO_TARGET_DIR".to_string(), self.target_dir.to_string()),
]);
Expand Down
21 changes: 2 additions & 19 deletions docs/overview/why_pavex.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,8 @@ Rust is a great language, but it has a large surface area: it's easy to feel lik
Pavex aims to **lower the barrier of entry**: you'll only need **an understanding of Rust core concepts to get up and running**.
When things go wrong, we'll be there to help you: Pavex's transpiler will provide **detailed error messages** to help you understand what went wrong and how to fix it.

```
ERROR:
× I can't invoke your wrapping middleware, `timeout`, because it needs an instance of
│ `TimeoutConfig` as input, but I can't find a constructor for that type.
│ ╭─[src/blueprint.rs:18:1]
│ 18 │
│ 19 │ bp.wrap(f!(crate::timeout));
│ · ────────┬────────
│ · ╰── The wrapping middleware was registered here
│ 20 │
│ ╰────
│ ╭─[src/load_shedding.rs:5:1]
│ 5 │
│ 6 │ pub async fn timeout<T>(next: Next<T>, timeout_config: TimeoutConfig) -> Response
│ · ──────┬──────
│ · I don't know how to construct an instance of this input parameter
│ ╰────
│ help: Register a constructor for `TimeoutConfig`
```ansi-color
--8<-- "doc_examples/quickstart/07-error.snap"
```

## Safe
Expand Down
1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ theme:
- navigation.tabs.sticky
- navigation.footer
- navigation.top
- toc.integrate
- toc.follow
- content.action.edit
- content.code.copy
Expand Down

0 comments on commit 6b4eae4

Please sign in to comment.