Docs: fix rendering clan source code url
This commit is contained in:
@@ -62,14 +62,11 @@ def sanitize(text: str) -> str:
|
|||||||
return text.replace(">", "\\>")
|
return text.replace(">", "\\>")
|
||||||
|
|
||||||
|
|
||||||
def replace_store_path(text: str) -> tuple[str, str]:
|
def replace_git_url(text: str) -> tuple[str, str]:
|
||||||
res = text
|
res = text
|
||||||
if text.startswith("/nix/store/"):
|
name = Path(res).name
|
||||||
res = "https://git.clan.lol/clan/clan-core/src/branch/main/" + str(
|
if text.startswith("https://git.clan.lol/clan/clan-core/src/branch/main/"):
|
||||||
Path(*Path(text).parts[4:])
|
name = str(Path(*Path(text).parts[7:]))
|
||||||
)
|
|
||||||
# name = Path(res).name
|
|
||||||
name = str(Path(*Path(text).parts[4:]))
|
|
||||||
return (res, name)
|
return (res, name)
|
||||||
|
|
||||||
|
|
||||||
@@ -159,7 +156,7 @@ def render_option(
|
|||||||
|
|
||||||
decls = option.get("declarations", [])
|
decls = option.get("declarations", [])
|
||||||
if decls:
|
if decls:
|
||||||
source_path, name = replace_store_path(decls[0])
|
source_path, name = replace_git_url(decls[0])
|
||||||
|
|
||||||
name = name.split(",")[0]
|
name = name.split(",")[0]
|
||||||
source_path = source_path.split(",")[0]
|
source_path = source_path.split(",")[0]
|
||||||
|
|||||||
22
lib/docs.nix
22
lib/docs.nix
@@ -1,21 +1,25 @@
|
|||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
{
|
rec {
|
||||||
|
prefix = "https://git.clan.lol/clan/clan-core/src/branch/main/";
|
||||||
# Strip store paths from option declarations to make docs more stable
|
# Strip store paths from option declarations to make docs more stable
|
||||||
# This prevents documentation from rebuilding when store paths change
|
# This prevents documentation from rebuilding when store paths change
|
||||||
# but the actual content remains the same
|
# but the actual content remains the same
|
||||||
stripStorePathsFromDeclarations = opt:
|
stripStorePathsFromDeclarations =
|
||||||
opt // {
|
opt:
|
||||||
declarations = map (decl:
|
opt
|
||||||
|
// {
|
||||||
|
declarations = map (
|
||||||
|
decl:
|
||||||
if lib.isString decl && lib.hasPrefix "/nix/store/" decl then
|
if lib.isString decl && lib.hasPrefix "/nix/store/" decl then
|
||||||
let
|
let
|
||||||
parts = lib.splitString "/" decl;
|
parts = lib.splitString "/" decl;
|
||||||
in
|
in
|
||||||
if builtins.length parts > 4 then
|
if builtins.length parts > 4 then
|
||||||
"/" + lib.concatStringsSep "/" (lib.drop 4 parts)
|
(prefix + "/" + lib.concatStringsSep "/" (lib.drop 4 parts))
|
||||||
else
|
else
|
||||||
decl
|
decl
|
||||||
else
|
else
|
||||||
decl
|
decl
|
||||||
) opt.declarations;
|
) opt.declarations;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user