Document high-level API concepts in an easier format

Created on 25 July 2024, about 1 month ago
Updated 6 September 2024, 1 day ago

Problem/Motivation

Not sure exactly which issue queue this should live in - seems like a core decision whether we want to do it or not, but to make it work, we'd need to figure out how things show up on Drupal.org which will need the DA. Putting it here for now but we can add spin-off issues as necessary.

High level Drupal API docs live in two places at the moment:

1. In core.api.php in phpdoc syntax

This generates pages like https://api.drupal.org/api/drupal/core%21core.api.php/group/cache/11.x

2. In the Drupal.org handbook.

https://www.drupal.org/docs/8/api/cache-api/cache-api β†’

--

core.api.php can obviously be updated via a core MR, but despite being both a core committer and cache API maintainer, trying to do anything but the most basic changes here fills me with dread - I really dislike using phpdoc for prose.

The Drupal handbook can be updated by anyone with permissions, but it's never clear to me how or when to make a big structural update to pages. For example the first page of https://www.drupal.org/docs/8/api/cache-api/cache-api β†’ immediately jumps into mentioning quite complex caching concepts with no preface, and mixes the low level cache API and render caching together without clearly delineating between the two. But if I wanted to embark on a full rewrite of that page, can I just do that or does it need a documentation issue first?

On the other hand, if I want to look at Symfony cache component documentation, I can go here:

https://symfony.com/doc/current/components/cache.html

Or for Laravel: https://laravel.com/docs/11.x/cache

Symfony's docs are stored in a dedicated repository in .rst syntax, which is similar to markdown.

Steps to reproduce

Proposed resolution

I don't know what the end point of this is, but I feel like we should not be storing and editing long-form prose in PHP comments detached from actual code (i.e. what we do in core.api.php).

This gives us a couple of options:

1. Take high level conceptual documentation out of core.api.php into the handbook - e.g. rewrite the handbook cache documentation and open an issue to remove that section from core.api.php or replace it with a link.

2. Find another way to provide version controlled high-level API documentation, whether .rst or a similar format, potentially rendering this on api.drupal.org using https://github.com/Gregwar/RST or similar.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🌱 Plan
Status

Active

Version

11.0 πŸ”₯

Component
DocumentationΒ  β†’

Last updated less than a minute ago

No maintainer
Created by

πŸ‡¬πŸ‡§United Kingdom catch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @catch
  • πŸ‡¬πŸ‡§United Kingdom catch
  • πŸ‡¬πŸ‡§United Kingdom catch
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    I have been thinking about this a fair bit, sparked by recently spending way too many hours to get some documentation to display correctly on api.drupal.org. Once that task was done, the next thing I did was look at what Symfony does. The reStructuredText (RST) format certainly looks much better for writing example code than what we have now. As for prose, I don't think there is as much of a difference, but still RST is easier. I did note that in the Symfony docs one can't view a single php file.

    For the proposals

    1. Doing this is more likely to lead to improvements than the longer path of creating an issue, MR, and so.

    2. What I think about here are, in no order, a) how the docs will be structured, b) need to follow a page of instructions to get setup to contribute, c) who has commit access, d) may not improve the documentation, e) adds a new place to find documentation without removing one. But I do think this should be pursued. And proposal 1 can happen independently of the decision on this.

    And with both 1 and 2 we don't have to wait 1 week for api.drupal.org to be re-parsed for the doc to be updated.

  • πŸ‡ΊπŸ‡ΈUnited States moshe weitzman Boston, MA

    Agree with most of the proposed resolution. My thoughts:

    1. Move long form texts to a new /docs folder in core (and contrib). The folder contains markdown files. Publish the docs via mkdocs or any other static site generator (SSG) that core prefers. mkdocs is the the SSG behind DDEVand Drush docs. We already support this in our Gitlab templates. Benefits:
      1. Once we are fully on Gitlab, it becomes super friendly to non devs and lazy devs to submit an MR via the Gitlab UI to change the docs.
      2. Docs can change along with code
      3. Docs automatically vary by branch.
    2. Retire the api module and use Doctum or similar external project to generate our API docs. We can start with Drupal 12, and keep the API module docs as more or less static for older versions.
Production build 0.71.5 2024