
This just adds the description processing for the top level function comment, support for parameter and return descriptions will come in a followup change. Note: Also adds a catch into the code for extracting comments from the IDL files to make it clear when the parser has not provided the proper line number for a node type when trying to extract a comment from it. Bug: 340297705 Change-Id: I44046d519e97b3a17142e79aabdec02cdbd9c224 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6237564 Commit-Queue: Tim <tjudkins@chromium.org> Reviewed-by: Devlin Cronin <rdevlin.cronin@chromium.org> Cr-Commit-Position: refs/heads/main@{#1416930}
The JSON Schema Compiler is used by the chrome extensions system to generate various necessary files from the "schemas" in extensions. These include the C++ type representations for API types, string blobs for the files, feature availability information, and more. You can read more about these in our documentation on schemas and features.
Note that, despite its name, the JSON Schema Compiler does not just handle JSON files -- it also handles files written in IDL syntax.
The main entry point for generation is compiler.py
, which then uses different
"compilers" and "generators" to produce necessary types and files. These are
used in gn actions in various files in the codebase, such as those in
//chrome/common/extensions/api/ and //extensions/common/api.
The loading of the schema files by compiler.py
differs slightly between JSON
schema files and IDL schema files
. For JSON schemas we first strip
the "//" style comments from the JSON file and then parse the rest using
standard python libraries. The resulting python object is then sent to the
"compilers" and "generators". For IDL schemas the process is a bit more
complicated. First we load the schema file with an IDL parser, which returns an
AST (Abstract Syntax Tree) that represents the contents of the file. This AST is
then passed to a "processor" that creates a python object based on it, mimicking
the same structure as the output from JSON schema loading. The resulting python
object is then passed to the "compilers" and "generators", just like the JSON
schema path.
NOTE: Currently we use an old IDL parser, which means that the current format of our IDL files is not up to date with modern WebIDL. However https://crbug.com/340297705 is working on fixing that, by integrating the Blink maintained WebIDL parser and creating a new "processor" to transform the output to the format we expect.
For any questions, reach out to the OWNERS.