Add descriptions for NodeTypes (#1044)
* Add descriptions for NodeTypes As highlighted by @decentralion in issue #807, we need descriptions for Node and Edge types in the UI to explain to users what each Node and Edge type does. This PR modifies the type definition for `NodeType` and adds a `+description: string` field, then updates all NodeTypes throughout the codebase with descriptions. Test plan: Verify that all tests pass and the descriptions makes sense.
This commit is contained in:
parent
5c2f232017
commit
e0762303d4
|
@ -13,6 +13,8 @@ export const fallbackNodeType: NodeType = Object.freeze({
|
||||||
pluralName: "nodes",
|
pluralName: "nodes",
|
||||||
prefix: NodeAddress.empty,
|
prefix: NodeAddress.empty,
|
||||||
defaultWeight: 1,
|
defaultWeight: 1,
|
||||||
|
description:
|
||||||
|
"The fallback NodeType for nodes which don't have any other type",
|
||||||
});
|
});
|
||||||
|
|
||||||
export const fallbackEdgeType: EdgeType = Object.freeze({
|
export const fallbackEdgeType: EdgeType = Object.freeze({
|
||||||
|
|
|
@ -66,6 +66,9 @@ export type NodeType = {|
|
||||||
// normal importance", and the weights scale linearly from there (i.e. 2
|
// normal importance", and the weights scale linearly from there (i.e. 2
|
||||||
// means twice as important).
|
// means twice as important).
|
||||||
+defaultWeight: number,
|
+defaultWeight: number,
|
||||||
|
// The `description` property should be a human-readable string that makes
|
||||||
|
// it clear to a user what each NodeType does
|
||||||
|
+description: string,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -149,6 +149,7 @@ describe("explorer/pagerankTable/Aggregation", () => {
|
||||||
pluralName: "whatDoth",
|
pluralName: "whatDoth",
|
||||||
defaultWeight: 1,
|
defaultWeight: 1,
|
||||||
prefix: NodeAddress.empty,
|
prefix: NodeAddress.empty,
|
||||||
|
description: "An example NodeType for testing purposes",
|
||||||
};
|
};
|
||||||
const edgeType: EdgeType = {
|
const edgeType: EdgeType = {
|
||||||
forwardName: "marsellus",
|
forwardName: "marsellus",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import {EdgeAddress, NodeAddress} from "../../core/graph";
|
import {EdgeAddress, NodeAddress, type NodeAddressT} from "../../core/graph";
|
||||||
import * as NullUtil from "../../util/null";
|
import * as NullUtil from "../../util/null";
|
||||||
import {
|
import {
|
||||||
aggregateByNodeType,
|
aggregateByNodeType,
|
||||||
|
@ -9,42 +9,51 @@ import {
|
||||||
aggregateFlat,
|
aggregateFlat,
|
||||||
aggregationKey,
|
aggregationKey,
|
||||||
} from "./aggregate";
|
} from "./aggregate";
|
||||||
|
import type {NodeType} from "../../analysis/types";
|
||||||
|
|
||||||
describe("explorer/pagerankTable/aggregate", () => {
|
describe("explorer/pagerankTable/aggregate", () => {
|
||||||
// TODO: If making major modifications to these tests, consider switching
|
// TODO: If making major modifications to these tests, consider switching
|
||||||
// from the hand-maintained connections and types, and instead use the demo
|
// from the hand-maintained connections and types, and instead use the demo
|
||||||
// adadpters from app/adapters/demoAdapters
|
// adadpters from app/adapters/demoAdapters
|
||||||
function example() {
|
function example() {
|
||||||
const nodes = {
|
const nodes: {+[string]: NodeAddressT} = {
|
||||||
root: NodeAddress.fromParts(["root"]),
|
root: NodeAddress.fromParts(["root"]),
|
||||||
zap: NodeAddress.fromParts(["zap"]),
|
zap: NodeAddress.fromParts(["zap"]),
|
||||||
kif: NodeAddress.fromParts(["kif"]),
|
kif: NodeAddress.fromParts(["kif"]),
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeTypes = {
|
const nodeTypes: {+[string]: NodeType} = {
|
||||||
root: {
|
root: {
|
||||||
name: "root",
|
name: "root",
|
||||||
pluralName: "roots",
|
pluralName: "roots",
|
||||||
prefix: nodes.root,
|
prefix: nodes.root,
|
||||||
defaultWeight: 0,
|
defaultWeight: 0,
|
||||||
|
description:
|
||||||
|
"This NodeType corresponds to the node with the address named `root`",
|
||||||
},
|
},
|
||||||
zap: {
|
zap: {
|
||||||
name: "zap",
|
name: "zap",
|
||||||
pluralName: "zaps",
|
pluralName: "zaps",
|
||||||
prefix: nodes.zap,
|
prefix: nodes.zap,
|
||||||
defaultWeight: 0,
|
defaultWeight: 0,
|
||||||
|
description:
|
||||||
|
"This NodeType corresponds to the node with the address named `zap`",
|
||||||
},
|
},
|
||||||
kif: {
|
kif: {
|
||||||
name: "kif",
|
name: "kif",
|
||||||
pluralName: "kifs",
|
pluralName: "kifs",
|
||||||
prefix: nodes.kif,
|
prefix: nodes.kif,
|
||||||
defaultWeight: 0,
|
defaultWeight: 0,
|
||||||
|
description:
|
||||||
|
"This NodeType corresponds to the node with the address named `kif`",
|
||||||
},
|
},
|
||||||
empty: {
|
empty: {
|
||||||
name: "empty",
|
name: "empty",
|
||||||
pluralName: "empties",
|
pluralName: "empties",
|
||||||
prefix: NodeAddress.empty,
|
prefix: NodeAddress.empty,
|
||||||
defaultWeight: 0,
|
defaultWeight: 0,
|
||||||
|
description:
|
||||||
|
"This NodeType is for an empty address, which matches every node",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ export const inserterNodeType: NodeType = Object.freeze({
|
||||||
pluralName: "inserters",
|
pluralName: "inserters",
|
||||||
prefix: NodeAddress.fromParts(["factorio", "inserter"]),
|
prefix: NodeAddress.fromParts(["factorio", "inserter"]),
|
||||||
defaultWeight: 1,
|
defaultWeight: 1,
|
||||||
|
description: "Nodes for Factorio inserter objects in demo plugin",
|
||||||
});
|
});
|
||||||
|
|
||||||
export const machineNodeType: NodeType = Object.freeze({
|
export const machineNodeType: NodeType = Object.freeze({
|
||||||
|
@ -18,6 +19,7 @@ export const machineNodeType: NodeType = Object.freeze({
|
||||||
pluralName: "machines",
|
pluralName: "machines",
|
||||||
prefix: NodeAddress.fromParts(["factorio", "machine"]),
|
prefix: NodeAddress.fromParts(["factorio", "machine"]),
|
||||||
defaultWeight: 2,
|
defaultWeight: 2,
|
||||||
|
description: "Nodes for Factorio machine objects in demo plugin",
|
||||||
});
|
});
|
||||||
|
|
||||||
export const assemblesEdgeType: EdgeType = Object.freeze({
|
export const assemblesEdgeType: EdgeType = Object.freeze({
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import type {PluginDeclaration} from "../../analysis/pluginDeclaration";
|
import type {PluginDeclaration} from "../../analysis/pluginDeclaration";
|
||||||
|
import type {NodeType} from "../../analysis/types";
|
||||||
import * as N from "./nodes";
|
import * as N from "./nodes";
|
||||||
import * as E from "./edges";
|
import * as E from "./edges";
|
||||||
|
|
||||||
const commitNodeType = Object.freeze({
|
const commitNodeType: NodeType = Object.freeze({
|
||||||
name: "Commit",
|
name: "Commit",
|
||||||
pluralName: "Commits",
|
pluralName: "Commits",
|
||||||
prefix: N.Prefix.commit,
|
prefix: N.Prefix.commit,
|
||||||
defaultWeight: 2,
|
defaultWeight: 2,
|
||||||
|
description: "NodeType representing a git commit",
|
||||||
});
|
});
|
||||||
|
|
||||||
const hasParentEdgeType = Object.freeze({
|
const hasParentEdgeType = Object.freeze({
|
||||||
|
|
|
@ -9,6 +9,7 @@ const repoNodeType = Object.freeze({
|
||||||
pluralName: "Repositories",
|
pluralName: "Repositories",
|
||||||
prefix: N.Prefix.repo,
|
prefix: N.Prefix.repo,
|
||||||
defaultWeight: 4,
|
defaultWeight: 4,
|
||||||
|
description: "NodeType for a GitHub repository",
|
||||||
});
|
});
|
||||||
|
|
||||||
const issueNodeType = Object.freeze({
|
const issueNodeType = Object.freeze({
|
||||||
|
@ -16,6 +17,7 @@ const issueNodeType = Object.freeze({
|
||||||
pluralName: "Issues",
|
pluralName: "Issues",
|
||||||
prefix: N.Prefix.issue,
|
prefix: N.Prefix.issue,
|
||||||
defaultWeight: 2,
|
defaultWeight: 2,
|
||||||
|
description: "NodeType for a GitHub issue",
|
||||||
});
|
});
|
||||||
|
|
||||||
const pullNodeType = Object.freeze({
|
const pullNodeType = Object.freeze({
|
||||||
|
@ -23,6 +25,7 @@ const pullNodeType = Object.freeze({
|
||||||
pluralName: "Pull requests",
|
pluralName: "Pull requests",
|
||||||
prefix: N.Prefix.pull,
|
prefix: N.Prefix.pull,
|
||||||
defaultWeight: 4,
|
defaultWeight: 4,
|
||||||
|
description: "NodeType for a GitHub pull request",
|
||||||
});
|
});
|
||||||
|
|
||||||
const reviewNodeType = Object.freeze({
|
const reviewNodeType = Object.freeze({
|
||||||
|
@ -30,6 +33,7 @@ const reviewNodeType = Object.freeze({
|
||||||
pluralName: "Pull request reviews",
|
pluralName: "Pull request reviews",
|
||||||
prefix: N.Prefix.review,
|
prefix: N.Prefix.review,
|
||||||
defaultWeight: 1,
|
defaultWeight: 1,
|
||||||
|
description: "NodeType for a GitHub code review",
|
||||||
});
|
});
|
||||||
|
|
||||||
const commentNodeType = Object.freeze({
|
const commentNodeType = Object.freeze({
|
||||||
|
@ -37,6 +41,7 @@ const commentNodeType = Object.freeze({
|
||||||
pluralName: "Comments",
|
pluralName: "Comments",
|
||||||
prefix: N.Prefix.comment,
|
prefix: N.Prefix.comment,
|
||||||
defaultWeight: 1,
|
defaultWeight: 1,
|
||||||
|
description: "NodeType for a GitHub comment",
|
||||||
});
|
});
|
||||||
|
|
||||||
const userNodeType = Object.freeze({
|
const userNodeType = Object.freeze({
|
||||||
|
@ -44,6 +49,7 @@ const userNodeType = Object.freeze({
|
||||||
pluralName: "Users",
|
pluralName: "Users",
|
||||||
prefix: N.Prefix.user,
|
prefix: N.Prefix.user,
|
||||||
defaultWeight: 1,
|
defaultWeight: 1,
|
||||||
|
description: "NodeType for a GitHub user",
|
||||||
});
|
});
|
||||||
|
|
||||||
const botNodeType = Object.freeze({
|
const botNodeType = Object.freeze({
|
||||||
|
@ -51,6 +57,7 @@ const botNodeType = Object.freeze({
|
||||||
pluralName: "Bots",
|
pluralName: "Bots",
|
||||||
prefix: N.Prefix.bot,
|
prefix: N.Prefix.bot,
|
||||||
defaultWeight: 0.25,
|
defaultWeight: 0.25,
|
||||||
|
description: "NodeType for a GitHub bot account",
|
||||||
});
|
});
|
||||||
|
|
||||||
const nodeTypes = Object.freeze([
|
const nodeTypes = Object.freeze([
|
||||||
|
|
Loading…
Reference in New Issue