Let themes allow to provide markdown files

Created on 25 August 2023, over 1 year ago

Problem/Motivation

The project wiki currently only supports module's to provide markdown files. But there are also Drupal themes, which need documentation.
Unfortunately, this isn't easily done. We can not simply define a project wiki plugin in our theme. Our plugin manager won't crawl themes for plugins and the code, that limits this discovery to module's only, themes to be buried deep into Drupal core (correct me if I am wrong, but I couldn't find it and I went to the bottom of the 'AnnotatedClassDiscovery' and 'DefaultPluginManager' classes).

Steps to reproduce

Proposed resolution

We have two options here:

Option 1
Find a way, so that our 'ProjectWikiContentPluginManager' also crawls for plugin defintions inside themes (This might be impossible, as themes are probably not meant for this).

Option 2 (preferred)
Implement a theme alter hook, that gets called at the exact same position as our module alter hook (project_wiki_entity_content_value_objects, with which we currently can alter projectWikiValueObjects before they are given to our theme).
Then, we need to put most of our ProjectWikiMarkdownContentPluginBase logic inside a service, so we can call this new service inside the theme alter hook invocation, read, parse and prepare our markdown files. And return them to our Controller.

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany Grevil

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

Comments & Activities

  • Issue created by @Grevil
  • Assigned to Anybody
  • 🇩🇪Germany Anybody Porta Westfalica

    Best would be to do it just like within modules. I'll take a look. if it's possible somehow. Otherwise we could try to create a submodule within a theme. Never did that, but perhaps that's possible :D

  • Assigned to lrwebks
  • 🇩🇪Germany Anybody Porta Westfalica

    @lrwebks please look for a Drupal core way to do this (Option 1 preferred). Is there a core problem to do this?
    Any further thoughts for clean workarounds? Maybe we could define our own .yml instead or something that could also work in themes?

  • 🇩🇪Germany Anybody Porta Westfalica

    I'll need to take a look, this seems hard or even impossible without hacks for now.
    Maybe replacing the Plugin PHP file with a .yml could be a way to solve this, like for example layouts and other things are registered in themes and layouts...

  • 🇩🇪Germany Anybody Porta Westfalica

    https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Theme!ThemeManage... seems to be the right starting point I think! Especially maybe we have a chance through the alter hook

Production build 0.71.5 2024