I've been trying to get more involved with contributing to Drupal lately, and one of the tasks I've been exploring is creating a replacement to Drupal's API documentation website. There has been some high level discussions within Drupal's issue queue about moving onto a new documentation strategy for a number of different parts of the project, and this is one of them.
Namely, there are efforts underway to move so-called "high-level" documentation (in *.api.php) files into Markdown in a /docs directory and deploy them as a Zensical microsite. There are similar efforts underway to alter the way that the API documentation gets generated (also here), and that's what I've been trying to work on.
In response, I've been spending the last month or so developing a new proof-of-concept code-as-documentation project on Drupal's GitLab. This project that can:
- Pull the latest Drupal core (and any number of branches or tags)
- Build a static documentation site based off of the source code
- Deploy the documentation via GitLab*
* Drupal's GitLab instance has some limits on the final size of a GL Pages upload, so I can't properly upload the entire bundle at this time, but you can browse all of the uploaded artifacts in your browser, which are just flat HTML.
In order to take this to the next step, I'd need to acquire some static hosting and upload the artifacts there. That would probably need to be done by hand until I can work with the GitLab administrators to provision deployment secrets.
The tool I'm using to accomplish all of this is a neat little PHP project called Doctum, which I've recently started contributing to.
Drupal user fjgarlin has, in the past, identified Doctum as being a pretty good tool for building documentation, and he even did some early scouting that compared some of the major off-the-shelf PHP documentation tools against one another. In my opinion, Doctum came out looking pretty strong from those early tests.
One issue that phpdocumentor maintainer Jaap has pointed out, is that the maintainer of Doctum isn't super active. That said, I've had some decent back and forth with the maintainer and am trying to get some things merged into the code base, which is moving along.
Aside from that, Doctum provides some pretty cool features that make it a decent candidate for this type of work, including:
- Really comprehensive documentation for code written in OOP (Object Oriented Programming)
- Decent PHPDoc tag support
- A built-in and extensible default theme written with twig
- Source code tag and version support
- Built in Opensearch support
- Linking files back to the upstream source code repository
- Fairly quick build time (for multiple branches on a powerful computer, only about 2-3 minutes. Maybe 5 minutes in a CI job)
In my tests, the Drupal core code happens to be quite extensive, so a complete branch (typically main) is about 700mb. If we exclude the test directory that comes down to about 300mb-- it's big, but not crazy.
I've been playing around with extending the base implementation as much as I possibly can using the default configuration interface, and I've discovered that most of the features that we want out of the current API documentation are present, some can be built using twig, others will need to be added as contribs up to Doctum, and still more require some discussion.
The big issue right now is that Drupal's API documentation, though it does follow a lot of PHPDoc conventions, has a lot of custom behavior that has been added on via the in-house API module. Some big offenders that currently break the documentation are @group, the @code/@endcode tags, @see/@endsee tags (pretty much any @end<tag>), and some of the custom object tags like @Event.
I'm cautiously optimistic about this work, and try to sit down and add new and useful features to my experiment when I have the chance.
Currently, I'm exploring adding some things like:
- A section on classes that shows what other objects (in the same branch) reference that class
- A section on classes that shows what other branches or tags implement the same class
- A section of functions that links back to the original module
- Adding build information for each deployment so you can see any upstream changes from both the documentation project and Drupal core itself.
- Various fixes for custom tags that are baked into the Drupal documentation which Doctum can't support.
Add new comment