Problem Statement

When Reading Render API documentation it is clear that a render array must be built, but it is unclear what render elements may be used in the render array or are provided by core.

Proposed Resolution

Add short statement to the Render API topic in the documenation provideding a see reference or link to the list of form elements provided at:

https://api.drupal.org/api/drupal/elements

CommentFileSizeAuthor
#8 2680307-6-api-navigation.patch1.63 KBmetzlerd

Comments

metzlerd created an issue. See original summary.

jhodgdon’s picture

I'm not sure how exactly I'd suggest making this link... Ideally, as Drupal evolves into new versions, the link would take you to the appropriate elements list for the version of the page you are looking at... that is not easy to do, since we can only put in a URL that goes to one particular version.

So probably, rather than making a real URL link, we should instead tell them how to find the list on api.drupal.org, something like

Find the Elements list in the sidebar block ...

metzlerd’s picture

Hmmm... I had actually not even seen the elements link in the sidebar. That does help the navigation. Do you think in the context of the documentation it would be better to rename that Render Elements, since that is how they appear to be referenced everywhere in the render api docs?

It's unfortunate that we can't provide a direct link. Is there no API page that we can reference, or any way to create api pages that reference these links? Or a way to display the list in an api page that we can reference in the docs? (Just trying to think outside the box).

jhodgdon’s picture

Sorry, there isn't a good way to do this.

You might look at what we did on the Services topic page:
https://api.drupal.org/api/drupal/core!core.api.php/group/container/8

API reference sites (such as https://api.drupal.org) generate lists of all existing services from these files, or you can look through the individual files manually.

I suggest we do something similar here... something like this:

API reference sites (such as https://api.drupal.org) generate lists of all existing form and render elements from these classes, or you can look for them manually.

metzlerd’s picture

Did you have an opinion about renaming Elements to Render Elements in the side bar itself? It would be nice if the language in the Render API at least was consistent with the API site. If so where would such a request get properly made?

metzlerd’s picture

So i've been thinking more about this. The Render API documentation basically says you can search for them already (but doesn't tell you how). Most people who will be reading these docs will already be on an API reference site such as api.drupal.org. My real problem was that when I was drilled into and reading the API documentation. I didn't think to look in the API Navigation block, partly because I never would have thought that the API Navigation block would provide access to content that I couldn't get to any other way.

I don't think the language from services example does anything to solve my original issue, which is that I was thinking for some reason that there would be links to that embedded in the api docs. Now that I know about that block I probably will never look at the render API docs again for this information, but I'm left with an uncomfortable feeling that this will be something that you "Just have to know" about api.drupal.org in order to use it.

My own preference would be to go ahead and embed the specific links, even though they will need to get modified for every branch (because I think it's worth the maintenance headache), or to create an issue in the API project that would allow us to create these references in a sane way. So if we don't want to go down either of these two paths, my inclination is to just mark this as "won't fix", and move on.

It's a bit disappointing, but I'll get over it... ;)

jhodgdon’s picture

RE #5 ... The sidebar is pretty narrow so I don't think I'll look favorably on renaming Elements to Render Elements in the sidebar. By the same token, the "Classes" link actually goes to "Classes, interfaces, and traits", but there isn't really room to put all of that there. If you want to request it, though, it would be an API module issue. project/api that is.

RE #6 ... I disagree strongly about embedding the specific links. That type of maintenance will never ever ever get done, and people will click on the links and not realize they're now in a different version of Drupal by mistake.

Let's instead figure out some language that would say to look for the links in the API site navigation block or something like that that would be clearer, and put it into both the Services and Render API blocks?

metzlerd’s picture

Status: Active » Needs review
StatusFileSize
new1.63 KB

Here's a first stab. Thoughts?

jhodgdon’s picture

Title: Link Render API To Render Elments API Docs » Direct people to Services and Elements pages on API sites in a clearer way
Version: 8.0.x-dev » 8.2.x-dev
Status: Needs review » Reviewed & tested by the community
Issue tags: +needs backport to 8.1.x, +needs backport to 8.0.x

I think this is perfect. Thanks!

Moving this to 8.2.x so the patch will be tested there. Needs to be committed to all 3 branches. Patch most likely will apply to all.

metzlerd’s picture

I verified that this patch is no different when generated against the 8.2.x branch and attempted to requeue the patch for testing. Not sure if I did that right... But I'm quite sure this will apply cleanly to 8.2.x-dev.

  • alexpott committed e0b0ed3 on 8.2.x
    Issue #2680307 by metzlerd, jhodgdon: Direct people to Services and...

  • alexpott committed 2f80c26 on 8.1.x
    Issue #2680307 by metzlerd, jhodgdon: Direct people to Services and...

  • alexpott committed 839e34a on 8.0.x
    Issue #2680307 by metzlerd, jhodgdon: Direct people to Services and...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 839e34a and pushed to 8.0.x, 8.1.x and 8.2.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.