Conversation
|
Context: There are two ways in which we can reference examples:
We currently have 150 :doc: links and 7 :ref: links mapping to examples. I give my perspective on the advantages / disavantages of Advantage:
Disadvantage:
IMHO :ref: links for examples only have the advantage that we can change the filenames / directory structure without the need to update the links. But we rarely do that (i) because it's rarely needed and (ii) such a change requires putting up a redirect, which is some effort in itself. I don't see an additional search/replace for the corresponding On the background that the examples references are much more read than changed I find that the disadvantages for reading/using outweigh the possibility of a slightly simpler filename/directory change. Therefore, I'm 0.5 on this. |
|
First, the references to examples comparison is a bit chicken and egg - the example gallery was made without references, so no one refers to them. However I think there are pros and cons to both referencing systems that depend a little on how you work - referencing by the webpage path is fragile and doesn't match the code tree path so its not very straightforward, and if you reference the stable docs, you need to remember what part of the path to refer to in the Regardless, this PR isn't prescriptive is how anyone uses the references or not - it just adds the references. |
That's also apples to oranges. In written .rst docs, you often have multiple sections in a document and want to link to a specific section inside the document, not the document as a whole. It's reasonable (and for non-top-level sections a necessity) to use :ref: there. In contrast we want to reference examples as a whole, not the title of the example.
We shouldn't "just add" stuff. I value consistency very high and want an agreed upon and documented policy how we want to reference docs. That may seem pedantic but IMHO it would be the worst outcome if half of the examples are referenced by :doc: and the other half by :ref:. Currently we predominantly use :doc: for example references and also explicitly use a gallery example for a :doc: example it in our documentation guide. If you want to change this, I want to have this conversation. I'm fine if others vote in favor of always using :ref:, but please let's do this systematically and not create a mess. |
|
That link takes me to a page that describes using both Also note that the document you link does explicitly advise against names like
I don't think I am proposing to change anything. I am pretty sure I chose the original examples to reference with |
|
Ok, maybe I'm overinterpreting and we don't have a standardized approach for referencing examples. But then I'd like to clarify our policy here. We have three options for example references:
My priority would be (1) > (2) > (3) for the reasons already given above. What do you propose? |
|
I think we should have lots of cross references. I don't really care what form they take, but given that ref works whether I am referencing page or a section, I have a mild preference for it. So I guess my ranking is 3>2>1. |
|
Ok, now we have pinned the conflict 1>2>3 vs. 3>2>1. Should we move this to one of the next dev calls? I suspect it might be easier to find an agreement there rather than through a written discussion. |
|
I'll ping about this. Adding reference labels to files has only a very mild cost to file size and makes changes robust to reorganization. Whether one uses |
|
Independent of examples, my understanding of labels is that you define them just when you need to :ref: them. It feels premature to define labels just in case. We do not do this for sections. So if we say :ref:ing examples is ok, I'd follow that practice. Other than that, I believe both our positions are clear and we need somebody else to take a stance. |
|
For sure - these were all used in #29124. |
|
I am weakly 3 > 2 > 1 . One practical difference is that the :doc: link hits the very top of the page, the :ref: link will be scrolled down a little bit so that the title is at the top of the browser window (which if you target the top heading effectively cuts off the cookie crumb bar). I'm inclined to merge this. |
I find this very annoying, links to examples should go to the top of the page. Everything else looks like a bug and always makes me uneasy whether there is something hidden above (though technically I know there isn’t. Independently, I still don’t see why we need to prematurely add all the labels. Even if you rather :ref: than :doc: you can add them as you need them. This feels like unnecessary clutter to me. |
|
I have the opposite sense in that I like that the :ref: links scroll down a bit to hide the boiler plate! This is extracted from #29124 which does use them all so with that context this is not preemptive. |
|
I still find the addition awkwardly ad-hoc. The labels don’t comply with our existing label conventions (no underscores) https://matplotlib.org/devdocs/devel/document.html#refer-to-other-documents-and-sections Also, if we’re going to systematically use labels for examples, I recommend to extend the policy and prefix the example labels with |
Hmm, and I even wrote that convention - happy to fix all these to be dashes...
That seems reasonable - I'll try to add a prefix to these where it makes sense |
c2f421a to
073fb4d
Compare
|
The latest commit only does |
|
I’m still not a big fan, but not enough to block if others think this is the way to go. So do as you see fit. |
PR summary
This just adds label references to some prominent examples so they can be referenced by
:ref:elsewhere in the docs.These get used in #29124.