mirror of
https://github.com/hsjobeki/noogle.git
synced 2024-08-16 16:20:45 +03:00
fix: forgot to update data.json after builtins import: renamed into lib.json
This commit is contained in:
parent
2d4a7d1e1b
commit
521fb6e03f
@ -220,6 +220,8 @@ export function BasicList(props: BasicListProps) {
|
||||
</List>
|
||||
|
||||
<Pagination
|
||||
hideNextButton
|
||||
hidePrevButton
|
||||
sx={{ display: "flex", justifyContent: "center", mt: 1, mb: 10 }}
|
||||
count={Math.ceil(items.length / itemsPerPage) || 1}
|
||||
color="primary"
|
||||
|
@ -109,7 +109,7 @@ export function Layout(props: LayoutProps) {
|
||||
overflowY: "scroll",
|
||||
}}
|
||||
>
|
||||
<Container sx={{ pt: 0 }} maxWidth="xl">
|
||||
<Container sx={{ pt: 0, px: { xs: 0, md: 2 } }} maxWidth="xl">
|
||||
{children}
|
||||
</Container>
|
||||
</main>
|
||||
|
@ -1,20 +1,25 @@
|
||||
import {
|
||||
Box,
|
||||
Container,
|
||||
IconButton,
|
||||
Link,
|
||||
List,
|
||||
ListItem,
|
||||
ListItemButton,
|
||||
ListItemIcon,
|
||||
ListItemSecondaryAction,
|
||||
ListItemText,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
// import CloseIcon from "@mui/icons-material/Close";
|
||||
import Highlight from "react-highlight";
|
||||
import LocalLibraryIcon from "@mui/icons-material/LocalLibrary";
|
||||
import InputIcon from "@mui/icons-material/Input";
|
||||
import { DocItem } from "../../types/nix";
|
||||
import CodeIcon from "@mui/icons-material/Code";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import ExpandLessIcon from "@mui/icons-material/ExpandLess";
|
||||
|
||||
// import hljs from "highlight.js";
|
||||
|
||||
@ -22,30 +27,30 @@ import ReactMarkdown from "react-markdown";
|
||||
import "highlight.js/styles/github.css";
|
||||
interface PreviewProps {
|
||||
docItem: DocItem;
|
||||
handleClose: () => void;
|
||||
}
|
||||
|
||||
export const Preview = (props: PreviewProps) => {
|
||||
const { docItem } = props;
|
||||
const { docItem, handleClose } = props;
|
||||
const { name, description, category, example, fn_type } = docItem;
|
||||
|
||||
const getGeneratedExamples = () => {
|
||||
if (description) {
|
||||
// const regex = /\`\`\`.*\`\`\`/gm;
|
||||
const regex = /(```.+?```)/gms;
|
||||
console.log({ description, regex });
|
||||
if (typeof description === "object") {
|
||||
return description
|
||||
.join(" ")
|
||||
.match(regex)
|
||||
?.join("")
|
||||
?.replace("```nix", "")
|
||||
?.replace("```", "");
|
||||
?.join("\n#---\n")
|
||||
?.replaceAll("```nix", "")
|
||||
?.replaceAll("```", "");
|
||||
} else {
|
||||
return description
|
||||
.match(regex)
|
||||
?.join("")
|
||||
?.replace("```nix", "")
|
||||
?.replace("```", "");
|
||||
?.join("\n#---\n")
|
||||
?.replaceAll("```nix", "")
|
||||
?.replaceAll("```", "");
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -69,8 +74,17 @@ export const Preview = (props: PreviewProps) => {
|
||||
borderTopColor: "primary.main",
|
||||
}}
|
||||
>
|
||||
{/* <Box sx={{ display: "flex" }}> */}
|
||||
<Typography variant="h2">{`${prefix}.${name}`}</Typography>
|
||||
{/* </Box> */}
|
||||
<List sx={{ width: "100%" }}>
|
||||
<ListItem>
|
||||
<Tooltip title="close details">
|
||||
<IconButton onClick={() => handleClose()}>
|
||||
<ExpandLessIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
<LocalLibraryIcon />
|
||||
@ -102,9 +116,6 @@ export const Preview = (props: PreviewProps) => {
|
||||
</Container>
|
||||
}
|
||||
/>
|
||||
{/* <ListItemSecondaryAction>
|
||||
<Link href={docsRef}>View Docs</Link>
|
||||
</ListItemSecondaryAction> */}
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
|
18
flake.lock
18
flake.lock
@ -43,11 +43,11 @@
|
||||
"crane": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1661875961,
|
||||
"narHash": "sha256-f1h/2c6Teeu1ofAHWzrS8TwBPcnN+EEu+z1sRVmMQTk=",
|
||||
"lastModified": 1670284777,
|
||||
"narHash": "sha256-JF0pc0s4z/X+Iy+lNHOwUQ8I5bz+q7uX4HrKTNIEj24=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "d9f394e4e20e97c2a60c3ad82c2b6ef99be19e24",
|
||||
"rev": "2243fb9c872de25cb564a02d324ea6a5b9853052",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -89,11 +89,11 @@
|
||||
"pre-commit-hooks": "pre-commit-hooks"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1670319715,
|
||||
"narHash": "sha256-W8GEZps6o+eZgMcYfoPbINiaH+yDhKENemgAcqCpu0s=",
|
||||
"lastModified": 1670559747,
|
||||
"narHash": "sha256-yT/ofVjhgGrdFQeFONFpLNnVJa8ALMuSvlILczvIIn4=",
|
||||
"owner": "nix-community",
|
||||
"repo": "dream2nix",
|
||||
"rev": "3681e0d5f5ab33a33238642a5fe004d372c66ab7",
|
||||
"rev": "8b4d355e8008c47791219da30fc390baf78c4099",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -263,11 +263,11 @@
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1670448771,
|
||||
"narHash": "sha256-vO89DbrTBCiV3e3E1cDv8Pldm9D4VRFiJzBx2iTt42c=",
|
||||
"lastModified": 1670665290,
|
||||
"narHash": "sha256-VkuPWVA+DF1AYx4hdw7JUxrJOdHP/cLhyL+t+xH9UsU=",
|
||||
"owner": "hsjobeki",
|
||||
"repo": "nixdoc",
|
||||
"rev": "9fbc589aef4c0eb256ce9b360fbbc2d1ccf0aa8d",
|
||||
"rev": "f9377fac1265f1e02329343aaff573dff68f9402",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -18,7 +18,7 @@
|
||||
packageOverrides = {
|
||||
${name}.staticPage = {
|
||||
preBuild = ''
|
||||
cp ${inp.nixdoc-fork.packages.${system}.data} ./models/data.json
|
||||
cp ${inp.nixdoc-fork.packages.${system}.data} ./models/lib.json
|
||||
'';
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
3359
models/lib.json
3359
models/lib.json
File diff suppressed because it is too large
Load Diff
@ -60,22 +60,23 @@ const preProcess = (a: string | undefined) => {
|
||||
}
|
||||
return a;
|
||||
};
|
||||
const filter =
|
||||
const filterByType =
|
||||
(to: NixType[], from: NixType[]) =>
|
||||
(data: MetaData): MetaData => {
|
||||
//if user wants any data show all
|
||||
if (to.includes("any") && from.includes("any")) {
|
||||
return data;
|
||||
}
|
||||
return data.filter(
|
||||
// TODO: Implement proper type matching
|
||||
({ name, fn_type }) => {
|
||||
if (fn_type) {
|
||||
const args = fn_type.split("->");
|
||||
const cleanType = fn_type.replace(/ /g, "").replace(`${name}::`, "");
|
||||
const args = cleanType.split("->");
|
||||
const front = args.slice(0, -1);
|
||||
let firstTerm = front.at(0);
|
||||
if (firstTerm?.includes("::")) {
|
||||
firstTerm = firstTerm.split("::").at(1);
|
||||
}
|
||||
const inpArgs = [firstTerm, ...front.slice(1, -1)];
|
||||
const parsedInpTypes = inpArgs.map(preProcess);
|
||||
// const fn_from =
|
||||
|
||||
const parsedInpTypes = front.map(preProcess);
|
||||
|
||||
const fn_to = args.at(-1);
|
||||
const parsedOutType = preProcess(fn_to);
|
||||
return (
|
||||
@ -110,12 +111,10 @@ export default function FunctionsPage() {
|
||||
};
|
||||
|
||||
const filteredData = useMemo(
|
||||
() => pipe(filter(to, from), search(term))(data),
|
||||
() => pipe(filterByType(to, from), search(term))(data),
|
||||
[to, from, term]
|
||||
);
|
||||
|
||||
// const pageData = useMemo(()=>filteredData.,[filteredData])
|
||||
|
||||
const handleSearch = (term: string) => {
|
||||
setTerm(term);
|
||||
};
|
||||
@ -157,11 +156,14 @@ export default function FunctionsPage() {
|
||||
})
|
||||
);
|
||||
const preview = (
|
||||
<Preview docItem={data.find((f) => getKey(f) === selected) || data[0]} />
|
||||
<Preview
|
||||
docItem={data.find((f) => getKey(f) === selected) || data[0]}
|
||||
handleClose={() => setSelected(null)}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<Box sx={{ ml: 2 }}>
|
||||
<Box sx={{ ml: { xs: 0, md: 2 } }}>
|
||||
<BasicList
|
||||
selected={selected}
|
||||
itemsPerPage={8}
|
||||
|
Loading…
Reference in New Issue
Block a user