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"
},
"locked": {
"lastModified": 1702384142,
"narHash": "sha256-AzZ/FLCMp8rqfY5wyFW+VvyEUA8OoZ43aBkAWp7NdPg=",
"lastModified": 1704367076,
"narHash": "sha256-wy+M/+mryU2w4HXO0cWiKeoL2IICR715q+yWacnSg4o=",
"owner": "hsjobeki",
"repo": "nix",
"rev": "1c33d81594c08fc62e3e94e5496a53524beedf7a",
"rev": "d86596aabc7e480858fd5d024deb8c4092200d47",
"type": "github"
},
"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 {
mdxSource: string;
title?: string;
}
const Toc = async (props: TocProps) => {
const { mdxSource } = props;
const { mdxSource, title } = props;
const headings = await extractHeadings(mdxSource);
return (
@ -52,6 +53,21 @@ const Toc = async (props: TocProps) => {
No sections
</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) => (
<Link key={idx} href={`#${h.id}`}>
<Typography
@ -60,7 +76,7 @@ const Toc = async (props: TocProps) => {
justifyContent: "start",
textTransform: "none",
color: "text.secondary",
pl: h.level - 1,
pl: h.level,
py: 0.5,
}}
>
@ -150,7 +166,7 @@ export default async function Page(props: { params: { path: string[] } }) {
return (
<>
<Toc mdxSource={source} />
<Toc mdxSource={source} title={item?.meta.title} />
<Box
component="main"
data-pagefind-body
@ -192,9 +208,12 @@ export default async function Page(props: { params: { path: string[] } }) {
</FilterProvider>
</Suspense>
<Typography
id={item?.meta.title}
variant="h2"
component={"h1"}
sx={{ marginRight: "auto" }}
sx={{
marginRight: "auto",
}}
>
{item?.meta.title}
</Typography>

View File

@ -89,7 +89,7 @@ export const PositionLink = ({
Underlying function
</Button>
</Link>
{count_applied && count_applied > 0 && (
{!!count_applied && count_applied > 0 && (
<Typography
variant="subtitle2"
sx={{ color: "text.secondary" }}

View File

@ -130,7 +130,11 @@ export const Navigation = ({
borderRadius: 3,
}}
>
<Button aria-label="Prev result" endIcon={<ChevronRight />}>
<Button
aria-label="Prev result"
endIcon={<ChevronRight />}
sx={{ float: "right" }}
>
Next
</Button>
<Typography variant="subtitle1">{next.meta.title}</Typography>

View File

@ -7,6 +7,7 @@ export type NixType =
| "string"
| "number"
| "bool"
| "path"
| "never"
| "any";
@ -15,6 +16,7 @@ export const nixTypes: NixType[] = [
"attrset",
"list",
"string",
"path",
"bool",
"never",
"number",
@ -29,6 +31,10 @@ const interpretToken = (token: string): NixType | undefined => {
return token as NixType;
} else if (["int", "float", "double"].includes(token)) {
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)) {
return "any";
} else {