Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This is a follow-up for #2352155: Remove HtmlFragment/HtmlPage.
That issue added a big section to theme.api.php
:
@section render_pipeline The Render Pipeline (or: how Drupal renders pages)
…
And created a diagram to go along with it. We didn't want to block that important issue on dealing with the details of where the diagram created for that issue should live. This issue is about deciding that.
Comment | File | Size | Author |
---|---|---|---|
#19 | 2373741-19.patch | 7.22 KB | Wim Leers |
Comments
Comment #1
Wim LeersThe parent issue landed, we can now continue here.
Comment #2
jhodgdonUm... that diagram... is ... large.
Perhaps it would be better as a drupal.org page attachment rather than trying to get it into api.drupal.org? Our philosophy on api.drupal.org topics and other documentation has been "Give the essentials, like to drupal.org for more details". This seems like a "more details" thing to me.
Regarding the section added to
https://api.drupal.org/api/drupal/core!modules!system!theme.api.php/grou...
needs some work. Please take a look at it. The @code sections should not be @code (that is for *blocks* of code, not individual functions/classes) and there is at least one broken @ref.
Plus it is really long and rambling, and I'm not even sure it belongs on the Render API topic page? It should either be a separate topic or just be on drupal.org IMO.
Comment #3
Wim LeersOk.
What would be the recommended place/location for this?
The overall feedback for this diagram has been that it's helped people understand how Drupal 8 renders pages and how it works in general at a high level. Many people have said it's crucial that this diagram is very visible, very findable. So we should ensure that is the case. Sometimes, a diagram can say more than a thousand words.
Oh boy, that doesn't look good. How can we see what this will look like *while* writing the docblocks? Because that's the crucial piece I've always missed: I try to write everything correctly, with the correct semantics, but then it almost never ends up looking like I expect.
So how do I then annotate code references rather than blocks of code? We use
<code>
for that on d.o. Markdown uses backticks. Some sites use<tt>
. How does that work for api.d.o?What would that topic be? "The render pipeline"?
Comment #4
jhodgdonWe have a whole section on drupal.org at
https://www.drupal.org/developing/api/8
documenting the Drupal 8 APIs. It should go in there.
Regarding seeing how things look while doing updates, the only way is to build your own API site, or to ask me to review patches because I have a "pretty good feel" for it.
Regarding @code we simply do not indicate in-text code on api.d.o. Things like classes and functions turn into links automatically, and we use @code *sections* when providing examples. That's how all other doc blocks in Drupal core are written.
Regarding separate topic... The rest of the Render API topic that was there before this patch is about how to use render arrays and stuff like that.
This new section is about how Drupal does stuff, not about how to use the API, which is why I don't think it belongs on this topic.
So yes, please do make it a separate topic called "Render Pipleline" and since each topic has a one-line description, that could be "Description of how Drupal renders pages".
Comment #5
Wim LeersBut that's not visible and findable enough. I never ever use https://www.drupal.org/developing/api because it's so incomplete and incoherent. Never since 2006. Many with me, probably. But I — and everybody I've ever seen work in Drupal — uses https://api.drupal.org all the time. So … to increase visibility/findability of that diagram, can we link from api.d.o to d.o/developing/api/8/something ?
Comment #6
webchickMakes sense to me. Could link from https://api.drupal.org/api/drupal/core%21includes%21menu.inc/group/menu/8 would probably be the most likely place.
Comment #7
jhodgdonAgreed with #6. Also I would like to point out that the api.d.o landing page for Drupal 8 ( https://api.drupal.org/api/drupal/8 ) does have a link (in the Further Information section at the bottom) to https://www.drupal.org/developing/api as a whole, or rather to the D8 section, and that most of the D8 topics that you can get to from the D8 landing page also contain links to the expanded documentation on drupal.org. So yes, definitely, add a link to this new docs page, once it's created.
Comment #8
jhodgdonAlso, a bit of history: We had an issue about a year ago where I was trying to get the drupal.org/developing/api docs into the Drupal Core code base for Drupal 8, or at least into a git repo where they could be edited via patches and displayed on api.drupal.org.
I got a prototype working and people tried it out... several iterations... But the end result was that the community decided they preferred to use the current system on drupal.org. I disagreed with this decision but I am not a dictator so we're stuck with the current drupal.org placement of these docs.
If you're interested, you can read through the issue to see how the discussion went -- the motivation was essentially what you said in #5. Anyway, here's the issue (although none of the demo sites is still active of course): #2106873: [meta][policy, no patch] Make Drupal 8 developer docs more discoverable
Comment #9
Wim LeersThank you very, very much for the explanation #8. I very strongly agree with what you set out to do, but which unfortunately did not come to happen :(
I'm pretty certain that the docs currently in
theme.api.php
for the render pipeline also don't meet your standards/requirements. So let's remove that, shorten it and point to a d.o handbook page.So, I created https://www.drupal.org/developing/api/8/render/pipeline, which contains a clearer, better structured version of what's currently in
theme.api.php
and includes the diagram. I think/hope you will be pleased. (Thanks to #2444211-20: Document cacheability of render arrays, and the considerations to use when generating render arrays, I know have a much better idea of how you want the in-code docs to look like.)Finally, here's a patch to clean up
theme.api.php
. I think there may be too many@see
s there — happy to reduce those.Comment #10
jhodgdonThanks! This is definitely a step in the right direction, and the d.o page is good.
A few thoughts on the current patch:
a)
No blank line after @section. Also, we normally start sections with a brief introduction (especially if they're long sections), ending with a "For further information" bit, rather than just starting a section saying "For further information". It's a bit jarring. Probably instead of "First, you need to know..." we should also say something like "For background on general routing concepts, see @ref ...".
b) Don't say "please" in documentation. Ever. ;)
c) The numbered list... the API module doesn't support numbered lists and we don't have them in our API docs in general. Not introduced by this patch, but it should be replaced by a bullet list, and also before any list should be a line ending in : explaining what is in the list.
So I'd propose changing:
to
or something like this. This list is more bullet-like than numbered-like anyway, as far as I can tell.
d) There are some line wrapping issues in the numbered list. All lines should go out to nearly 80 characters within a single paragraph or bullet item.
e)
What does "handles controllers" mean? Also "which" requires a comma before it.
f)
Serial comma needed between "Dialog, and ". And really, "Dialog" and "Modal" shouldn't be capitalized, and "Ajax" should not be all-caps.
g)
Um. First off, please stick to ASCII in API docs, no -- character. And we try to avoid "e.g."; better to write out "for example" -- you'd be surprised how often e.g. and i.e. are confused and misused. And this is not punctuated correctly... but the real problem is that I'm not sure what this means. What is decoration? How are panels decoration?
h)
Is there a way we could combine this with the bullet list?
So a proposed rewrite of this whole section would be something like this (replacing the proposal in my review item (c) above):
Comment #11
Wim LeersComment #12
jhodgdonLooking good! A few minor things still to address:
a) Unfortunately paragraph breaks don't work in bullet lists in API docs. Sorry.
I think the thing to do here is to make them two separate bullets, which I think is OK.
b)
This is a comma splice. Replace , with ;
c)
Can we mention how to do this briefly? Such as something like ", which is a plugin annotated with \Drupal\Foo\Bar\Whatever annotation". (that will turn into a link to the plugin annotation class, which will have more information). Possibly it's one of your @see lines, but including the reference right here will make it more obvious to developers.
c)
We don't have numbers so this is confusing. I think we can just take out the references to 1, 2, 3 and it will be clear enough.
Maybe the second paragraph could be:
Routes whose controllers return the "main content" for the page as a render array can be requested in different formats (HTML, JSON, etc.), and/or in a "decorated" manner, as described above.
I'm still not convinced we need these two paragraphs separate from the bullet list. It still seems to me that integrating the information into the above bullet list would be clearer and would require less repetition and "see above" kinds of references. But I don't feel too strongly about it.
d)
At the end of this, maybe change it to:
... around the main content), and the contributed Panels module, for example.
Also I think it might be useful to do something like (c) here to explain where these "decorators" come from or what class they are, or how it's decided which one to use for a given page?
Comment #13
Wim LeersComment #14
jhodgdonThat looks good! One very very very minor thing: On another Documentation issue, there's an effort underway to remove ... from documentation. So let's not introduce one here:
Just use ", etc." instead. Then you can RTBC your own patch and we can all rejoice. Thanks a bunch!
Comment #15
star-szrGreat to see this coming together :)
Comment #16
hussainwebMaking the small change as per #14 and marking it as RTBC as per that comment.
Comment #17
Wim LeersYay!
Comment #18
alexpottNeeds a reroll.
Comment #19
Wim LeersComment #20
hussainweb@Wim Leers: I think you picked the interdiff from something else. Since this is just a reroll, I don't think an interdiff is even necessary (or possible).
Comment #21
Wim Leers#20: you're right! I'm too damn used to always upload a patch and an interdiff :/
Please ignore the #19 interdiff! It was a rebase, an interdiff doesn't make any sense anyway.
Comment #22
alexpottDocs are not frozen in beta. Committed 505e393 and pushed to 8.0.x. Thanks!