Skip to content

Commit

Permalink
Return used portions of schema and prune more carefully. (#234) (#235)
Browse files Browse the repository at this point in the history
* Revert "Remove stale unimplemented portions of schema. (#225)"

This reverts commit a9e26c6.

* Return used portions of schema and prune more carefully.
  • Loading branch information
obi1kenobi committed Jul 21, 2023
1 parent 6320822 commit 00ce4fd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
9 changes: 2 additions & 7 deletions src/adapter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ impl<'a> Adapter<'a> for RustdocAdapter<'a> {
properties::resolve_implemented_trait_property(contexts, property_name)
}
"Static" => properties::resolve_static_property(contexts, property_name),
"RawType" | "ResolvedPathType" | "PrimitiveType"
if matches!(property_name.as_ref(), "name") =>
{
"RawType" | "ResolvedPathType" if matches!(property_name.as_ref(), "name") => {
// fields from "RawType"
properties::resolve_raw_type_property(contexts, property_name)
}
Expand Down Expand Up @@ -231,7 +229,7 @@ impl<'a> Adapter<'a> for RustdocAdapter<'a> {
let coerce_to_type = coerce_to_type.clone();
match type_name.as_ref() {
"Item" | "Variant" | "FunctionLike" | "Importable" | "ImplOwner" | "RawType"
| "ResolvedPathType" | "GlobalValue" => {
| "GlobalValue" => {
resolve_coercion_with(contexts, move |vertex| {
let actual_type_name = vertex.typename();

Expand All @@ -241,9 +239,6 @@ impl<'a> Adapter<'a> for RustdocAdapter<'a> {
"PlainVariant" | "TupleVariant" | "StructVariant"
),
"ImplOwner" => matches!(actual_type_name, "Struct" | "Enum"),
"ResolvedPathType" => {
matches!(actual_type_name, "ResolvedPathType" | "ImplementedTrait")
}
"GlobalValue" => matches!(actual_type_name, "Constant" | "Static",),
_ => {
// The remaining types are final (don't have any subtypes)
Expand Down
3 changes: 1 addition & 2 deletions src/adapter/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ impl<'a> Typename for Vertex<'a> {
VertexKind::ImplementedTrait(..) => "ImplementedTrait",
VertexKind::RawType(ty) => match ty {
rustdoc_types::Type::ResolvedPath { .. } => "ResolvedPathType",
rustdoc_types::Type::Primitive(..) => "PrimitiveType",
_ => "OtherType",
_ => "RawType",
},
VertexKind::FunctionParameter(..) => "FunctionParameter",
VertexKind::FunctionAbi(..) => "FunctionAbi",
Expand Down
33 changes: 33 additions & 0 deletions src/rustdoc_schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ type StructField implements Item {
# edges from Item
span: Span
attribute: [Attribute!]

# own edges
raw_type: RawType
}

"""
Expand Down Expand Up @@ -843,3 +846,33 @@ type AssociatedConstant implements Item {
span: Span
attribute: [Attribute!]
}

"""
A type represented in the "raw" rustdoc JSON representation.
Copiously detailed, but not the easiest to use due to its complexity.
This interface is a temporary, perma-unstable type intended to be used
only until the rustdoc JSON format is stabilized and until subsequently
we are able to design a better, more permanent representation for
Rust types in this schema.
https://docs.rs/rustdoc-types/latest/rustdoc_types/enum.Type.html
"""
interface RawType {
name: String!
}

"""
Represents a struct, enum, or trait.
https://docs.rs/rustdoc-types/latest/rustdoc_types/enum.Type.html#variant.ResolvedPath
"""
type ResolvedPathType implements RawType {
"""
The fully-qualified canonical name of the type.
For example: "core::marker::PhantomData" or "std::marker::PhantomData"
"""
name: String!
}

0 comments on commit 00ce4fd

Please sign in to comment.