Skip to content

Commit

Permalink
Integrate codespell for Book (#1121)
Browse files Browse the repository at this point in the history
- add `codespell` CI job
- add `book.codespell` Makefile command
- fix Book typos found by codespell

Co-authored-by: Kai Ren <[email protected]>
  • Loading branch information
kianmeng and tyranron authored Oct 27, 2023
1 parent d11e351 commit 0fc95dd
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[codespell]
ignore-words-list = crate
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
if: ${{ github.event_name == 'pull_request' }}
needs:
- bench
- codespell
- clippy
- feature
- msrv
Expand Down Expand Up @@ -54,6 +55,15 @@ jobs:

- run: make cargo.lint

codespell:
name: codespell (Book)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: codespell-project/actions-codespell@v2
with:
path: book/

rustfmt:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -342,6 +352,7 @@ jobs:
needs:
- bench
- clippy
- codespell
- feature
- msrv
- package
Expand Down Expand Up @@ -391,7 +402,7 @@ jobs:
name: deploy (Book)
if: ${{ github.ref == 'refs/heads/master'
|| startsWith(github.ref, 'refs/tags/juniper@') }}
needs: ["test", "test-book"]
needs: ["codespell", "test", "test-book"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
book: book.build


codespell: book.codespell


fmt: cargo.fmt


Expand Down Expand Up @@ -137,6 +140,15 @@ book.build:
mdbook build book/ $(if $(call eq,$(out),),,-d $(out))


# Spellcheck Book.
#
# Usage:
# make book.codespell [fix=(no|yes)]

book.codespell:
codespell book/ $(if $(call eq,$(fix),yes),--write-changes,)


# Serve Book on some port.
#
# Usage:
Expand Down Expand Up @@ -180,8 +192,8 @@ graphql-playground:
# .PHONY section #
##################

.PHONY: book fmt lint release test \
book.build book.serve \
.PHONY: book codespell fmt lint release test \
book.build book.codespell book.serve \
cargo.fmt cargo.lint cargo.release cargo.test \
graphiql graphql-playground \
test.book test.cargo
2 changes: 1 addition & 1 deletion book/src/advanced/dataloaders.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Avoiding the N+1 Problem With Dataloaders

A common issue with graphql servers is how the resolvers query their datasource.
This issue results in a large number of unneccessary database queries or http requests.
This issue results in a large number of unnecessary database queries or http requests.
Say you were wanting to list a bunch of cults people were in

```graphql
Expand Down
2 changes: 1 addition & 1 deletion book/src/advanced/multiple_ops_per_request.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Multiple operations per request

The GraphQL standard generally assumes there will be one server request for each client operation you want to perform (such as a query or mutation). This is conceptually simple but has the potential to be inefficent.
The GraphQL standard generally assumes there will be one server request for each client operation you want to perform (such as a query or mutation). This is conceptually simple but has the potential to be inefficient.

Some client libraries such as [apollo-link-batch-http](https://www.apollographql.com/docs/link/links/batch-http.html) have added the ability to batch operations in a single HTTP request to save network round-trips and potentially increase performance. There are some [tradeoffs](https://blog.apollographql.com/batching-client-graphql-queries-a685f5bcd41b) that should be considered before batching requests.

Expand Down
6 changes: 3 additions & 3 deletions book/src/types/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ Also, enum name can be specified explicitly, if desired.
# extern crate juniper;
use juniper::{graphql_interface, GraphQLObject};

#[graphql_interface(enum = CharaterInterface, for = Human)]
#[graphql_interface(enum = CharacterInterface, for = Human)]
trait Character {
fn id(&self) -> &str;
}

#[derive(GraphQLObject)]
#[graphql(impl = CharaterInterface)]
#[graphql(impl = CharacterInterface)]
struct Human {
id: String,
home_planet: String,
Expand Down Expand Up @@ -248,7 +248,7 @@ use juniper::{graphql_interface, GraphQLObject};
pub struct ObjA {
id: Vec<String>,
// ^^ the evaluated program panicked at
// 'Failed to implement interface `Character` on `ObjA`: Field `id`: implementor is expected to return a subtype of
// 'Failed to implement interface `Character` on `ObjA`: Field `id`: implementer is expected to return a subtype of
// interface's return object: `[String!]!` is not a subtype of `String!`.'
}
Expand Down
2 changes: 1 addition & 1 deletion book/src/types/objects/using_contexts.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl User {
let DatabaseContext(context) = context;
// If context is immutable use .read() on RwLock.
let mut context = context.write().await;
// Preform a mutable operation.
// Perform a mutable operation.
context.requested_count.entry(self.id).and_modify(|e| { *e += 1 }).or_insert(1).clone()
}

Expand Down
2 changes: 1 addition & 1 deletion book/src/types/other-index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Other Types

The GraphQL type system provides several types in additon to objects.
The GraphQL type system provides several types in addition to objects.

Find out more about each type below:

Expand Down

0 comments on commit 0fc95dd

Please sign in to comment.