mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 20:25:32 +03:00
nixos-render-docs: make error message on broken redirects less verbose
before, we were showing (almost) the same set of options twice in case of renaming an identifier, which is confusing and obsucres the recommendation. after this change we also show the recommendation in a much more frequent case, when contributors add a new identifier.
This commit is contained in:
parent
c9e5b2da15
commit
ae87721626
1 changed files with 13 additions and 33 deletions
|
@ -28,8 +28,7 @@ Identifiers must not be identical to any historical location's anchor of the sam
|
|||
The following identifiers violate this rule:
|
||||
- {"\n - ".join(self.conflicting_anchors)}
|
||||
|
||||
This can break links or redirects. If you added new content, choose a different identifier.
|
||||
""")
|
||||
This can break links or redirects. If you added new content, choose a different identifier.""")
|
||||
if self.divergent_redirects:
|
||||
error_messages.append(f"""
|
||||
All historical content locations must correspond to exactly one identifier.
|
||||
|
@ -37,8 +36,7 @@ All historical content locations must correspond to exactly one identifier.
|
|||
- {"\n - ".join(self.divergent_redirects)}
|
||||
|
||||
It leads to inconsistent behavior depending on which redirect is applied.
|
||||
Please update doc/redirects.json or nixos/doc/manual/redirects.json!
|
||||
""")
|
||||
Please update doc/redirects.json or nixos/doc/manual/redirects.json!""")
|
||||
if self.identifiers_missing_current_outpath:
|
||||
error_messages.append(f"""
|
||||
The first element of an identifier's redirects list must denote its current location.
|
||||
|
@ -46,14 +44,18 @@ The first element of an identifier's redirects list must denote its current loca
|
|||
- {"\n - ".join(self.identifiers_missing_current_outpath)}
|
||||
|
||||
If you moved content, add its new location as the first element of the redirects mapping.
|
||||
Please update doc/redirects.json or nixos/doc/manual/redirects.json!
|
||||
""")
|
||||
Please update doc/redirects.json or nixos/doc/manual/redirects.json!""")
|
||||
if self.identifiers_without_redirects:
|
||||
error_messages.append(f"""
|
||||
Identifiers present in the source must have a mapping in the redirects file.
|
||||
- {"\n - ".join(self.identifiers_without_redirects)}
|
||||
|
||||
This can happen when an identifier was added or renamed.
|
||||
- {"\n - ".join(self.identifiers_without_redirects)}""")
|
||||
if self.orphan_identifiers:
|
||||
error_messages.append(f"""
|
||||
Keys of the redirects mapping must correspond to some identifier in the source.
|
||||
- {"\n - ".join(self.orphan_identifiers)}""")
|
||||
if self.identifiers_without_redirects or self.orphan_identifiers or self.identifiers_missing_current_outpath:
|
||||
error_messages.append(f"""
|
||||
This can happen when an identifier was added, renamed, or removed.
|
||||
|
||||
Added new content?
|
||||
redirects add-content ❬identifier❭ ❬path❭
|
||||
|
@ -67,31 +69,9 @@ Identifiers present in the source must have a mapping in the redirects file.
|
|||
Removed content? Redirect to alternatives or relevant release notes.
|
||||
redirects remove-and-redirect ❬identifier❭ ❬target-identifier❭
|
||||
|
||||
Note that you need to run `nix-shell doc` or `nix-shell nixos/doc/manual` to be able to run this command.
|
||||
NOTE: Run `nix-shell doc` or `nix-shell nixos/doc/manual` to make this command available.
|
||||
""")
|
||||
if self.orphan_identifiers:
|
||||
error_messages.append(f"""
|
||||
Keys of the redirects mapping must correspond to some identifier in the source.
|
||||
- {"\n - ".join(self.orphan_identifiers)}
|
||||
|
||||
This can happen when an identifier was removed or renamed.
|
||||
|
||||
Added new content?
|
||||
redirects add-content ❬identifier❭ ❬path❭
|
||||
|
||||
Moved existing content to a different output path?
|
||||
redirects move-content ❬identifier❭ ❬path❭
|
||||
|
||||
Renamed existing identifiers?
|
||||
redirects rename-identifier ❬old-identifier❭ ❬new-identifier❭
|
||||
|
||||
Removed content? (good for redirecting deprecations to new content or release notes)
|
||||
redirects remove-and-redirect ❬identifier❭ ❬target-identifier❭
|
||||
|
||||
Note that you need to run `nix-shell doc` or `nix-shell nixos/doc/manual` to be able to run this command.
|
||||
""")
|
||||
|
||||
error_messages.append("NOTE: If your Manual build passes locally and you see this message in CI, you probably need a rebase.")
|
||||
error_messages.append("NOTE: If your build passes locally and you see this message in CI, you probably need a rebase.")
|
||||
return "\n".join(error_messages)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue