on master help sign in
Use 'todo' instead of 'TODO' for comments in TodoMVC
320d7d9Nick Fitzgerald
examples/todomvc/src/controller.rs+1−1
@@ -15,7 +15,7 @@ use std::ops::{Deref, DerefMut};
15///
15///
16/// One could imagine alternative controller implementations with `*Actions`
16/// One could imagine alternative controller implementations with `*Actions`
17/// trait implementations for (e.g.) testing that will assert various expected
17/// trait implementations for (e.g.) testing that will assert various expected
18−/// action methods are called after rendering TODO items and sending DOM events.
18+/// action methods are called after rendering todo items and sending DOM events.
19#[derive(Default, Deserialize, Serialize)]
19#[derive(Default, Deserialize, Serialize)]
20pub struct Controller;
20pub struct Controller;
21
21
examples/todomvc/src/lib.rs+1−1
@@ -24,7 +24,7 @@ pub fn run() -> Result<(), JsValue> {
24 // Set up the logging for debugging if/when things go wrong.
24 // Set up the logging for debugging if/when things go wrong.
25 init_logging();
25 init_logging();
26
26
27− // Grab the TODO app container.
27+ // Grab the todo app container.
28 let document = utils::document();
28 let document = utils::document();
29 let container = document
29 let container = document
30 .query_selector(".todoapp")?
30 .query_selector(".todoapp")?
examples/todomvc/src/router.rs+1−1
@@ -12,7 +12,7 @@ use wasm_bindgen::JsCast;
12/// Start the router.
12/// Start the router.
13pub fn start(vdom: VdomWeak) {
13pub fn start(vdom: VdomWeak) {
14 // Callback fired whenever the URL's hash fragment changes. Keeps the root
14 // Callback fired whenever the URL's hash fragment changes. Keeps the root
15− // TODOs collection's visibility in sync with the `#` fragment.
15+ // todos collection's visibility in sync with the `#` fragment.
16 let on_hash_change = move || {
16 let on_hash_change = move || {
17 let new_vis = utils::hash()
17 let new_vis = utils::hash()
18 .and_then(|hash| {
18 .and_then(|hash| {
examples/todomvc/src/todo.rs+14−14
@@ -1,4 +1,4 @@
1−//! Type definition and `dodrio::Render` implementation for a single TODO item.
1+//! Type definition and `dodrio::Render` implementation for a single todo item.
2
2
3use crate::keys;
3use crate::keys;
4use dodrio::{bumpalo::Bump, on, Attribute, Node, Render, RootRender, VdomWeak};
4use dodrio::{bumpalo::Bump, on, Attribute, Node, Render, RootRender, VdomWeak};
@@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
6use std::marker::PhantomData;
6use std::marker::PhantomData;
7use wasm_bindgen::{prelude::*, JsCast};
7use wasm_bindgen::{prelude::*, JsCast};
8
8
9−/// A single TODO item.
9+/// A single todo item.
10#[derive(Serialize, Deserialize)]
10#[derive(Serialize, Deserialize)]
11pub struct Todo<C> {
11pub struct Todo<C> {
12 id: usize,
12 id: usize,
@@ -20,24 +20,24 @@ pub struct Todo<C> {
20 _controller: PhantomData<C>,
20 _controller: PhantomData<C>,
21}
21}
22
22
23−/// Actions on a single TODO item that can be triggered from the UI.
23+/// Actions on a single todo item that can be triggered from the UI.
24pub trait TodoActions {
24pub trait TodoActions {
25− /// Toggle the completion state of the TODO item with the given id.
25+ /// Toggle the completion state of the todo item with the given id.
26 fn toggle_completed(root: &mut dyn RootRender, vdom: VdomWeak, id: usize);
26 fn toggle_completed(root: &mut dyn RootRender, vdom: VdomWeak, id: usize);
27
27
28− /// Delete the TODO item with the given id.
28+ /// Delete the todo item with the given id.
29 fn delete(root: &mut dyn RootRender, vdom: VdomWeak, id: usize);
29 fn delete(root: &mut dyn RootRender, vdom: VdomWeak, id: usize);
30
30
31− /// Begin editing the TODO item with the given id.
31+ /// Begin editing the todo item with the given id.
32 fn begin_editing(root: &mut dyn RootRender, vdom: VdomWeak, id: usize);
32 fn begin_editing(root: &mut dyn RootRender, vdom: VdomWeak, id: usize);
33
33
34− /// Update the edits for the TODO with the given id.
34+ /// Update the edits for the todo with the given id.
35 fn update_edits(root: &mut dyn RootRender, vdom: VdomWeak, id: usize, edits: String);
35 fn update_edits(root: &mut dyn RootRender, vdom: VdomWeak, id: usize, edits: String);
36
36
37− /// Finish editing the TODO with the given id.
37+ /// Finish editing the todo with the given id.
38 fn finish_edits(root: &mut dyn RootRender, vdom: VdomWeak, id: usize);
38 fn finish_edits(root: &mut dyn RootRender, vdom: VdomWeak, id: usize);
39
39
40− /// Cancel editing the TODO with the given id.
40+ /// Cancel editing the todo with the given id.
41 fn cancel_edits(root: &mut dyn RootRender, vdom: VdomWeak, id: usize);
41 fn cancel_edits(root: &mut dyn RootRender, vdom: VdomWeak, id: usize);
42}
42}
43
43
@@ -56,7 +56,7 @@ impl<C> Todo<C> {
56 }
56 }
57 }
57 }
58
58
59− /// Set this TODO item's id.
59+ /// Set this todo item's id.
60 pub fn set_id(&mut self, id: usize) {
60 pub fn set_id(&mut self, id: usize) {
61 self.id = id;
61 self.id = id;
62 }
62 }
@@ -71,22 +71,22 @@ impl<C> Todo<C> {
71 self.completed = to;
71 self.completed = to;
72 }
72 }
73
73
74− /// Get this TODO's title.
74+ /// Get this todo's title.
75 pub fn title(&self) -> &str {
75 pub fn title(&self) -> &str {
76 &self.title
76 &self.title
77 }
77 }
78
78
79− /// Set this TODO item's title.
79+ /// Set this todo item's title.
80 pub fn set_title<S: Into<String>>(&mut self, title: S) {
80 pub fn set_title<S: Into<String>>(&mut self, title: S) {
81 self.title = title.into();
81 self.title = title.into();
82 }
82 }
83
83
84− /// Set the edits for this TODO.
84+ /// Set the edits for this todo.
85 pub fn set_edits<S: Into<String>>(&mut self, edits: Option<S>) {
85 pub fn set_edits<S: Into<String>>(&mut self, edits: Option<S>) {
86 self.edits = edits.map(Into::into);
86 self.edits = edits.map(Into::into);
87 }
87 }
88
88
89− /// Take this TODO's edits, leaving `None` in their place.
89+ /// Take this todo's edits, leaving `None` in their place.
90 pub fn take_edits(&mut self) -> Option<String> {
90 pub fn take_edits(&mut self) -> Option<String> {
91 self.edits.take()
91 self.edits.take()
92 }
92 }
examples/todomvc/src/todos.rs+20−20
@@ -1,5 +1,5 @@
1//! Type definitions and `dodrio::Render` implementation for a collection of
1//! Type definitions and `dodrio::Render` implementation for a collection of
2−//! TODO items.
2+//! todo items.
3
3
4use crate::controller::Controller;
4use crate::controller::Controller;
5use crate::todo::{Todo, TodoActions};
5use crate::todo::{Todo, TodoActions};
@@ -15,7 +15,7 @@ use std::mem;
15use wasm_bindgen::prelude::*;
15use wasm_bindgen::prelude::*;
16use wasm_bindgen::JsCast;
16use wasm_bindgen::JsCast;
17
17
18−/// A collection of TODOs.
18+/// A collection of todos.
19#[derive(Default, Serialize, Deserialize)]
19#[derive(Default, Serialize, Deserialize)]
20#[serde(rename = "todos-dodrio", bound = "")]
20#[serde(rename = "todos-dodrio", bound = "")]
21pub struct Todos<C = Controller> {
21pub struct Todos<C = Controller> {
@@ -33,25 +33,25 @@ pub struct Todos<C = Controller> {
33
33
34/// Actions for `Todos` that can be triggered by UI interactions.
34/// Actions for `Todos` that can be triggered by UI interactions.
35pub trait TodosActions: TodoActions {
35pub trait TodosActions: TodoActions {
36− /// Toggle the completion state of all TODO items.
36+ /// Toggle the completion state of all todo items.
37 fn toggle_all(root: &mut dyn RootRender, vdom: VdomWeak);
37 fn toggle_all(root: &mut dyn RootRender, vdom: VdomWeak);
38
38
39− /// Update the draft TODO item's text.
39+ /// Update the draft todo item's text.
40 fn update_draft(root: &mut dyn RootRender, vdom: VdomWeak, draft: String);
40 fn update_draft(root: &mut dyn RootRender, vdom: VdomWeak, draft: String);
41
41
42− /// Finish the current draft TODO item and add it to the collection of
42+ /// Finish the current draft todo item and add it to the collection of
43− /// TODOs.
43+ /// todos.
44 fn finish_draft(root: &mut dyn RootRender, vdom: VdomWeak);
44 fn finish_draft(root: &mut dyn RootRender, vdom: VdomWeak);
45
45
46− /// Change the TODO item visibility filtering to the given `Visibility`.
46+ /// Change the todo item visibility filtering to the given `Visibility`.
47 fn change_visibility(root: &mut dyn RootRender, vdom: VdomWeak, vis: Visibility);
47 fn change_visibility(root: &mut dyn RootRender, vdom: VdomWeak, vis: Visibility);
48
48
49− /// Delete all completed TODO items.
49+ /// Delete all completed todo items.
50 fn delete_completed(root: &mut dyn RootRender, vdom: VdomWeak);
50 fn delete_completed(root: &mut dyn RootRender, vdom: VdomWeak);
51}
51}
52
52
53impl<C> Todos<C> {
53impl<C> Todos<C> {
54− /// Construct a new TODOs set.
54+ /// Construct a new todos set.
55 ///
55 ///
56 /// If an existing set is available in local storage, then us that,
56 /// If an existing set is available in local storage, then us that,
57 /// otherwise create a new set.
57 /// otherwise create a new set.
@@ -62,7 +62,7 @@ impl<C> Todos<C> {
62 Self::from_local_storage().unwrap_or_default()
62 Self::from_local_storage().unwrap_or_default()
63 }
63 }
64
64
65− /// Deserialize a set of TODOs from local storage.
65+ /// Deserialize a set of todos from local storage.
66 pub fn from_local_storage() -> Option<Self> {
66 pub fn from_local_storage() -> Option<Self> {
67 utils::local_storage()
67 utils::local_storage()
68 .get("todomvc-dodrio")
68 .get("todomvc-dodrio")
@@ -71,7 +71,7 @@ impl<C> Todos<C> {
71 .and_then(|json| serde_json::from_str(&json).ok())
71 .and_then(|json| serde_json::from_str(&json).ok())
72 }
72 }
73
73
74− /// Serialize this set of TODOs to local storage.
74+ /// Serialize this set of todos to local storage.
75 pub fn save_to_local_storage(&self) {
75 pub fn save_to_local_storage(&self) {
76 let serialized = serde_json::to_string(self).unwrap_throw();
76 let serialized = serde_json::to_string(self).unwrap_throw();
77 utils::local_storage()
77 utils::local_storage()
@@ -79,41 +79,41 @@ impl<C> Todos<C> {
79 .unwrap_throw();
79 .unwrap_throw();
80 }
80 }
81
81
82− /// Add a new TODO item to this collection.
82+ /// Add a new todo item to this collection.
83 pub fn add_todo(&mut self, todo: Todo<C>) {
83 pub fn add_todo(&mut self, todo: Todo<C>) {
84 self.todos.push(todo);
84 self.todos.push(todo);
85 }
85 }
86
86
87− /// Delete the TODO with the given id.
87+ /// Delete the todo with the given id.
88 pub fn delete_todo(&mut self, id: usize) {
88 pub fn delete_todo(&mut self, id: usize) {
89 self.todos.remove(id);
89 self.todos.remove(id);
90 self.fix_ids();
90 self.fix_ids();
91 }
91 }
92
92
93− /// Delete all completed TODO items.
93+ /// Delete all completed todo items.
94 pub fn delete_completed(&mut self) {
94 pub fn delete_completed(&mut self) {
95 self.todos.retain(|t| !t.is_complete());
95 self.todos.retain(|t| !t.is_complete());
96 self.fix_ids();
96 self.fix_ids();
97 }
97 }
98
98
99− // Fix all TODO identifiers so that they match their index once again.
99+ // Fix all todo identifiers so that they match their index once again.
100 fn fix_ids(&mut self) {
100 fn fix_ids(&mut self) {
101 for (id, todo) in self.todos.iter_mut().enumerate() {
101 for (id, todo) in self.todos.iter_mut().enumerate() {
102 todo.set_id(id);
102 todo.set_id(id);
103 }
103 }
104 }
104 }
105
105
106− /// Get a shared slice of the underlying set of TODO items.
106+ /// Get a shared slice of the underlying set of todo items.
107 pub fn todos(&self) -> &[Todo<C>] {
107 pub fn todos(&self) -> &[Todo<C>] {
108 &self.todos
108 &self.todos
109 }
109 }
110
110
111− /// Get an exclusive slice of the underlying set of TODO items.
111+ /// Get an exclusive slice of the underlying set of todo items.
112 pub fn todos_mut(&mut self) -> &mut [Todo<C>] {
112 pub fn todos_mut(&mut self) -> &mut [Todo<C>] {
113 &mut self.todos
113 &mut self.todos
114 }
114 }
115
115
116− /// Set the draft TODO item text.
116+ /// Set the draft todo item text.
117 pub fn set_draft<S: Into<String>>(&mut self, draft: S) {
117 pub fn set_draft<S: Into<String>>(&mut self, draft: S) {
118 self.draft = draft.into();
118 self.draft = draft.into();
119 }
119 }
@@ -123,12 +123,12 @@ impl<C> Todos<C> {
123 mem::replace(&mut self.draft, String::new())
123 mem::replace(&mut self.draft, String::new())
124 }
124 }
125
125
126− /// Get the current visibility for these TODOs.
126+ /// Get the current visibility for these todos.
127 pub fn visibility(&self) -> Visibility {
127 pub fn visibility(&self) -> Visibility {
128 self.visibility
128 self.visibility
129 }
129 }
130
130
131− /// Set the visibility for these TODOS.
131+ /// Set the visibility for these todoS.
132 pub fn set_visibility(&mut self, vis: Visibility) {
132 pub fn set_visibility(&mut self, vis: Visibility) {
133 self.visibility = vis;
133 self.visibility = vis;
134 }
134 }
examples/todomvc/src/visibility.rs+4−4
@@ -3,14 +3,14 @@
3use std::fmt;
3use std::fmt;
4use std::str::FromStr;
4use std::str::FromStr;
5
5
6−/// The visibility filtering for TODO items.
6+/// The visibility filtering for todo items.
7#[derive(Clone, Copy, Eq, PartialEq)]
7#[derive(Clone, Copy, Eq, PartialEq)]
8pub enum Visibility {
8pub enum Visibility {
9− /// Show all TODOs.
9+ /// Show all todos.
10 All,
10 All,
11− /// Show only active, incomplete TODOs.
11+ /// Show only active, incomplete todos.
12 Active,
12 Active,
13− /// Show only inactive, completed TODOs.
13+ /// Show only inactive, completed todos.
14 Completed,
14 Completed,
15}
15}
16
16