From cf85ab05fc10505a1b8061a44e90ddab872f373f Mon Sep 17 00:00:00 2001 From: hsjobeki Date: Wed, 7 Dec 2022 23:10:58 +0100 Subject: [PATCH] improve type proto --- components/basicList/basicList.tsx | 4 +- components/functionItem/functionItem.tsx | 6 +- components/preview/preview.tsx | 18 +++-- flake.lock | 89 +++++++++++++++++++----- pages/index.tsx | 29 ++++++-- 5 files changed, 116 insertions(+), 30 deletions(-) diff --git a/components/basicList/basicList.tsx b/components/basicList/basicList.tsx index 6a92b6a..5be6a2d 100644 --- a/components/basicList/basicList.tsx +++ b/components/basicList/basicList.tsx @@ -198,8 +198,8 @@ export function BasicList(props: BasicListProps) { {/* */} - {items.map(({ item, key }) => ( - + {items.map(({ item, key }, idx) => ( + - {`${fn_type} `} + {`${fn_type || "No type yet provided"} `} ); diff --git a/components/preview/preview.tsx b/components/preview/preview.tsx index f1dd0aa..9cac0ef 100644 --- a/components/preview/preview.tsx +++ b/components/preview/preview.tsx @@ -89,12 +89,22 @@ export const Preview = (props: PreviewProps) => { }} disableTypography primary={ - Example + example && ( + + Example + + ) } secondary={ - - {example} - + example ? ( + + {example} + + ) : ( + {`no example yet provided`} + ) } /> diff --git a/flake.lock b/flake.lock index 103be40..a51a3e6 100644 --- a/flake.lock +++ b/flake.lock @@ -78,20 +78,22 @@ "all-cabal-json": "all-cabal-json", "crane": "crane", "devshell": "devshell", + "flake-parts": "flake-parts", "flake-utils-pre-commit": "flake-utils-pre-commit", "ghc-utils": "ghc-utils", "gomod2nix": "gomod2nix", "mach-nix": "mach-nix", + "nix-pypi-fetcher": "nix-pypi-fetcher", "nixpkgs": "nixpkgs", "poetry2nix": "poetry2nix", "pre-commit-hooks": "pre-commit-hooks" }, "locked": { - "lastModified": 1667429039, - "narHash": "sha256-Lu6da25JioHzerkLHAHSO9suCQFzJ/XBjkcGCIbasLM=", + "lastModified": 1670319715, + "narHash": "sha256-W8GEZps6o+eZgMcYfoPbINiaH+yDhKENemgAcqCpu0s=", "owner": "nix-community", "repo": "dream2nix", - "rev": "5252794e58eedb02d607fa3187ffead7becc81b0", + "rev": "3681e0d5f5ab33a33238642a5fe004d372c66ab7", "type": "github" }, "original": { @@ -123,6 +125,24 @@ "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": { "locked": { "lastModified": 1659877975, @@ -216,6 +236,22 @@ "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": { "inputs": { "flake-utils": [ @@ -227,11 +263,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1670069861, - "narHash": "sha256-K+uqDkNkw5W3Rv6kIfJ43htAkhZwqNrVXg+pW6lNez4=", + "lastModified": 1670448771, + "narHash": "sha256-vO89DbrTBCiV3e3E1cDv8Pldm9D4VRFiJzBx2iTt42c=", "owner": "hsjobeki", "repo": "nixdoc", - "rev": "29813f73b02d85c57856afe8bc09d3ab308bfe55", + "rev": "9fbc589aef4c0eb256ce9b360fbbc2d1ccf0aa8d", "type": "github" }, "original": { @@ -255,18 +291,35 @@ "type": "indirect" } }, - "nixpkgs_2": { + "nixpkgs-lib": { "locked": { - "lastModified": 1669919498, - "narHash": "sha256-cndPLdFj2V0OchIgz1sOVKZXOi+ETgSq/OqCCbWsRoo=", + "dir": "lib", + "lastModified": 1665349835, + "narHash": "sha256-UK4urM3iN80UXQ7EaOappDzcisYIuEURFRoGQ/yPkug=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "14c7bd44711b04c05cb78412451005415310b6bd", + "rev": "34c5293a71ffdb2fe054eb5288adc1882c1eb0b1", "type": "github" }, "original": { + "dir": "lib", "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", "type": "github" } @@ -290,16 +343,16 @@ "poetry2nix": { "flake": false, "locked": { - "lastModified": 1632969109, - "narHash": "sha256-jPDclkkiAy5m2gGLBlKgH+lQtbF7tL4XxBrbSzw+Ioc=", + "lastModified": 1666918719, + "narHash": "sha256-BkK42fjAku+2WgCOv2/1NrPa754eQPV7gPBmoKQBWlc=", "owner": "nix-community", "repo": "poetry2nix", - "rev": "aee8f04296c39d88155e05d25cfc59dfdd41cc77", + "rev": "289efb187123656a116b915206e66852f038720e", "type": "github" }, "original": { "owner": "nix-community", - "ref": "1.21.0", + "ref": "1.36.0", "repo": "poetry2nix", "type": "github" } @@ -358,11 +411,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1670034122, - "narHash": "sha256-EqmuOKucPWtMvCZtHraHr3Q3bgVszq1x2PoZtQkUuEk=", + "lastModified": 1670380307, + "narHash": "sha256-7fJN5ndnE8YbrrtYdqMo3gDV/BW37M4wNBRhjdfP/XY=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "a0d5773275ecd4f141d792d3a0376277c0fc0b65", + "rev": "fc98242f5f49d39b8fd3a611c146741a35dc012d", "type": "github" }, "original": { diff --git a/pages/index.tsx b/pages/index.tsx index 76c17c4..6f5a197 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -27,11 +27,26 @@ const search = }; const preProcess = (a: string | undefined) => { - if (a?.match(/\[(.*)\]/)) { - return "list"; - } - if (a?.toLowerCase()?.includes("attrset")) { - return "attrset"; + if (a) { + let b = a; + if (a.includes("::")) { + b = a.split("::")[1]; + } + 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; }; @@ -58,6 +73,10 @@ const filter = 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; } );