@@ -56,73 +56,6 @@ fn normalize_command_match_patterns(steps: &mut [Step]) {
5656 }
5757}
5858
59- /// Produces a list of (command, description) pairs for command steps.
60- ///
61- /// Scans the provided steps for those whose `step_type` is `StepType::Command`,
62- /// selects a command string from `input` if present or `match_pattern` otherwise
63- /// (ignoring empty/whitespace values), and pairs it with a short description
64- /// (using `short_description`, falling back to `description`, or a sensible
65- /// default when both are empty).
66- ///
67- /// # Parameters
68- ///
69- /// - `steps`: Slice of steps to extract command guide entries from.
70- ///
71- /// # Returns
72- ///
73- /// A vector of `(command, description)` tuples for each command step with a
74- /// non-empty command string.
75- ///
76- /// # Examples
77- ///
78- /// ```rust,no_run
79- /// // Construct demo steps and produce guide entries.
80- /// // Assume `Step` and `StepType` are available in scope.
81- /// let steps = vec![
82- /// Step {
83- /// step_type: StepType::Command,
84- /// input: Some("echo hello".to_string()),
85- /// match_pattern: None,
86- /// short_description: Some("Greet".to_string()),
87- /// description: None,
88- /// ..Default::default()
89- /// },
90- /// Step {
91- /// step_type: StepType::Command,
92- /// input: None,
93- /// match_pattern: Some("ls -la".to_string()),
94- /// short_description: None,
95- /// description: Some("List files".to_string()),
96- /// ..Default::default()
97- /// },
98- /// ];
99- ///
100- /// let entries = command_guide_entries(&steps);
101- /// assert_eq!(entries.len(), 2);
102- /// ```
103- fn command_guide_entries ( steps : & [ Step ] ) -> Vec < ( String , String ) > {
104- steps
105- . iter ( )
106- . filter ( |step| matches ! ( step. step_type, StepType :: Command ) )
107- . filter_map ( |step| {
108- let command = step
109- . input
110- . clone ( )
111- . or_else ( || step. match_pattern . clone ( ) )
112- . filter ( |v| !v. trim ( ) . is_empty ( ) ) ?;
113-
114- let description = step
115- . short_description
116- . clone ( )
117- . or_else ( || step. description . clone ( ) )
118- . filter ( |v| !v. trim ( ) . is_empty ( ) )
119- . unwrap_or_else ( || "Run this command in the terminal preview." . to_string ( ) ) ;
120-
121- Some ( ( command, description) )
122- } )
123- . collect ( )
124- }
125-
12659/// Constructs a namespaced demo path using router params, the demo ID, and an optional suffix.
12760
12861///
0 commit comments