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

doc: Explain how to link to options in the manual #102246

Open
nh2 opened this issue Oct 31, 2020 · 8 comments
Open

doc: Explain how to link to options in the manual #102246

nh2 opened this issue Oct 31, 2020 · 8 comments

Comments

@nh2
Copy link
Contributor

nh2 commented Oct 31, 2020

I'm trying to write a release notes entry and spending an unjustified amount of time trying to make the hyperlink to a NixOS option documentation work.

I want to link to systemd.services.<name>.unitConfig.

Searching in the existing release notes code, I found repeated usage of at least the following patterns, out of which only one works:

  • <option>networking.interfaces.&lt;name&gt;.useDHCP = true;</option>
    • does not work, no hyperlink is created
  • <varname>hardware.logitech.lcd.enable</varname>
    • does not work, no hyperlink is created; probably <varname> wasn't made for this
  • <literal>security.acme.certs._name_.user</literal>
    • does not work (as expected, given that it's <literal>, no hyperlink is created, and that's probably fine given that this is the old value for the option), but it still renders wrong in the manual, namely as security.acme.certs._name_.user
  • services.tinc.networks.<name>.bindToAddress
    • does not work (<literal> was used so no link is created)
  • <xref linkend="opt-systemd.network.networks._name_.dhcpV4Config"/>
    • works

Thus, only few people seem to know how to link to a NixOS option, so the manual is full of non-working links.

Proposed solution

  • Why does <option> even exist if it doesn't link correctly? Is it for command line options? We need to explain it.
  • Could we have a <nixos-option> tag that "just works" without escaping and magic prefixes e.g. <nixos-option>systemd.services._name_.unitConfig</nixos-option>?
  • We should recommend one way to refer to no-longer-existing / removed options (probably <literal>).
  • We should explain somewhere easy to find what the correct way is, and that <option>, <varname>, <literal> are all wrong for this purpose.
    This should probaly be done in contributing-to-this-manual.xml.

CC a somwhat arbitrary list of contributers that might be interested/knowledgeable in this: @edolstra @jonringer @jtojnar @doronbehar

@nh2
Copy link
Contributor Author

nh2 commented Oct 31, 2020

I cannot figure out how NixOS/rfcs#72 would affect or improve this.

In the example from there, the services.xserver.libinput.enable from the code listing links to the NixOS option correctly, but I don't know how they do it or where the sources for that are.

Can you tell me @mboes?

@jonringer
Copy link
Contributor

A lot of this might change with the common mark rfc

@jtojnar
Copy link
Member

jtojnar commented Oct 31, 2020

DocBook elements have semantic definitions but not really a prescribed rendering. You can read their definitions in the DocBook documentation:

Yeah, according to the specification <option> is for command options and we are overloading the meaning. I guess <varname> is the most correct choice but <option> sounds a lot nicer so it gets used most often 🤷‍♀️

In the default stylesheet we use for rendering DocBook to HTML, the elements are simply rendered as <code> or something similar, with class attribute to distinguish them for styling with CSS. If we want links, we need to add them separately.

We render the Options appendix as <variablelist>. Each entry is assigned an xml:id generated from its name like this:

<xsl:variable name="id" select="concat('opt-', str:replace(str:replace(str:replace(attr[@name = 'name']/string/@value, '*', '_'), '&lt;', '_'), '>', '_'))" />

The ID then can be used across the whole document by either:

There are other options for linking, including a cross-document linking using olink but the two options above are the most relevant.

We could also add a rule to the stylesheet, that would linkify all <option>s that contain a string matching an existing NixOS option. Not sure how it would affect performance, though. A custom element would be easier in that regard since we could just replace it with <xref /> without any set up.

With the impending doom port to CommonMark, I am not sure if it is worth it to spend any time on this, though.

@FRidh
Copy link
Member

FRidh commented Dec 4, 2020

I cannot figure out how NixOS/rfcs#72 would affect or improve this.

In the example from there, the services.xserver.libinput.enable from the code listing links to the NixOS option correctly, but I don't know how they do it or where the sources for that are.

Can you tell me @mboes?

I found the link to the sources NixOS/rfcs#72 (comment). As mentioned there, only a single file was markdown, the rest was actually the result of a docbook to restructuredtext conversion. Restructuredtext has a lot more metadata.

@stale
Copy link

stale bot commented Jun 3, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 3, 2021
@jonringer
Copy link
Contributor

the 21.11 release notes will be written in markdown. Going to close as linking to options (at least in context of dockbook) is no longer relevant.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 3, 2021
@jtojnar
Copy link
Member

jtojnar commented Jun 4, 2021

We still need to link to options and I have seen someone suggest the incorrect syntax on Matrix yesterday.

Currently, it is [`enable`](#opt-services.xserver.libinput.enable) for options with custom label and <xref linkend="opt-services.xserver.libinput.enable"/> for automatic label. Using the anchor format is important since otherwise (e.g. using options.html#hash) will cause the link not to be checked.

Linking options in submodules also is not trivial (replace <, > and * for _ in the anchor). Or just copy the anchor from the option link on the options page.

Eventually, I want to use empty links for the automatic anchors (e.g. [](#opt-services.xserver.libinput.enable)), which has precedent in MyST but we are not there yet.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2022-10-22-documentation-team-meeting-notes-12-nixcon-edition/22689/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants