Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more example queries to rustdoc playground. #381

Merged
merged 1 commit into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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