From f31c2a395ecb3be05aba82bdb8f224d42d280f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Wed, 28 Jun 2023 17:44:44 +0200 Subject: [PATCH] Render descriptions as Markdown (#667) * Render descriptions as Markdown Following https://github.com/NixOS/nixpkgs/pull/237557, DocBook descriptions are not supported any more. We cannot use options.json any more because it still has DocBook descriptions in 22.11, so read the options from the modules directly. * Bump VERSION --- VERSION | 2 +- flake-info/assets/commands/flake_info.nix | 9 ++++++--- flake-info/src/data/import.rs | 13 +++---------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/VERSION b/VERSION index 425151f..d81cc07 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -40 +42 diff --git a/flake-info/assets/commands/flake_info.nix b/flake-info/assets/commands/flake_info.nix index d6cdb79..2d735c7 100644 --- a/flake-info/assets/commands/flake_info.nix +++ b/flake-info/assets/commands/flake_info.nix @@ -156,7 +156,10 @@ rec { all = packages ++ apps ++ options; # nixpkgs-specific, doesn't use the flake argument - nixos-options = lib.mapAttrsToList (name: option: option // { inherit name; }) - (builtins.fromJSON (builtins.unsafeDiscardStringContext (builtins.readFile - "${(import {}).options}/share/doc/nixos/options.json"))); + nixos-options = readNixOSOptions { + module = import ++ [ + + { nixpkgs.hostPlatform = "x86_64-linux"; } + ]; + }; } diff --git a/flake-info/src/data/import.rs b/flake-info/src/data/import.rs index affeb3d..9874446 100644 --- a/flake-info/src/data/import.rs +++ b/flake-info/src/data/import.rs @@ -117,18 +117,11 @@ impl Serialize for DocString { S: Serializer, { match self { - DocString::String(db) => { - serializer.serialize_str(&db.render_docbook().unwrap_or_else(|e| { - warn!("Could not render DocBook content: {}", e); - db.to_owned() - })) - } - DocString::DocFormat(DocFormat::MarkdownDoc(md)) => { - serializer.serialize_str(&md.render_markdown().unwrap_or_else(|e| { + DocString::String(md) | DocString::DocFormat(DocFormat::MarkdownDoc(md)) => serializer + .serialize_str(&md.render_markdown().unwrap_or_else(|e| { warn!("Could not render Markdown content: {}", e); md.to_owned() - })) - } + })), } } }