Skip to content
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

Improve cross referencing in NixOS Manual #38831

Merged
merged 3 commits into from May 1, 2018

Conversation

rdnetto
Copy link
Contributor

@rdnetto rdnetto commented Apr 12, 2018

Motivation for this change

Discoverability of Appendix A, which documents the options, is poor. This results in issues like #20548, where users copy isolated snippets without understanding them.

Things done

This PR modifies all references to options in manual to be links or cross-references to their section in the appendix. This means that the generated HTML will render them as hyperlinks, and that the manual will fail to build if someone removes/renames an option without updating it.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@jtojnar
Copy link
Contributor

jtojnar commented Apr 12, 2018

Do you have a script for adding the links? I think it would be best if the links were added during the build, otherwise the files will be quite messy or people will keep forgetting to add the links.

@rdnetto
Copy link
Contributor Author

rdnetto commented Apr 12, 2018

Do you have a script for adding the links? I think it would be best if the links were added during the build, otherwise the files will be quite messy or people will keep forgetting to add the links.

Unfortunately no - they were added by hand.

Automating the process is non-trivial, for the following reasons:

  • the tool would need to differentiate between terms which are options and terms which are package names. e.g. services.postgresql.package and pkgs.postgresql96 are defined in different places (and I don't know if the latter always has documentation)
  • the tool would need to be capable of parsing Nix, so that it could understand that foo.bar = { baz = null } means that the link should reference foo.bar.baz
  • the tool would need to understand wildcards like systemd.services._name_.serviceConfig
  • we'd probably need to extend the docbook syntax somehow so that the tool would know which sections to replace, since not all <programlisting>s contain Nix, and not all Nix is in <programlisting>s
  • what dependencies do we consider acceptable for building the manual? Haskell is a good fit for this kind of problem and already has libraries for parsing Nix, but I don't know how maintainable the community would find it

It's not unfeasible, but it's a decent chunk of work. My suggestion is that we start by manually maintaining the links, and figure out how/if we want to automate it.

Copy link
Member

@lheckemann lheckemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it!

Just one issue: you've modified the indentation in various places, which is mostly fine, except in some cases where the elements actually preserve whitespace, particularly <screen> sections. In these cases it results in worse rendering, since the leading whitespace is preserved. However, I see you've also fixed the same issue in some other places, which is also nice.

Thanks for this!

@rdnetto
Copy link
Contributor Author

rdnetto commented Apr 16, 2018

Just one issue: you've modified the indentation in various places, which is mostly fine, except in some cases where the elements actually preserve whitespace, particularly sections. In these cases it results in worse rendering, since the leading whitespace is preserved. However, I see you've also fixed the same issue in some other places, which is also nice.

I was learning the docbook syntax as I worked through this, so I probably did those sections before I realised that <screen> preserved indentation. Should be fixed now, let me know if I've missed any.

@rdnetto
Copy link
Contributor Author

rdnetto commented Apr 28, 2018

This should be ready to merge now, unless I've missed anything.

@grahamc
Copy link
Member

grahamc commented May 1, 2018

what dependencies do we consider acceptable for building the manual? Haskell is a good fit for this kind of problem and already has libraries for parsing Nix, but I don't know how maintainable the community would find it

Haskell is much too big. NixOS docs's build closure should remain fairly small.

@grahamc grahamc merged commit d1165db into NixOS:master May 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants