mirror of
https://github.com/nix-community/noogle.git
synced 2024-09-11 09:15:53 +03:00
handle functors
This commit is contained in:
parent
10e1bd820a
commit
af1e30100d
@ -155,11 +155,11 @@
|
|||||||
"nixpkgs-regression": "nixpkgs-regression"
|
"nixpkgs-regression": "nixpkgs-regression"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1702384142,
|
"lastModified": 1704367076,
|
||||||
"narHash": "sha256-AzZ/FLCMp8rqfY5wyFW+VvyEUA8OoZ43aBkAWp7NdPg=",
|
"narHash": "sha256-wy+M/+mryU2w4HXO0cWiKeoL2IICR715q+yWacnSg4o=",
|
||||||
"owner": "hsjobeki",
|
"owner": "hsjobeki",
|
||||||
"repo": "nix",
|
"repo": "nix",
|
||||||
"rev": "1c33d81594c08fc62e3e94e5496a53524beedf7a",
|
"rev": "d86596aabc7e480858fd5d024deb8c4092200d47",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
1
pesto/test_data/atom/functor.expect
Normal file
1
pesto/test_data/atom/functor.expect
Normal file
@ -0,0 +1 @@
|
|||||||
|
Some(NixDocComment { content: Some("Docs"), count_applied: None })
|
7
pesto/test_data/atom/functor.nix
Normal file
7
pesto/test_data/atom/functor.nix
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
let
|
||||||
|
/**Docs*/
|
||||||
|
foo = {
|
||||||
|
__functor = self: x: self;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{ inherit foo; }
|
4
pesto/test_data/atom/functor.pos
Normal file
4
pesto/test_data/atom/functor.pos
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"line": 3,
|
||||||
|
"column": 9
|
||||||
|
}
|
@ -24,10 +24,11 @@ export async function generateStaticParams(): Promise<{ path: string[] }[]> {
|
|||||||
|
|
||||||
interface TocProps {
|
interface TocProps {
|
||||||
mdxSource: string;
|
mdxSource: string;
|
||||||
|
title?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Toc = async (props: TocProps) => {
|
const Toc = async (props: TocProps) => {
|
||||||
const { mdxSource } = props;
|
const { mdxSource, title } = props;
|
||||||
const headings = await extractHeadings(mdxSource);
|
const headings = await extractHeadings(mdxSource);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -52,6 +53,21 @@ const Toc = async (props: TocProps) => {
|
|||||||
No sections
|
No sections
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
|
{title && (
|
||||||
|
<Link href={`#${title}`}>
|
||||||
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
sx={{
|
||||||
|
justifyContent: "start",
|
||||||
|
textTransform: "none",
|
||||||
|
color: "text.secondary",
|
||||||
|
py: 0.5,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{title}
|
||||||
|
</Typography>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
{headings.map((h, idx) => (
|
{headings.map((h, idx) => (
|
||||||
<Link key={idx} href={`#${h.id}`}>
|
<Link key={idx} href={`#${h.id}`}>
|
||||||
<Typography
|
<Typography
|
||||||
@ -60,7 +76,7 @@ const Toc = async (props: TocProps) => {
|
|||||||
justifyContent: "start",
|
justifyContent: "start",
|
||||||
textTransform: "none",
|
textTransform: "none",
|
||||||
color: "text.secondary",
|
color: "text.secondary",
|
||||||
pl: h.level - 1,
|
pl: h.level,
|
||||||
py: 0.5,
|
py: 0.5,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -150,7 +166,7 @@ export default async function Page(props: { params: { path: string[] } }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Toc mdxSource={source} />
|
<Toc mdxSource={source} title={item?.meta.title} />
|
||||||
<Box
|
<Box
|
||||||
component="main"
|
component="main"
|
||||||
data-pagefind-body
|
data-pagefind-body
|
||||||
@ -192,9 +208,12 @@ export default async function Page(props: { params: { path: string[] } }) {
|
|||||||
</FilterProvider>
|
</FilterProvider>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
<Typography
|
<Typography
|
||||||
|
id={item?.meta.title}
|
||||||
variant="h2"
|
variant="h2"
|
||||||
component={"h1"}
|
component={"h1"}
|
||||||
sx={{ marginRight: "auto" }}
|
sx={{
|
||||||
|
marginRight: "auto",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{item?.meta.title}
|
{item?.meta.title}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
@ -89,7 +89,7 @@ export const PositionLink = ({
|
|||||||
Underlying function
|
Underlying function
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
{count_applied && count_applied > 0 && (
|
{!!count_applied && count_applied > 0 && (
|
||||||
<Typography
|
<Typography
|
||||||
variant="subtitle2"
|
variant="subtitle2"
|
||||||
sx={{ color: "text.secondary" }}
|
sx={{ color: "text.secondary" }}
|
||||||
|
@ -130,7 +130,11 @@ export const Navigation = ({
|
|||||||
borderRadius: 3,
|
borderRadius: 3,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button aria-label="Prev result" endIcon={<ChevronRight />}>
|
<Button
|
||||||
|
aria-label="Prev result"
|
||||||
|
endIcon={<ChevronRight />}
|
||||||
|
sx={{ float: "right" }}
|
||||||
|
>
|
||||||
Next
|
Next
|
||||||
</Button>
|
</Button>
|
||||||
<Typography variant="subtitle1">{next.meta.title}</Typography>
|
<Typography variant="subtitle1">{next.meta.title}</Typography>
|
||||||
|
@ -7,6 +7,7 @@ export type NixType =
|
|||||||
| "string"
|
| "string"
|
||||||
| "number"
|
| "number"
|
||||||
| "bool"
|
| "bool"
|
||||||
|
| "path"
|
||||||
| "never"
|
| "never"
|
||||||
| "any";
|
| "any";
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ export const nixTypes: NixType[] = [
|
|||||||
"attrset",
|
"attrset",
|
||||||
"list",
|
"list",
|
||||||
"string",
|
"string",
|
||||||
|
"path",
|
||||||
"bool",
|
"bool",
|
||||||
"never",
|
"never",
|
||||||
"number",
|
"number",
|
||||||
@ -29,6 +31,10 @@ const interpretToken = (token: string): NixType | undefined => {
|
|||||||
return token as NixType;
|
return token as NixType;
|
||||||
} else if (["int", "float", "double"].includes(token)) {
|
} else if (["int", "float", "double"].includes(token)) {
|
||||||
return "number";
|
return "number";
|
||||||
|
} else if (["derivation", "package"].includes(token)) {
|
||||||
|
return "attrset";
|
||||||
|
} else if (["storepath"].includes(token) || token.includes("path")) {
|
||||||
|
return "path";
|
||||||
} else if (["a", "b", "c", "d", "e"].includes(token)) {
|
} else if (["a", "b", "c", "d", "e"].includes(token)) {
|
||||||
return "any";
|
return "any";
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user