add support for outside tree functions such as make-disk-image

This commit is contained in:
Johannes Kirschbauer 2024-01-03 14:13:21 +01:00 committed by Johannes Kirschbauer
parent f954db4fbb
commit 0b4e1d38bd
6 changed files with 59 additions and 27 deletions

View File

@ -21,14 +21,16 @@
## Available data
There are the following subsets of nix functions available.
There are the following subsets of `nix` and `nixpkgs` functions available.
Recursively Indexed:
Recursively indexed:
- lib
- pkgs.rustPackages
Normally Indexed:
> Recursively means all deeply nested sub-attributes.
Normally indexed:
- builtins
- pkgs.stdenv
@ -36,7 +38,17 @@ Normally Indexed:
- pkgs.writers
- pkgs.pythonPackages
- pkgs.haskell.lib
- pkgs.dockerTools
- pkgs.haskell.lib
# Off the tree functions
Some function are not part of the evaluation value of default.nix in nixpkgs. They must be imported individually.
- make-disk-image
---
All Indexing is done via the [pasta](./pasta/) module. PRs welcome!
## Contribute
@ -47,7 +59,14 @@ Indexed data can be added very easily in ./pasta/src/eval.nix
### Build this page
`nix build .#`
`nix build .#ui`
This page generates static html pages.
One page per api function.
It automatically includes meta tags for other search engines like google or bing.
Searching within the page is done via [pagefind](https://pagefind.app/) which is only available in the production build.
### Develop

View File

@ -4,8 +4,8 @@ pkgs.stdenv.mkDerivation {
src = ./src;
nativeBuildInputs = [ nix ];
buildPhase = ''
nix-instantiate --eval --strict --json --store $PWD \
eval.nix --arg 'pkgs' 'import ${nixpkgs} {}' -A all \
nix-instantiate --eval --strict --json --store $PWD --show-trace \
eval.nix --arg 'pkgs' 'import ${nixpkgs} {}' --arg 'repo' '${nixpkgs.outPath}' -A all \
> $out
'';
}

View File

@ -1,29 +1,28 @@
{ pkgs ? # import (builtins.fetchTree {
{
# import (builtins.fetchTree {
# repo = "nixpkgs";
# ref = "migrate-doc-comments";
# owner = "hsjobeki";
# type = "github";
# }) {},
import
(builtins.fetchTree {
nixpkgs ? (builtins.fetchTree {
repo = "nixpkgs";
ref = "master";
owner = "nixos";
type = "github";
})
{ }
,
, pkgs ? import nixpkgs { }
, repo ? nixpkgs.outPath
}:
let
inherit pkgs;
inherit (pkgs) lib;
make-disk-image = import (repo + "/nixos/lib/make-disk-image.nix");
tools = import ./tools.nix { inherit lib; };
inherit (tools) getDocsFromSet collectFns toFile;
# Contains seperate sets of metadata.
# which then allows running seperate evaluations. Once at a time for better error tracing and memory management.
docs = {
############# Recusive analysis sets
lib = collectFns lib { initialPath = [ "lib" ]; };
@ -43,16 +42,19 @@ let
getDocsFromSet pkgs.pythonPackages [ "pkgs" "pythonPackages" ];
builtins =
getDocsFromSet builtins [ "builtins" ];
mkDiskImage = [
{
path = [ "make-disk-image" ];
docs = tools.getDocs { inherit make-disk-image; } "make-disk-image";
}
];
};
all = builtins.foldl' (acc: name: acc ++ docs.${name}) [ ] (builtins.attrNames docs);
# generate test_data for pesto
test_data = {
attrsets = getDocsFromSet lib.attrsets [ "lib" "attrsets" ];
};
in
{ inherit tools pkgs docs toFile getDocsFromSet collectFns all test_data; }

View File

@ -32,6 +32,12 @@ let
/* *
Recursively collect documentation for all values
[
{
path :: [ String ];
docs :: GetDocs;
}
]
*/
collectFns = set:
{ initialPath ? [ ], limit ? null, }:
@ -126,4 +132,4 @@ let
}]) [ ])
];
in
{ inherit toFile collectFns getDocsFromSet; }
{ inherit getDocs toFile collectFns getDocsFromSet; }

View File

@ -23,7 +23,6 @@ use crate::pasta::{AliasList, Docs, ValuePath};
/// Match Non-Primop
/// Eq position
pub fn find_aliases(item: &Docs, list: &Vec<&Docs>) -> AliasList {
dbg!("find alias for", &item.path);
let res: AliasList = list
.iter()
.filter_map(|other| {
@ -55,7 +54,6 @@ pub fn find_aliases(item: &Docs, list: &Vec<&Docs>) -> AliasList {
None
}
(false, false) => {
dbg!("this case", s_meta.countApplied);
if s_meta.countApplied != Some(0) {
if item.path.last() == other.path.last() {
return Some(other.path.clone());

View File

@ -60,11 +60,11 @@ const Toc = async (props: TocProps) => {
justifyContent: "start",
textTransform: "none",
color: "text.secondary",
pl: (h.level - 1) * 2 + 1,
pl: h.level - 1,
py: 0.5,
}}
>
{h.value}
<span dangerouslySetInnerHTML={{ __html: h.value }} />
</Typography>
</Link>
))}
@ -88,6 +88,13 @@ const MDX = ({ source }: { source: string }) => (
sx={{
color: "inherit",
textDecoration: "none",
":before": {
content: "''",
display: "block",
height: "75px",
visibility: "hidden",
marginTop: "-75px",
},
}}
component="a"
{...p}