From 0532cdd73f493f2e4bf92b71118d8b464052d4bf Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Sun, 9 Jun 2024 17:24:27 +0200 Subject: [PATCH] Website: improve wordings and other minor fixes --- website/src/components/Lambda.tsx | 4 +- website/src/components/PositionLink.tsx | 12 ++-- website/src/components/ResultPreview.tsx | 84 +++++++++++++----------- website/src/models/nix.ts | 16 +++++ 4 files changed, 72 insertions(+), 44 deletions(-) diff --git a/website/src/components/Lambda.tsx b/website/src/components/Lambda.tsx index c65ce1c..f8617c2 100644 --- a/website/src/components/Lambda.tsx +++ b/website/src/components/Lambda.tsx @@ -1,7 +1,7 @@ import React from "react"; import type { SVGProps } from "react"; -export function NixLambda(props: SVGProps) { +export function Lambda(props: SVGProps) { return ( ) { ); } -export function NixBuiltin(props: SVGProps) { +export function Nix(props: SVGProps) { return ( - This function is not declared in a .nix file + This function is not defined in a .nix file. It is likely a builtins + function or an alias of a builtins function. builtins functions are + predefined functions provided by Nix. {!is_primop && ( - This is very likely a bug in noogle please report this error. + This is very likely a bug in Noogle please report this error. )} @@ -84,7 +86,7 @@ export const PositionLink = ({ sx={{ textTransform: "none", my: 1, placeSelf: "start" }} startIcon={} > - Edit source + Edit Source Code )} @@ -108,7 +110,7 @@ export const PositionLink = ({ }} startIcon={} > - Attribute position + View Attribute Definition )} @@ -130,7 +132,7 @@ export const PositionLink = ({ }} startIcon={} > - Underlying function + See Function Definition )} diff --git a/website/src/components/ResultPreview.tsx b/website/src/components/ResultPreview.tsx index 55883c4..d5314be 100644 --- a/website/src/components/ResultPreview.tsx +++ b/website/src/components/ResultPreview.tsx @@ -7,9 +7,10 @@ import { ListItem, ListItemAvatar, ListItemText, + Tooltip, } from "@mui/material"; import { PagefindResult } from "./Pagefind"; -import { NixLambda, NixBuiltin } from "./Lambda"; +import { Lambda, Nix } from "./Lambda"; import { data } from "@/models/data"; import { findType } from "@/models/nix"; @@ -30,15 +31,7 @@ export const ResultPreview = (props: ResultPreviewProps) => { const cntAliases = item?.meta?.aliases?.length; const category = item?.meta?.path?.[0]; - console.log({ isFunctor, item, signature }); - - const icon = isFunctor ? ( - - ) : isPrimop ? ( - - ) : ( - - ); + const icon = isFunctor ? : isPrimop ? : ; return ( <> { aria-label={`item-${meta.title}`} > - - {icon} - + + {icon} + + { }} secondaryTypographyProps={{ variant: "body1", + color: "text.primary", }} primary={ @@ -96,28 +100,34 @@ export const ResultPreview = (props: ResultPreviewProps) => { /> )} {!!cntAliases && ( - + + + )} {isFunctor && ( - + + + )} {isPrimop && ( - + + + )} diff --git a/website/src/models/nix.ts b/website/src/models/nix.ts index a48007c..933c102 100644 --- a/website/src/models/nix.ts +++ b/website/src/models/nix.ts @@ -80,10 +80,26 @@ export function interpretType( return { args: ["any"], returns: ["any"] }; } +/** + * Find the type of a function that is a builtin or by looking at its builtins aliases + */ export function findType(item: Doc): string | undefined { + if (item.meta.is_primop && !item.meta.signature && item.meta.aliases) { + for (const alias of item.meta.aliases) { + const type = findTypeByPath(alias); + if (type) { + return type; + } + } + } + return findTypeByPath(item.meta.path); } +/** + * Find the type of a builtins.* function by looking at its path. + * Noogle has a hand-crafted list of builtin types that cannot be retrieved otherwise. + */ export function findTypeByPath(path: string[]): string | undefined { if (path.length === 2 && path[0] === "builtins") { const fallbackType = builtinTypes[path[1]];