-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
CONTRIBUTING: Add hotlinks to package and module reviewing guides, minor touchups #263575
CONTRIBUTING: Add hotlinks to package and module reviewing guides, minor touchups #263575
Conversation
b3505fe
to
af7dc47
Compare
af7dc47
to
3a97930
Compare
CONTRIBUTING.md
Outdated
@@ -556,6 +556,7 @@ Pull requests should not be squash merged in order to keep complete commit messa | |||
If you removed packages or made some major NixOS changes, write about it in the release notes for the next stable release in [`nixos/doc/manual/release-notes`](./nixos/doc/manual/release-notes). | |||
|
|||
### File naming and organisation | |||
[file-naming-and-organisation]: #file-naming-and-organisation |
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.
Unfortunately these only work locally in the file, changing the title will still break pages linking to it..
What should work, and I really think we should have that, is custom HTML anchors like
<a name="location"></a>
Can you try that and confirm whether it works?
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.
Is pandoc commonmark notation supported?
### File naming and organisation {#location}
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.
Unfortunately not
3a97930
to
06d00e3
Compare
CONTRIBUTING.md
Outdated
@@ -266,7 +266,7 @@ for review, which allows you to sidestep this issue. | |||
This is not a bulletproof method though, as OfBorg still does review requests even on draft PRs. | |||
``` | |||
|
|||
## How to backport pull requests | |||
## How to backport pull requests<a name="how-to-backport-pull-requests"></a> |
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.
## How to backport pull requests<a name="how-to-backport-pull-requests"></a> | |
## How to backport pull requests <a name="how-to-backport-pull-requests"></a> |
When I add a space as suggested above then pandoc --to gfm
adds a -
at the end of the automatic id
of the h2
tag. I assume pandoc behaves like github in this manner.
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.
If i add the anchor below the title, then it gets put inside the p
block
I did as suggested, but the results is not pretty to read in source. Perhaps a CI check that looks for dead links is the way to go? EDIT: humble beginnings:
|
It would also be great for third-party documents to be able to link to anchors, but I guess for now something like that would be better than nothing |
I've committed heinous crimes, but alas we do have a prototype: { pkgs ? import ./. {}
, lib ? pkgs.lib
}:
with pkgs;
let
src = let
toLink = path: {
inherit path;
name = lib.removePrefix "${toString ./.}/" (toString path);
};
in pkgs.linkFarm "nixpkgs-gfm-docs" (map toLink [
./CONTRIBUTING.md
./README.md
./doc/README.md
./lib/README.md
./lib/path/README.md
./maintainers/README.md
./nixos/README.md
./pkgs/README.md
./pkgs/by-name/README.md
./pkgs/test/nixpkgs-check-by-name/README.md
]);
in
runCommand "test-nixpkgs-gfm-links" {
nativeBuildInputs = [ htmlq pandoc ];
} ''
md2html() {
local fname="$1" # relative to ${src}
if test -f html-cache/"$fname"; then
cat html-cache/"$fname"
else
mkdir -p "$(dirname html-cache/"$fname")"
pandoc ${src}/"$fname" --from gfm --to html | tee html-cache/"$fname"
fi
}
return_code=0
shopt -s globstar
for fname in ${src}/**/*.md; do
fname="''${fname#${src}/}" # strip nix store prefix
get_links() (
set +o pipefail
md2html "$fname" \
| htmlq a --attribute href --base file:///"$fname" \
| grep '^file:///' \
| cut -d/ -f4- \
| grep -E '\.md(#.*)?$' \
| sort -u
)
while IFS=# read target anchor; do
if ! test -f ${src}/"$target"; then
>&2 echo "ERROR ($fname): resolved reference not found: $target"
return_code=1
continue
fi
test -n "$anchor" || continue
if test -z "$(md2html "$target" | htmlq "#$anchor")"; then
>&2 echo "ERROR ($fname): resolved reference not found: $target#$anchor"
return_code=1
fi
done < <(get_links)
done
touch $out
exit $return_code
'' Output:
The first two are genuine errors, and the last two are due to my code not handling |
06d00e3
to
669e8aa
Compare
I cleaned it up and pushed it as @ofborg build tests.nixpkgs-check-readme-links |
669e8aa
to
f86a538
Compare
Nice! Though just recently I was pointed to https://github.com/serokell/xrefcheck, which looks a bit nicer 😅 In any case, could you do that in a separate PR? This way we can merge this one with just the doc improvements/fixes |
f86a538
to
68686fb
Compare
Otherwise looking good! |
…es, fix references
68686fb
to
8feb68f
Compare
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.
Nice thanks!
Description of changes
I missed a detail myself, so let's improve discoverability.
Rendered:
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/
)