Problem/Motivation

We need to document all of the special keys like distribution and the newer opt in and opt out.

Steps to reproduce

N/A

Proposed resolution

Create a profile.api.php in the Extension namespace.
We can move some of the hook docs in core.api.php over as well.

Remaining tasks

User interface changes

N/A

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Issue fork drupal-3615639

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nicxvan created an issue. See original summary.

macsim made their first commit to this issue’s fork.

macsim’s picture

Status: Active » Needs review

MR opened.

Generated with the help of an LLM.

nicxvan’s picture

Status: Needs review » Needs work

We need to add the new keys.

Also I'm not sure which parts of this you used LLMs for, I tried to do a comparison, but since it's prose it didn't show a clean diff.

I did see you added: - php: The minimum PHP version required.
I don't see where that happens for profiles? Am I missing something?

macsim’s picture

Status: Needs work » Needs review

My bad, I just added the documentation for opt_out_install.
Is there another key that needs to be documented?

Unless I'm mistaken, the php key is supported for profiles.
ProfileExtensionList::$defaults sets it to \Drupal::MINIMUM_PHP, and ExtensionList::checkIncompatibility() checks $extension->info['php'] for all extension types including profiles.
That said, it is not documented anywhere else (modules, themes), so we can probably leave it out here too.

nicxvan’s picture

Thanks! Let's keep the php key documented here, I missed that bit, I was looking at the forms.

opt_out_install actually isn't in yet, but we can postpone this issue on #3614401: Allow install profiles to opt out of being installed

We do need keep_profile too: https://www.drupal.org/node/3605597

I think that might be it. I need to read through carefully what you moved, but this is a great start!

charlliequadros’s picture

Hi @macsim,

  1. I reviewed this and noticed that the `opt_out_install` key does not exist on `main` yet. As I understand it, it should probably only be documented after the other issue that introduces this key has been merged.

    I'm not sure what the best way to handle this here would be, but if this change is merged into `main` now, we would be documenting a key that does not yet exist in the codebase.

    I was updating my comment, so I ended up missing the comment above. You can ignore this.

  2. There are also a few other documented keys that are not currently available. You can use the following command to check which keys are missing:

    grep -rhoE "profile(*info|->info)'?]?(['[a-z*]+'])+" core/ \
      --include='*.php' --include='*.inc' \
      | sed "s/.*info'?]?//; s/']['/./g; s/['//; s/']//" \
      | sort -u
    
  3. I also noticed another issue with the examples.

    Both examples currently use:

    core_version_requirement: ^11
    

    However, `main` is currently on `12.0-dev`. Copying either example produces a profile that cannot be installed.

    `InfoParserDynamic` sets `core_incompatible`, the active profile is included in the module list by `ModuleExtensionList`, and `install_install_profile()` eventually reaches the check in `ModuleInstaller`. That check runs before the `$enable_dependencies` branch, so passing `FALSE` does not bypass it.

    Since nothing in the installer catches this incompatibility earlier, it eventually surfaces midway through the batch as a `MissingDependencyException`.

    Changing it to:

    core_version_requirement: ^12
    

    would fix the problem for now, but it would also mean updating the example for every new major version.

    Another option could be to use:

    core_version_requirement: >=11

    This would keep the example valid for Drupal 11, the current 12.0-dev branch, and future major versions without requiring an update each time. InfoParserInterface::parse() already uses >=9 as an example of this approach.

    It might also make sense to keep a single example rather than two, which would reduce the amount of documentation that could become stale over time.

charlliequadros’s picture

Status: Needs review » Needs work
nicxvan’s picture

Thanks!

For 1, yes that is what I was referring to in 7 we can postpone this on the issue I linked. We can also pull the key here and add it in the issue where the feature is added.

For 2 regex is great, I might open follow ups to better document module and theme keys too.

For 3 core_version_requirement I would consider copying what module.api.php says about it, I'm not sure I agree we should only have one example, one is a profile, one is a distribution. Identifying the differences is one of the specific things we want to better document.

macsim’s picture

Thanks for the regex @charlliequadros.
I added documentation for recipes and keep_profile missing keys.

For 3 core_version_requirement I would consider copying what module.api.php says about it

There's actually no example in module.api.php ; the only reference to core_version_requirement is in the hook_update_N documentation:

 * The numbers are normally composed of three parts:
 * - 1 or 2 digits for Drupal core compatibility (Drupal 8, 9, 10, etc.). This
 *   convention must be followed. If your module is compatible with multiple
 *   major versions (e.g., it has a core_version_requirement of '^8.8 || ^9'),
 *   use the lowest major core branch it is compatible with (8 in this example).
 * - 1 or 2 digits for your module's major release version. Examples:
 *   - For 8.x-1.* or 1.y.x (semantic versioning), use 1 or 01.
 *   - For 8.x-2.* or 2.y.x, use 2 or 02.
 *   - For 8.x-10.* or 10.y.x, use 10.
 *   - For core 8.0.x, use 0 or 00.
 *   - For core 8.1.x, use 1 or 01.
 *   - For core 8.10.x, use 10.

I am ok with both the core_version_requirement: ^12 and core_version_requirement: >=11 versions ; even if we choose the first one, it actually doesn't really need to be updated on each major version - that hook_update_N reference is still using a drupal 8 example and the documentation is still understandable.