Skip to content

Commit

Permalink
Add more example queries to rustdoc playground.
Browse files Browse the repository at this point in the history
  • Loading branch information
obi1kenobi committed Jul 15, 2023
1 parent d4d9fea commit 94b36fd
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Traits with associated constants + their default values, if any.
# Try these crates: bitflags, arrayvec, digest, lock_api
query {
Crate {
item {
... on Trait {
name @output

associated_constant {
const: name @output
const_default_value: default @output

span {
filename @output
first_line: begin_line @output
}
}
}
}
}
}

vars:
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Traits with associated types.
# Try these crates: itertools, futures_core, anyhow, ansi_term
query {
Crate {
item {
... on Trait {
name @output

associated_type {
associated_type: name @output

span {
filename @output
first_line: begin_line @output
}
}
}
}
}
}

vars:
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Types with associated constants.
# Try these crates: memchr, crossbeam_epoch, chrono, arrayvec, getrandom, hashbrown
query {
Crate {
item {
# ImplOwner in our schema is a common supertype of
# vertex types like Struct and Enum:
# ones that may own "impl" blocks.
... on ImplOwner {
__typename @output # Get the exact type of this vertex.
name @output

inherent_impl {
associated_constant {
const: name @output
const_value: default @output

span {
filename @output
first_line: begin_line @output
}
}
}
}
}
}
}

vars:
{

}
15 changes: 15 additions & 0 deletions experiments/browser_based_querying/src/rustdoc/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import enumsWithTupleVariants from '../../example_queries/rustdoc/enums_with_tup
import itemsWithAllowedLints from '../../example_queries/rustdoc/items_with_allowed_lints.example';
import structsImportableByMultiplePaths from '../../example_queries/rustdoc/structs_importable_by_multiple_paths.example';
import traitsWithSupertraits from '../../example_queries/rustdoc/traits_with_supertraits.example';
import traitsWithAssociatedTypes from '../../example_queries/rustdoc/traits_with_associated_types.example';
import traitAssociatedConsts from '../../example_queries/rustdoc/trait_associated_consts.example';
import typeAssociatedConsts from '../../example_queries/rustdoc/type_associated_consts.example';

const RUSTDOC_SCHEMA = buildSchema(rustdocSchema);

Expand Down Expand Up @@ -47,6 +50,18 @@ const EXAMPLE_OPTIONS: { name: string; value: [string, string] }[] = [
name: 'Traits With Supertraits',
value: parseExample(traitsWithSupertraits),
},
{
name: 'Traits With Associated Types',
value: parseExample(traitsWithAssociatedTypes),
},
{
name: 'Traits With Associated Constants',
value: parseExample(traitAssociatedConsts),
},
{
name: 'Structs And Enums With Associated Constants',
value: parseExample(typeAssociatedConsts),
},
];

import crateNames from '../rustdocCrates';
Expand Down

0 comments on commit 94b36fd

Please sign in to comment.