handle functors

This commit is contained in:
Johannes Kirschbauer 2024-01-04 15:40:02 +01:00 committed by Johannes Kirschbauer
parent 10e1bd820a
commit af1e30100d
8 changed files with 50 additions and 9 deletions

View File

@ -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": {

View File

@ -0,0 +1 @@
Some(NixDocComment { content: Some("Docs"), count_applied: None })

View File

@ -0,0 +1,7 @@
let
/**Docs*/
foo = {
__functor = self: x: self;
};
in
{ inherit foo; }

View File

@ -0,0 +1,4 @@
{
"line": 3,
"column": 9
}

View File

@ -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>

View File

@ -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" }}

View File

@ -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>

View File

@ -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 {