MDL-71096 core: Add meta information about APIs to core
commit28937d424376e5b71e51775921b70221192ee069
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Wed, 19 Oct 2022 09:46:10 +0000 (19 11:46 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Fri, 9 Dec 2022 09:49:12 +0000 (9 10:49 +0100)
tree597b5c97146174c803e0e648fa8f0478ce56c080
parent40a89d8a9aa8ef25ea1de560df02a3df38951651
MDL-71096 core: Add meta information about APIs to core

Right now we have the information only in docs:
  - https://docs.moodle.org/dev/Core_APIs
  - https://moodledev.io/docs/apis

And, in fact, we are crawling those pages to get the information
from various tools (moodlecheck, CiBoT...). Obviously, that's far
from ideal, the source only has the current list of APIs, and
there isn't much information there but the names.

So we are moving the source of information to be in core, so it
can be modified between branches, and contains richer information:
 - The component the API belongs to, usually a subsystem or core.
 - If the API can be used as level 2 namespace.
 - If the API can be used as level 2 namespace out from its component.

Note that all that information has NO USES right now in core (and maybe
never will), but tools/checkers will benefit enormously by having that
information at hand, so we can check for namespaces, categories and
other bits way better.

Also, once we have this, the APIs dev documents linked above, surely
can be improved by being automatically generated and include all the
meta-information available.

It also includes a very basic json schema validating the basis. It can
be tried online @ https://www.jsonschemavalidator.net , or any other
tool. PHP requires extra libraries to be able to perform the validation.

Covered with unit tests, both api-related functions and structure validation.
lib/apis.json [new file with mode: 0644]
lib/apis.schema.json [new file with mode: 0644]
lib/classes/component.php
lib/tests/component_test.php
version.php