gpui: Store action documentation (#33809)

Closes #ISSUE

Adds a new `documentation` method to actions, that is extracted from doc
comments when using the `actions!` or derive macros.

Additionally, this PR adds doc comments to as many action definitions in
Zed as possible.

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Ben Kunkle 2025-07-02 20:14:33 -05:00 committed by GitHub
parent def8bab5a8
commit 6cd4dbdea1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
96 changed files with 1467 additions and 78 deletions

View file

@ -11,6 +11,7 @@ use serde::{Deserialize, Serialize};
// https://github.com/mmastrac/rust-ctor/issues/280
pub fn init() {}
/// Opens a URL in the system's default web browser.
#[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
#[action(namespace = zed)]
#[serde(deny_unknown_fields)]
@ -18,6 +19,7 @@ pub struct OpenBrowser {
pub url: String,
}
/// Opens a zed:// URL within the application.
#[derive(Clone, PartialEq, Deserialize, JsonSchema, Action)]
#[action(namespace = zed)]
#[serde(deny_unknown_fields)]
@ -28,15 +30,25 @@ pub struct OpenZedUrl {
actions!(
zed,
[
/// Opens the settings editor.
OpenSettings,
/// Opens the default keymap file.
OpenDefaultKeymap,
/// Opens account settings.
OpenAccountSettings,
/// Opens server settings.
OpenServerSettings,
/// Quits the application.
Quit,
/// Opens the user keymap file.
OpenKeymap,
/// Shows information about Zed.
About,
/// Opens the documentation website.
OpenDocs,
/// Views open source licenses.
OpenLicenses,
/// Opens the telemetry log.
OpenTelemetryLog,
]
);
@ -56,6 +68,7 @@ pub enum ExtensionCategoryFilter {
DebugAdapters,
}
/// Opens the extensions management interface.
#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
#[action(namespace = zed)]
#[serde(deny_unknown_fields)]
@ -65,6 +78,7 @@ pub struct Extensions {
pub category_filter: Option<ExtensionCategoryFilter>,
}
/// Decreases the font size in the editor buffer.
#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
#[action(namespace = zed)]
#[serde(deny_unknown_fields)]
@ -73,6 +87,7 @@ pub struct DecreaseBufferFontSize {
pub persist: bool,
}
/// Increases the font size in the editor buffer.
#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
#[action(namespace = zed)]
#[serde(deny_unknown_fields)]
@ -81,6 +96,7 @@ pub struct IncreaseBufferFontSize {
pub persist: bool,
}
/// Resets the buffer font size to the default value.
#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
#[action(namespace = zed)]
#[serde(deny_unknown_fields)]
@ -89,6 +105,7 @@ pub struct ResetBufferFontSize {
pub persist: bool,
}
/// Decreases the font size of the user interface.
#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
#[action(namespace = zed)]
#[serde(deny_unknown_fields)]
@ -97,6 +114,7 @@ pub struct DecreaseUiFontSize {
pub persist: bool,
}
/// Increases the font size of the user interface.
#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
#[action(namespace = zed)]
#[serde(deny_unknown_fields)]
@ -105,6 +123,7 @@ pub struct IncreaseUiFontSize {
pub persist: bool,
}
/// Resets the UI font size to the default value.
#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
#[action(namespace = zed)]
#[serde(deny_unknown_fields)]
@ -116,7 +135,13 @@ pub struct ResetUiFontSize {
pub mod dev {
use gpui::actions;
actions!(dev, [ToggleInspector]);
actions!(
dev,
[
/// Toggles the developer inspector for debugging UI elements.
ToggleInspector
]
);
}
pub mod workspace {
@ -139,9 +164,13 @@ pub mod git {
actions!(
git,
[
/// Checks out a different git branch.
CheckoutBranch,
/// Switches to a different git branch.
Switch,
/// Selects a different repository.
SelectRepo,
/// Opens the git branch selector.
#[action(deprecated_aliases = ["branches::OpenRecent"])]
Branch
]
@ -151,25 +180,51 @@ pub mod git {
pub mod jj {
use gpui::actions;
actions!(jj, [BookmarkList]);
actions!(
jj,
[
/// Opens the Jujutsu bookmark list.
BookmarkList
]
);
}
pub mod toast {
use gpui::actions;
actions!(toast, [RunAction]);
actions!(
toast,
[
/// Runs the action associated with a toast notification.
RunAction
]
);
}
pub mod command_palette {
use gpui::actions;
actions!(command_palette, [Toggle]);
actions!(
command_palette,
[
/// Toggles the command palette.
Toggle
]
);
}
pub mod feedback {
use gpui::actions;
actions!(feedback, [FileBugReport, GiveFeedback]);
actions!(
feedback,
[
/// Opens the bug report form.
FileBugReport,
/// Opens the feedback form.
GiveFeedback
]
);
}
pub mod theme_selector {
@ -177,6 +232,7 @@ pub mod theme_selector {
use schemars::JsonSchema;
use serde::Deserialize;
/// Toggles the theme selector interface.
#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
#[action(namespace = theme_selector)]
#[serde(deny_unknown_fields)]
@ -191,6 +247,7 @@ pub mod icon_theme_selector {
use schemars::JsonSchema;
use serde::Deserialize;
/// Toggles the icon theme selector interface.
#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
#[action(namespace = icon_theme_selector)]
#[serde(deny_unknown_fields)]
@ -205,7 +262,14 @@ pub mod agent {
actions!(
agent,
[OpenConfiguration, OpenOnboardingModal, ResetOnboarding]
[
/// Opens the agent configuration panel.
OpenConfiguration,
/// Opens the agent onboarding modal.
OpenOnboardingModal,
/// Resets the agent onboarding state.
ResetOnboarding
]
);
}
@ -223,8 +287,15 @@ pub mod assistant {
]
);
actions!(assistant, [ShowConfiguration]);
actions!(
assistant,
[
/// Shows the assistant configuration panel.
ShowConfiguration
]
);
/// Opens the rules library for managing agent rules and prompts.
#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)]
#[action(namespace = agent, deprecated_aliases = ["assistant::OpenRulesLibrary", "assistant::DeployPromptLibrary"])]
#[serde(deny_unknown_fields)]
@ -233,6 +304,7 @@ pub mod assistant {
pub prompt_to_select: Option<Uuid>,
}
/// Deploys the assistant interface with the specified configuration.
#[derive(Clone, Default, Deserialize, PartialEq, JsonSchema, Action)]
#[action(namespace = assistant)]
#[serde(deny_unknown_fields)]
@ -244,9 +316,18 @@ pub mod assistant {
pub mod debugger {
use gpui::actions;
actions!(debugger, [OpenOnboardingModal, ResetOnboarding]);
actions!(
debugger,
[
/// Opens the debugger onboarding modal.
OpenOnboardingModal,
/// Resets the debugger onboarding state.
ResetOnboarding
]
);
}
/// Opens the recent projects interface.
#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
#[action(namespace = projects)]
#[serde(deny_unknown_fields)]
@ -255,6 +336,7 @@ pub struct OpenRecent {
pub create_new_window: bool,
}
/// Creates a project from a selected template.
#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
#[action(namespace = projects)]
#[serde(deny_unknown_fields)]
@ -276,7 +358,7 @@ pub enum RevealTarget {
Dock,
}
/// Spawn a task with name or open tasks modal.
/// Spawns a task with name or opens tasks modal.
#[derive(Debug, PartialEq, Clone, Deserialize, JsonSchema, Action)]
#[action(namespace = task)]
#[serde(untagged)]
@ -309,7 +391,7 @@ impl Spawn {
}
}
/// Rerun the last task.
/// Reruns the last task.
#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)]
#[action(namespace = task)]
#[serde(deny_unknown_fields)]
@ -350,15 +432,36 @@ pub mod outline {
pub static TOGGLE_OUTLINE: OnceLock<fn(AnyView, &mut Window, &mut App)> = OnceLock::new();
}
actions!(zed_predict_onboarding, [OpenZedPredictOnboarding]);
actions!(git_onboarding, [OpenGitIntegrationOnboarding]);
actions!(
zed_predict_onboarding,
[
/// Opens the Zed Predict onboarding modal.
OpenZedPredictOnboarding
]
);
actions!(
git_onboarding,
[
/// Opens the git integration onboarding modal.
OpenGitIntegrationOnboarding
]
);
actions!(debug_panel, [ToggleFocus]);
actions!(
debug_panel,
[
/// Toggles focus on the debug panel.
ToggleFocus
]
);
actions!(
debugger,
[
/// Toggles the enabled state of a breakpoint.
ToggleEnableBreakpoint,
/// Removes a breakpoint.
UnsetBreakpoint,
/// Opens the project debug tasks configuration.
OpenProjectDebugTasks,
]
);