-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixosOptionsDoc.optionsMarkdown
: init, with anchors
#300309
nixosOptionsDoc.optionsMarkdown
: init, with anchors
#300309
Conversation
This adds a new optionsMarkdown, that's compatible with the HTML (and DocBook) outputs. This needs anchor syntax, which is not part of the CommonMark specification, as of version 0.31.2.
optionsMarkdown = pkgs.runCommand "options.md" { | ||
nativeBuildInputs = [ pkgs.nixos-render-docs ]; | ||
} '' | ||
nixos-render-docs -j $NIX_BUILD_CORES options commonmark \ | ||
--manpage-urls ${pkgs.path + "/doc/manpage-urls.json"} \ | ||
--revision ${lib.escapeShellArg revision}${ | ||
lib.optionalString markdownAnchors '' \ | ||
--render-anchors \ | ||
--anchor-prefix ${lib.escapeShellArg optionIdPrefix}''} \ | ||
${optionsJSON}/share/doc/nixos/options.json \ | ||
$out | ||
''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this mostly duplicates optionsCommonMark
, it would make sense to have a function that encapsulates commonmark-plus-extensions in some way. that would also spare you the indignity of turning your own feature on while advising all other new features to be turned off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #370352 I avoid this duplication by introducing extraArgs
which can be overridden. That's much simpler and doesn't cause duplication.
_id_translate_table = { | ||
ord('*'): ord('_'), | ||
ord('<'): ord('_'), | ||
ord(' '): ord('_'), | ||
ord('>'): ord('_'), | ||
ord('['): ord('_'), | ||
ord(']'): ord('_'), | ||
ord(':'): ord('_'), | ||
ord('"'): ord('_'), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's the same table as xml uses, duplicated. it's not a great transform to begin with, we should be applying something more like url-encoding instead (but see later comments for that also).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It now reuses that routine. I agree it's not a great transform, lacking injectivity, but it's the one that's been used all this time in DocBook and HTML option docs.
A better transform could be added by extending the enum in #370352, if anyone wants or needs that.
@@ -437,11 +455,15 @@ def _decl_def_entry(self, href: Optional[str], name: str) -> list[str]: | |||
def _decl_def_footer(self) -> list[str]: | |||
return [] | |||
|
|||
def make_id (self, loc: list[str]) -> str: | |||
return '.'.join([to_id(x) for x in loc]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's not necessarily a unique transform any more if any module chooses to use a .
in its keys. existing code gets a pass on this by virtue if being inherited bad behavior, new code should not make such mistakes if at all possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compatibility is my explicit goal with the legacy
anchor style. I think I've done a good job at reusing existing code in #370352. A line of code like this is unavoidable for that. Better anchor styles can be added, as mentioned.
I agree, but I couldn't find a good place to put that function. For that I blame the structure of |
Description of changes
This adds a new
optionsMarkdown
attribute, that's compatible with the HTML (and DocBook) outputs.This functionality needs anchor syntax, which is not part of the CommonMark specification, as of version 0.31.2.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.