-
-
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
nixos/*: deprecate docbook option docs #189318
Conversation
What is the advantage of |
|
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.
nix looks good, changelog and docs look good.
Have only skimmed the lib.mdDoc insertions but they looked good from what I can tell.
Have not reviewed the Python code
@@ -179,6 +181,8 @@ Use `configure.packages` instead. | |||
|
|||
- memtest86+ was updated from 5.00-coreboot-002 to 6.00-beta2. It is now the upstream version from https://www.memtest.org/, as coreboot's fork is no longer available. | |||
|
|||
- Option descriptions, examples, and defaults writting in DocBook are now deprecated and will generate informational messages during the documentation build. Using CommonMark is preferred and will become the default in 23.05. |
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 is also too fast. There needs to be a reasonable period for third-party tools to easily support multiple nixpkgs releases without causing warnings. This was previously a problem with iirc home-manager, where a deprecation warning was unavoidable due to older nixpkgs still needing support.
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.
as far as we can tell there will be no way for us to do this transition that will not cause pains in third-party tools, waiting longer will only make them worse (cf python 2). anything that wants to support both can either go the trivial route with a let mdDoc = lib.mdDoc or lib.id; in
prefix and using documentation that works with both renderers, or it can have two texts and switch between them based on pkgs.version
. considering how much things change between releases it doesn't seem unreasonable to expect third-party things to add support quickly, while actually removing support for old docbook is a lot less pressing as long as the gates work. maybe we should instead add something to the docs system that reliably tells whether the underlying docs format is docbook or markdown?
(we also can't make any meaningful improvements to rendering of the options chapter/manpage before docbook is fully disallowed. can't find a way to insert raw roff sequences into a docbook manpage build or raw html into a docbook html build, which would leave us with rendering each docbook option individually and parsing the generated output to insert into what we'd render from markdown directly. 🙁)
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.
anything that wants to support both can either go the trivial route with a let mdDoc = lib.mdDoc or lib.id; in prefix and using documentation that works with both renderers, or it can have two texts and switch between them based on pkgs.version
Both of those are far from ideal and require a lot of work. Third-party tools should also have a chance for a smooth transition with an appropriate deprecation period. Merging this PR as-is would require home-manager, nix-darwin (and anything else rendering docs using the module system) to effectively immediately update all their docbook to markdown, support for which was only introduced a couple months ago.
This is how I think the deprecation strategy should look like:
- 22.11: Introduce support for markdown docs (treewide: markdown option docs #176146). Mention in the release notes that support for docbook will be deprecated in the next release and removed in the one after that. No warning for docbook yet. This allows third-party tools to read release notes and prepare for the next release, such that they won't cause any warnings for users.
- 23.05: Deprecate docbook support by adding a warning when
mdDoc
isn't used. The warning mentions that docbook support will be removed in the next released. This pushes everybody to usemdDoc
, explicitly confirming that they have transitioned their code to markdown. - 23.11: Remove docbook support either by using markdown implicitly for unannotated strings. This is only safe assuming everybody did the transition to 23.05, if somebody updates from older releases, they'd never get the warning to move to
mdDoc
, but considering the alternative of throwing an error for unannotated strings, that's a worthwhile tradeoff imo. - (future): Slowly deprecate
mdDoc
with a warning, then an error, then a complete removal
So essentially there's two deprecation phases: An initial silent one for third-party tools to prepare a smooth NixOS/nixpkgs upgrade for their users, and a noisy one (warning) for end users. And if a third-party tool misses the first phase of deprecation, they will get complaints by their users during the second one.
Yes this means that we'll have to wait with the docbook removal for another year, but that's just how deprecation works with a stable API surface (which is expected of nixpkgs).
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.
Found the issue I was thinking of that shows how this problem happened in the past: #163451
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.
while yes, markdown support for options is new in the scheme of things, it's been known for a good while now that docbook is on the way out. for that reason we'd much rather skip what you propose for 22.11. perhaps we could make the process easier on users by adding an option to disable the deprecation warnings?
dunno. we honestly don't have the energy to fight for doing this quickly, we just want the docs build to not take ten minutes each time. may someone else decide.
lib/options.nix
Outdated
else | ||
lib.warn | ||
"literalDocBook is deprecated, use literalMD instead" | ||
{ _type = "literalDocBook"; inherit text; }; |
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 will annoy third party module maintainers.
They'll receive issues and PRs about the warnings, while they need to keep using docbook until 22.05 is EOL.
You could prepare the deprecation though, with
else | |
lib.warn | |
"literalDocBook is deprecated, use literalMD instead" | |
{ _type = "literalDocBook"; inherit text; }; | |
else | |
lib.warnIf (lib.isInOldestRelease 2211) | |
"literalDocBook is deprecated, use literalMD instead" | |
{ _type = "literalDocBook"; inherit text; }; |
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.
wouldn't that only delay the annoyance to third-party modules by one release? if they want to not see warnings during the last release that supports both docbook and markdown they'll still have to write docs twice for that period or work with a common denominator. especially for modules that are rarely or never used with unstable, they'd see the same brick wall of deprecation notices, only later?
we honestly don't quite follow how moving the warnings into the future will make anything nicer for folks unless every module maintainer reads the complete release notes and acts upon them quickly (which seems rather unlikely)
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.
@infinisil @roberth here's an idea: we deprecate everything very slowly indeed, but also add a temporary option to be removed together with docbook, eg |
sgtm
Yes, for Nixpkgs' own CI we can and should be strict. I can think of two ways we should probably both implement
These changes won't affect users, but keep nixpkgs prepared for the final change. |
softened the deprecation policy a lot and added a check for manual equivalence by build type to the CI workflows. haven't added a test yet (not sure what the best way to do this would be). for now this probably shouldn't be a channel blocker, it doesn't seem quite important enough for that—once we're on the last stretch to removing docbook that would be a good thing to do though. |
.github/workflows/manual-nixos.yml
Outdated
nix-build \ | ||
--option restrict-eval true \ | ||
-o docbook nixos/release.nix \ | ||
-A manual.x86_64-linux | ||
nix-build \ | ||
--option restrict-eval true \ | ||
--arg configuration '{ documentation.nixos.options.renderFromMD = true; }' | ||
-o md nixos/release.nix \ | ||
-A manual.x86_64-linux | ||
.github/workflows/compare-manuals.sh \ | ||
docbook/share/doc/nixos/options.html \ | ||
md/share/doc/nixos/options.html |
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.
Could you add explanatory messages to these commands when they fail?
That way, the average contributor will know what to do in either of the three circumstances.
Would a failure in the last command only be caused by a programming error in the python script?
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.
Could you add explanatory messages to these commands when they fail?
the first cannot fail unless the CI machine breaks, the second produces diagnostics as part of its output. added a little informational message to the last one.
Would a failure in the last command only be caused by a programming error in the python script?
currently it cannot fail at all (if anyting fails, it'll be the second nix-build). in a speculative future it could fail if the MD renderer produces a different output for any reason at all, even for stylistic choices. we might not be able to match the docbook-produced manual exactly, in which case the comparison would either have to be modified or maybe even removed again.
rebased to master because new docbook options appeared. no other changes. |
is there anything that still needs to be done here? really want to get this over with before it needs another rebase for newly introduced options. |
absent any further comments or change requests we'd like to merge this in a week. rebasing hasn't been necessary very often so far at least, which seems to be a good sign for the overall effort. |
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.
Almost looking good to me!
# render directly from markdown instead of going through a docbook intermediate stage. | ||
# currently this only forbids using docbook in option docs, it does not yet render | ||
# directly from markdown. | ||
, renderFromMD ? false |
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.
Why is this flag called renderFromMD
when it doesn't do that? If it just warns for docbook shouldn't it be called something like allowDocbook = true/"warn"/"error"
?
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.
Why is this flag called
renderFromMD
when it doesn't do that
it does not yet, but once this is merged we plan to start working on a direct-from-MD renderer that will be used when this flag is set.
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 is very misleading though. How about having such a proposed allowDocbook
and if we later allow markdown rendering, we can introduce another option renderBackend = "docbook"/"markdown"
. Then if "markdown" is chosen, allowDocbook
is forcibly set to "error" or null
(indicating docbook
is not even detected anymore, so the option doesn't make sense)
|
nixos/modules/misc/documentation.nix
Outdated
The `false` setting for this option is not yet fully supported. While it | ||
should work fine and produce the same output as the previous toolchain | ||
using DocBook it may not work in all circumstances. It is always permissible | ||
to set this to `true` when it was set to `false` previously. |
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.
Wait what does this mean? "It is always permissible to set this to true
when it was set to false
previously."?
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 documentation is expected to not break if this has been set to false
at some point and only markdown documentation added after that. setting it to false may break stuff, but unsetting it should definitely fix those breakages
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.
I see, how about rewording this a bit then, something like "Whether markdown option documentation is allowed is independent of this option."
deprecate literalDocBook by adding a warning (that will not fire yet) to its uses and other docbook literal strings by adding optional warning message to mergeJSON.
mostly no rendering changes except in buildkite, which used markdown where docbook was expected without marking up its markdown.
the nixos manual should not use docbook for module option documentation, only markdown, to make future transition to a markdown-only world easier and less painful. this check will ensure that all options documentation (even plain text that would not be interpreted specially by neither markdown nor docbook) is declared as being markdown.
we want to make sure that rendering the manual from markdown without going through docbook produces (semantically) the same output as with going through docbook. to ensure this we'll build the manual twice, run each manual through html-tidy to generate a normalized form and diff the normalized forms. we don't want to compare raw output because that exposes us to a lot of whitespace we'd have to reproduce exactly in the MD render. this check may be relaxed even further in the future, but hopefully not by much.
with all problems now resolved we'll go ahead and merge ahead of more docbook being added. hopefully no large problems will pop up, if so we can always revert and redo or apply fixes as needed. |
@pennae: this PR broke nixpkgs manual: https://hydra.nixos.org/build/190038194 |
|
included in the NixOS manual. During the migration process from DocBook | ||
to CommonMark the description may also be written in CommonMark, but has | ||
to be wrapped in `lib.mdDoc` to differentiate it from DocBook. See |
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.
Looks like lib.mdDoc
is no longer documented in the NixOS manual: https://nixos.org/manual/nixos/unstable/#sec-option-declarations
This leads to confusion: #200724
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 comment was marked as resolved.
This comment was marked as resolved.
following the plan in #189318 (comment) also adds an activation script to print the warning during activation instead of during build, otherwise folks using the new CLI that hides build logs by default might never see the warning.
Description of changes
deprecate docbook option docs and functions for creating docbook option docs. this very explicitly does not introduce warnings that could break a build to not break any systems when the 22.11 rolls around, and for 23.05 we'll want to remove docbook support for options entirely (without another warning).
a couple new module have been merged since the last conversion PR was started and a few options weren't converted even then, so we have to handle a few deprecation messages immediately as well.
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes