Conversation
lizlooney
requested changes
Sep 20, 2026
lizlooney
left a comment
Collaborator
There was a problem hiding this comment.
This is really spectacular!
| ## Building | ||
|
|
||
| ```bash | ||
| ./build.sh # builds all of the examples |
Collaborator
There was a problem hiding this comment.
Insert the following:
cd <your repo>/example_libraries
| components/*.json - optional component classes that are added to the components toolbox | ||
| python_data/*.json - optional python modules and classes, in the format of the generated | ||
| robotpy_data.json, that the library's blocks and components use | ||
| samples/<SampleName>/*.json - optional sample projects that are shown with the built in samples |
|
|
||
| Blocks has to know about the Python modules and classes that blocks use, not just the component | ||
| classes. For example, a component method might return an object whose fields can be read, take an | ||
| enum as an argument, or return a subclass of a built in class. Each `*.json` file in |
| `components/`. | ||
| - `aliases` maps type names to the types they are aliases for. | ||
| - `subclasses` maps a class name to the names of its subclasses. Blocks that take the class also | ||
| accept the subclasses, and a library can add subclasses to a built in class. |
| - `subclasses` maps a class name to the names of its subclasses. Blocks that take the class also | ||
| accept the subclasses, and a library can add subclasses to a built in class. | ||
|
|
||
| Python data doesn't add anything to the toolbox by itself, and it isn't shown with the built in |
|
|
||
| """Generates components/ and python_data/ for the REV Robotics library from robotpy-rev. | ||
|
|
||
| This uses python_tools, so run it with the python_tools venv (see python_tools/README.md), with |
Collaborator
There was a problem hiding this comment.
Who are these instructions for? Who needs to "run it"?
Does running these commands generate some files? If so, which ones? Maybe these instructions belong in the README.md file.
|
|
||
|
|
||
| def _writeJson(json_data, file_path: str, indent: int = 4, sort_keys: bool = True): | ||
| with open(file_path, 'w', encoding='utf-8') as json_file: |
Collaborator
There was a problem hiding this comment.
Insert the following code so we know what files are being written.
print(f'INFO: writing file {file_path}',
file=sys.stderr)
| if not_generated_names and add_unused_to_ignore: | ||
| python_toolbox[_KEY_IGNORE] = sorted(ignored_names | set(not_generated_names)) | ||
| _writeJson(python_toolbox, os.path.join(library_directory, _PYTHON_TOOLBOX_FILE), indent=2, | ||
| sort_keys=False) |
Collaborator
There was a problem hiding this comment.
Why aren't the keys sorted?
| if owner is None and name not in generated_enum_names}) - ignored_names) | ||
| if not_generated_names and add_unused_to_ignore: | ||
| python_toolbox[_KEY_IGNORE] = sorted(ignored_names | set(not_generated_names)) | ||
| _writeJson(python_toolbox, os.path.join(library_directory, _PYTHON_TOOLBOX_FILE), indent=2, |
| "rev.ColorSensorV3", | ||
| "rev.ColorSensorV3.RawColor" | ||
| ], | ||
| "ignore": [ |
Collaborator
There was a problem hiding this comment.
I don't really understand the ignore section.
Are these classes that are not applicable to FIRST and/or to Systemcore/Motioncore?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This creates a way for third parties to be able to add components and python libraries into blocks.
Third parties follow the directions in
examples/for creating their own.blocks_libfiles which contain metadata, python wheels, samples, and blockly toolboxes.There is also support for i18n.
Libraries are managed under "Manage... Libraries..."
In order to make sure this could work, this PR also moves all of REV items from being built-in to one of the samples.
Linked Issues
Closes #539
Type of Change
How Has This Been Tested?
Created the four built-in examples which have a variety of options.
Make sure that they show up in components, can be used in blocks, etc.
Checklist