Validate actions in docs (#31073)
Adds a validation step to docs preprocessing so that actions referenced
in docs are checked against the list of all registered actions in GPUI.
In order for this to work properly, all of the crates that register
actions had to be importable by the `docs_preprocessor` crate and
actually used (see [this
comment](ec16e70336 (diff-2674caf14ae6d70752ea60c7061232393d84e7f61a52915ace089c30a797a1c3)
)
for why this is challenging).
In order to accomplish this I have moved the entry point of zed into a
separate stub file named `zed_main.rs` so that `main.rs` is importable
by the `docs_preprocessor` crate, this is kind of gross, but ensures
that all actions that are registered in the application are registered
when checking them in `docs_preprocessor`. An alternative solution
suggested by @mikayla-maki was to separate out all our `::init()`
functions into a lib entry point in the `zed` crate that can be imported
instead, however, this turned out to be a far bigger refactor and is in
my opinion better to do in a follow up PR with significant testing to
ensure no regressions in behavior occur.
Release Notes:
- N/A
This commit is contained in:
parent
52770cd3ad
commit
17c3b741ec
14 changed files with 216 additions and 48 deletions
|
@ -288,6 +288,18 @@ impl ActionRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
/// Generate a list of all the registered actions.
|
||||
/// Useful for transforming the list of available actions into a
|
||||
/// format suited for static analysis such as in validating keymaps, or
|
||||
/// generating documentation.
|
||||
pub fn generate_list_of_all_registered_actions() -> Vec<MacroActionData> {
|
||||
let mut actions = Vec::new();
|
||||
for builder in inventory::iter::<MacroActionBuilder> {
|
||||
actions.push(builder.0());
|
||||
}
|
||||
actions
|
||||
}
|
||||
|
||||
/// Defines and registers unit structs that can be used as actions.
|
||||
///
|
||||
/// To use more complex data types as actions, use `impl_actions!`
|
||||
|
@ -333,7 +345,6 @@ macro_rules! action_as {
|
|||
::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug, ::std::cmp::PartialEq,
|
||||
)]
|
||||
pub struct $name;
|
||||
|
||||
gpui::__impl_action!(
|
||||
$namespace,
|
||||
$name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue