improve type proto

This commit is contained in:
hsjobeki 2022-12-07 23:10:58 +01:00
parent f6fe44473f
commit cf85ab05fc
5 changed files with 116 additions and 30 deletions

View File

@ -198,8 +198,8 @@ export function BasicList(props: BasicListProps) {
{/* </Stack> */} {/* </Stack> */}
</Box> </Box>
<List aria-label="basic-list" sx={{ pt: 0 }}> <List aria-label="basic-list" sx={{ pt: 0 }}>
{items.map(({ item, key }) => ( {items.map(({ item, key }, idx) => (
<Box key={key}> <Box key={`${key}-${idx}`}>
<Slide <Slide
direction="up" direction="up"
in={key === selected} in={key === selected}

View File

@ -29,7 +29,11 @@ export default function FunctionItem(props: FunctionItemProps) {
> >
<Stack> <Stack>
<ListItemText primary={name} secondary={category} /> <ListItemText primary={name} secondary={category} />
<Typography>{`${fn_type} `}</Typography> <Typography
sx={{
color: !fn_type ? "text.secondary" : "text.primary",
}}
>{`${fn_type || "No type yet provided"} `}</Typography>
</Stack> </Stack>
</Paper> </Paper>
); );

View File

@ -89,12 +89,22 @@ export const Preview = (props: PreviewProps) => {
}} }}
disableTypography disableTypography
primary={ primary={
<Typography sx={{ color: "text.secondary" }}>Example</Typography> example && (
<Typography sx={{ color: "text.secondary" }}>
Example
</Typography>
)
} }
secondary={ secondary={
<Box sx={{ mt: -2, pl: 1.5 }}> example ? (
<Highlight className="nix">{example}</Highlight> <Box sx={{ mt: -2, pl: 1.5 }}>
</Box> <Highlight className="nix">{example}</Highlight>
</Box>
) : (
<Typography
sx={{ color: "text.secondary" }}
>{`no example yet provided`}</Typography>
)
} }
/> />
</ListItem> </ListItem>

View File

@ -78,20 +78,22 @@
"all-cabal-json": "all-cabal-json", "all-cabal-json": "all-cabal-json",
"crane": "crane", "crane": "crane",
"devshell": "devshell", "devshell": "devshell",
"flake-parts": "flake-parts",
"flake-utils-pre-commit": "flake-utils-pre-commit", "flake-utils-pre-commit": "flake-utils-pre-commit",
"ghc-utils": "ghc-utils", "ghc-utils": "ghc-utils",
"gomod2nix": "gomod2nix", "gomod2nix": "gomod2nix",
"mach-nix": "mach-nix", "mach-nix": "mach-nix",
"nix-pypi-fetcher": "nix-pypi-fetcher",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"poetry2nix": "poetry2nix", "poetry2nix": "poetry2nix",
"pre-commit-hooks": "pre-commit-hooks" "pre-commit-hooks": "pre-commit-hooks"
}, },
"locked": { "locked": {
"lastModified": 1667429039, "lastModified": 1670319715,
"narHash": "sha256-Lu6da25JioHzerkLHAHSO9suCQFzJ/XBjkcGCIbasLM=", "narHash": "sha256-W8GEZps6o+eZgMcYfoPbINiaH+yDhKENemgAcqCpu0s=",
"owner": "nix-community", "owner": "nix-community",
"repo": "dream2nix", "repo": "dream2nix",
"rev": "5252794e58eedb02d607fa3187ffead7becc81b0", "rev": "3681e0d5f5ab33a33238642a5fe004d372c66ab7",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -123,6 +125,24 @@
"type": "github" "type": "github"
} }
}, },
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1668450977,
"narHash": "sha256-cfLhMhnvXn6x1vPm+Jow3RiFAUSCw/l1utktCw5rVA4=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "d591857e9d7dd9ddbfba0ea02b43b927c3c0f1fa",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1659877975, "lastModified": 1659877975,
@ -216,6 +236,22 @@
"type": "indirect" "type": "indirect"
} }
}, },
"nix-pypi-fetcher": {
"flake": false,
"locked": {
"lastModified": 1669065297,
"narHash": "sha256-UStjXjNIuIm7SzMOWvuYWIHBkPUKQ8Id63BMJjnIDoA=",
"owner": "DavHau",
"repo": "nix-pypi-fetcher",
"rev": "a9885ac6a091576b5195d547ac743d45a2a615ac",
"type": "github"
},
"original": {
"owner": "DavHau",
"repo": "nix-pypi-fetcher",
"type": "github"
}
},
"nixdoc-fork": { "nixdoc-fork": {
"inputs": { "inputs": {
"flake-utils": [ "flake-utils": [
@ -227,11 +263,11 @@
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
}, },
"locked": { "locked": {
"lastModified": 1670069861, "lastModified": 1670448771,
"narHash": "sha256-K+uqDkNkw5W3Rv6kIfJ43htAkhZwqNrVXg+pW6lNez4=", "narHash": "sha256-vO89DbrTBCiV3e3E1cDv8Pldm9D4VRFiJzBx2iTt42c=",
"owner": "hsjobeki", "owner": "hsjobeki",
"repo": "nixdoc", "repo": "nixdoc",
"rev": "29813f73b02d85c57856afe8bc09d3ab308bfe55", "rev": "9fbc589aef4c0eb256ce9b360fbbc2d1ccf0aa8d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -255,18 +291,35 @@
"type": "indirect" "type": "indirect"
} }
}, },
"nixpkgs_2": { "nixpkgs-lib": {
"locked": { "locked": {
"lastModified": 1669919498, "dir": "lib",
"narHash": "sha256-cndPLdFj2V0OchIgz1sOVKZXOi+ETgSq/OqCCbWsRoo=", "lastModified": 1665349835,
"narHash": "sha256-UK4urM3iN80UXQ7EaOappDzcisYIuEURFRoGQ/yPkug=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "14c7bd44711b04c05cb78412451005415310b6bd", "rev": "34c5293a71ffdb2fe054eb5288adc1882c1eb0b1",
"type": "github" "type": "github"
}, },
"original": { "original": {
"dir": "lib",
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-22.11", "ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1670448685,
"narHash": "sha256-THuBf9WTup5IAPKH36BIRUu3gGbfC1nEbZwXSTGIrMA=",
"owner": "hsjobeki",
"repo": "nixpkgs",
"rev": "eb28895531d354ac9e55fbe721c1182a92c7b28e",
"type": "github"
},
"original": {
"owner": "hsjobeki",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -290,16 +343,16 @@
"poetry2nix": { "poetry2nix": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1632969109, "lastModified": 1666918719,
"narHash": "sha256-jPDclkkiAy5m2gGLBlKgH+lQtbF7tL4XxBrbSzw+Ioc=", "narHash": "sha256-BkK42fjAku+2WgCOv2/1NrPa754eQPV7gPBmoKQBWlc=",
"owner": "nix-community", "owner": "nix-community",
"repo": "poetry2nix", "repo": "poetry2nix",
"rev": "aee8f04296c39d88155e05d25cfc59dfdd41cc77", "rev": "289efb187123656a116b915206e66852f038720e",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nix-community", "owner": "nix-community",
"ref": "1.21.0", "ref": "1.36.0",
"repo": "poetry2nix", "repo": "poetry2nix",
"type": "github" "type": "github"
} }
@ -358,11 +411,11 @@
"nixpkgs": "nixpkgs_3" "nixpkgs": "nixpkgs_3"
}, },
"locked": { "locked": {
"lastModified": 1670034122, "lastModified": 1670380307,
"narHash": "sha256-EqmuOKucPWtMvCZtHraHr3Q3bgVszq1x2PoZtQkUuEk=", "narHash": "sha256-7fJN5ndnE8YbrrtYdqMo3gDV/BW37M4wNBRhjdfP/XY=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "a0d5773275ecd4f141d792d3a0376277c0fc0b65", "rev": "fc98242f5f49d39b8fd3a611c146741a35dc012d",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -27,11 +27,26 @@ const search =
}; };
const preProcess = (a: string | undefined) => { const preProcess = (a: string | undefined) => {
if (a?.match(/\[(.*)\]/)) { if (a) {
return "list"; let b = a;
} if (a.includes("::")) {
if (a?.toLowerCase()?.includes("attrset")) { b = a.split("::")[1];
return "attrset"; }
const cleaned = b?.replace("(", "").replace(")", "").trim();
let typ = cleaned;
if (cleaned.match(/\[(.*)\]/)) {
typ = "list";
}
if (
cleaned.toLowerCase().includes("attrset") ||
cleaned.trim().startsWith("{")
) {
typ = "attrset";
}
if (cleaned.length === 1 && ["a", "b", "c", "d", "e"].includes(cleaned)) {
typ = "any";
}
return typ;
} }
return a; return a;
}; };
@ -58,6 +73,10 @@ const filter =
to.some((t) => parsedOutType?.includes(t)) to.some((t) => parsedOutType?.includes(t))
); );
} }
//function type could not be detected only show those without filters
if (fn_type === null) {
return to.includes("any") && from.includes("any");
}
return false; return false;
} }
); );