+66 -50 +/-9 browse
1 | diff --git a/.cargo/config b/.cargo/config |
2 | new file mode 100644 |
3 | index 0000000..b2c9bde |
4 | --- /dev/null |
5 | +++ b/.cargo/config |
6 | @@ -0,0 +1,2 @@ |
7 | + [doc.extern-map.registries] |
8 | + crates-io = "https://docs.rs/" |
9 | diff --git a/.github/workflows/rustdoc.yml b/.github/workflows/rustdoc.yml |
10 | index d52d860..8ea5781 100644 |
11 | --- a/.github/workflows/rustdoc.yml |
12 | +++ b/.github/workflows/rustdoc.yml |
13 | @@ -30,7 +30,7 @@ jobs: |
14 | override: true |
15 | - name: Make rustdocs |
16 | run: | |
17 | - make rustdoc |
18 | + make rustdoc-nightly || make rustdoc |
19 | rm -rf docs |
20 | ls -R |
21 | mv target/doc docs |
22 | diff --git a/Cargo.toml b/Cargo.toml |
23 | index 5632c20..ebf396f 100644 |
24 | --- a/Cargo.toml |
25 | +++ b/Cargo.toml |
26 | @@ -1,4 +1,5 @@ |
27 | [workspace] |
28 | + resolver = "2" |
29 | members = [ |
30 | "archive-http", |
31 | "cli", |
32 | diff --git a/Makefile b/Makefile |
33 | index b58141c..fdc5415 100644 |
34 | --- a/Makefile |
35 | +++ b/Makefile |
36 | @@ -36,3 +36,11 @@ rustdoc: |
37 | .PHONY: rustdoc-open |
38 | rustdoc-open: |
39 | @RUSTDOCFLAGS="--html-before-content ./.github/doc_extra.html" $(CARGOBIN) doc --workspace --all-features --no-deps --document-private-items --open |
40 | + |
41 | + .PHONY: rustdoc-nightly |
42 | + rustdoc-nightly: |
43 | + @RUSTDOCFLAGS="--html-before-content ./.github/doc_extra.html" $(CARGOBIN) +nightly doc -Zrustdoc-map -Z rustdoc-scrape-examples --workspace --all-features --no-deps --document-private-items |
44 | + |
45 | + .PHONY: rustdoc-nightly-open |
46 | + rustdoc-nightly-open: |
47 | + @RUSTDOCFLAGS="--html-before-content ./.github/doc_extra.html" $(CARGOBIN) +nightly doc -Zrustdoc-map -Z rustdoc-scrape-examples --workspace --all-features --no-deps --document-private-items --open |
48 | diff --git a/cli/Cargo.toml b/cli/Cargo.toml |
49 | index 49224df..c87d354 100644 |
50 | --- a/cli/Cargo.toml |
51 | +++ b/cli/Cargo.toml |
52 | @@ -14,10 +14,11 @@ default-run = "mpot" |
53 | [[bin]] |
54 | name = "mpot" |
55 | path = "src/main.rs" |
56 | + doc-scrape-examples = true |
57 | |
58 | [dependencies] |
59 | base64 = { version = "0.21" } |
60 | - clap = { version = "^4.2", default-features = false, features = ["derive", "cargo", "unicode", "help", "usage", "error-context", "suggestions"] } |
61 | + clap = { version = "^4.2", default-features = false, features = ["std", "derive", "cargo", "unicode", "help", "usage", "error-context", "suggestions"] } |
62 | log = "0.4" |
63 | mailpot = { version = "^0.1", path = "../core" } |
64 | serde = { version = "^1", features = ["derive", ] } |
65 | @@ -32,7 +33,7 @@ predicates = "3" |
66 | tempfile = "3.3" |
67 | |
68 | [build-dependencies] |
69 | - clap = { version = "^4.2", default-features = false, features = ["derive", "cargo", "unicode", "wrap_help", "help", "usage", "error-context", "suggestions"] } |
70 | + clap = { version = "^4.2", default-features = false, features = ["std", "derive", "cargo", "unicode", "wrap_help", "help", "usage", "error-context", "suggestions"] } |
71 | clap_mangen = "0.2.10" |
72 | mailpot = { version = "^0.1", path = "../core" } |
73 | stderrlog = "^0.5" |
74 | diff --git a/core/Cargo.toml b/core/Cargo.toml |
75 | index 6d9911d..4a598b5 100644 |
76 | --- a/core/Cargo.toml |
77 | +++ b/core/Cargo.toml |
78 | @@ -10,6 +10,9 @@ repository = "https://github.com/meli/mailpot" |
79 | keywords = ["mail", "mailing-lists"] |
80 | categories = ["email"] |
81 | |
82 | + [lib] |
83 | + doc-scrape-examples = true |
84 | + |
85 | [dependencies] |
86 | anyhow = "1.0.58" |
87 | chrono = { version = "^0.4", features = ["serde", ] } |
88 | diff --git a/core/src/message_filters/settings.rs b/core/src/message_filters/settings.rs |
89 | index b28be1b..bda6c09 100644 |
90 | --- a/core/src/message_filters/settings.rs |
91 | +++ b/core/src/message_filters/settings.rs |
92 | @@ -19,7 +19,7 @@ |
93 | |
94 | //! Named templates, for generated e-mail like confirmations, alerts etc. |
95 | //! |
96 | - //! Template database model: [`Template`]. |
97 | + //! Template database model: [`Template`](crate::Template). |
98 | |
99 | use std::collections::HashMap; |
100 | |
101 | diff --git a/core/src/policies.rs b/core/src/policies.rs |
102 | index 12e2df3..259c796 100644 |
103 | --- a/core/src/policies.rs |
104 | +++ b/core/src/policies.rs |
105 | @@ -61,10 +61,12 @@ mod post_policy { |
106 | |
107 | /// Remove an existing list policy. |
108 | /// |
109 | + /// # Examples |
110 | + /// |
111 | /// ``` |
112 | /// # use mailpot::{models::*, Configuration, Connection, SendMail}; |
113 | /// # use tempfile::TempDir; |
114 | - /// |
115 | + /// # |
116 | /// # let tmp_dir = TempDir::new().unwrap(); |
117 | /// # let db_path = tmp_dir.path().join("mpot.db"); |
118 | /// # let config = Configuration { |
119 | @@ -73,7 +75,7 @@ mod post_policy { |
120 | /// # data_path: tmp_dir.path().to_path_buf(), |
121 | /// # administrators: vec![], |
122 | /// # }; |
123 | - /// |
124 | + /// # |
125 | /// # fn do_test(config: Configuration) { |
126 | /// let db = Connection::open_or_create_db(config).unwrap().trusted(); |
127 | /// # assert!(db.list_post_policy(1).unwrap().is_none()); |
128 | @@ -107,27 +109,11 @@ mod post_policy { |
129 | /// # } |
130 | /// # do_test(config); |
131 | /// ``` |
132 | - pub fn remove_list_post_policy(&self, list_pk: i64, policy_pk: i64) -> Result<()> { |
133 | - let mut stmt = self |
134 | - .connection |
135 | - .prepare("DELETE FROM post_policy WHERE pk = ? AND list = ? RETURNING *;")?; |
136 | - stmt.query_row(rusqlite::params![&policy_pk, &list_pk,], |_| Ok(())) |
137 | - .map_err(|err| { |
138 | - if matches!(err, rusqlite::Error::QueryReturnedNoRows) { |
139 | - Error::from(err).chain_err(|| NotFound("list or list policy not found!")) |
140 | - } else { |
141 | - err.into() |
142 | - } |
143 | - })?; |
144 | - |
145 | - trace!("remove_list_post_policy {} {}.", list_pk, policy_pk); |
146 | - Ok(()) |
147 | - } |
148 | - |
149 | + /// |
150 | /// ```should_panic |
151 | /// # use mailpot::{models::*, Configuration, Connection, SendMail}; |
152 | /// # use tempfile::TempDir; |
153 | - /// |
154 | + /// # |
155 | /// # let tmp_dir = TempDir::new().unwrap(); |
156 | /// # let db_path = tmp_dir.path().join("mpot.db"); |
157 | /// # let config = Configuration { |
158 | @@ -136,15 +122,29 @@ mod post_policy { |
159 | /// # data_path: tmp_dir.path().to_path_buf(), |
160 | /// # administrators: vec![], |
161 | /// # }; |
162 | - /// |
163 | + /// # |
164 | /// # fn do_test(config: Configuration) { |
165 | /// let db = Connection::open_or_create_db(config).unwrap().trusted(); |
166 | /// db.remove_list_post_policy(1, 1).unwrap(); |
167 | /// # } |
168 | /// # do_test(config); |
169 | /// ``` |
170 | - #[cfg(doc)] |
171 | - pub fn remove_list_post_policy_panic() {} |
172 | + pub fn remove_list_post_policy(&self, list_pk: i64, policy_pk: i64) -> Result<()> { |
173 | + let mut stmt = self |
174 | + .connection |
175 | + .prepare("DELETE FROM post_policy WHERE pk = ? AND list = ? RETURNING *;")?; |
176 | + stmt.query_row(rusqlite::params![&policy_pk, &list_pk,], |_| Ok(())) |
177 | + .map_err(|err| { |
178 | + if matches!(err, rusqlite::Error::QueryReturnedNoRows) { |
179 | + Error::from(err).chain_err(|| NotFound("list or list policy not found!")) |
180 | + } else { |
181 | + err.into() |
182 | + } |
183 | + })?; |
184 | + |
185 | + trace!("remove_list_post_policy {} {}.", list_pk, policy_pk); |
186 | + Ok(()) |
187 | + } |
188 | |
189 | /// Set the unique post policy for a list. |
190 | pub fn set_list_post_policy(&self, policy: PostPolicy) -> Result<DbVal<PostPolicy>> { |
191 | @@ -257,10 +257,12 @@ mod subscription_policy { |
192 | |
193 | /// Remove an existing subscription policy. |
194 | /// |
195 | + /// # Examples |
196 | + /// |
197 | /// ``` |
198 | /// # use mailpot::{models::*, Configuration, Connection, SendMail}; |
199 | /// # use tempfile::TempDir; |
200 | - /// |
201 | + /// # |
202 | /// # let tmp_dir = TempDir::new().unwrap(); |
203 | /// # let db_path = tmp_dir.path().join("mpot.db"); |
204 | /// # let config = Configuration { |
205 | @@ -269,7 +271,7 @@ mod subscription_policy { |
206 | /// # data_path: tmp_dir.path().to_path_buf(), |
207 | /// # administrators: vec![], |
208 | /// # }; |
209 | - /// |
210 | + /// # |
211 | /// # fn do_test(config: Configuration) { |
212 | /// let db = Connection::open_or_create_db(config).unwrap().trusted(); |
213 | /// let list = db |
214 | @@ -302,27 +304,11 @@ mod subscription_policy { |
215 | /// # } |
216 | /// # do_test(config); |
217 | /// ``` |
218 | - pub fn remove_list_subscription_policy(&self, list_pk: i64, policy_pk: i64) -> Result<()> { |
219 | - let mut stmt = self.connection.prepare( |
220 | - "DELETE FROM subscription_policy WHERE pk = ? AND list = ? RETURNING *;", |
221 | - )?; |
222 | - stmt.query_row(rusqlite::params![&policy_pk, &list_pk,], |_| Ok(())) |
223 | - .map_err(|err| { |
224 | - if matches!(err, rusqlite::Error::QueryReturnedNoRows) { |
225 | - Error::from(err).chain_err(|| NotFound("list or list policy not found!")) |
226 | - } else { |
227 | - err.into() |
228 | - } |
229 | - })?; |
230 | - |
231 | - trace!("remove_list_subscription_policy {} {}.", list_pk, policy_pk); |
232 | - Ok(()) |
233 | - } |
234 | - |
235 | + /// |
236 | /// ```should_panic |
237 | /// # use mailpot::{models::*, Configuration, Connection, SendMail}; |
238 | /// # use tempfile::TempDir; |
239 | - /// |
240 | + /// # |
241 | /// # let tmp_dir = TempDir::new().unwrap(); |
242 | /// # let db_path = tmp_dir.path().join("mpot.db"); |
243 | /// # let config = Configuration { |
244 | @@ -331,15 +317,29 @@ mod subscription_policy { |
245 | /// # data_path: tmp_dir.path().to_path_buf(), |
246 | /// # administrators: vec![], |
247 | /// # }; |
248 | - /// |
249 | + /// # |
250 | /// # fn do_test(config: Configuration) { |
251 | /// let db = Connection::open_or_create_db(config).unwrap().trusted(); |
252 | /// db.remove_list_post_policy(1, 1).unwrap(); |
253 | /// # } |
254 | /// # do_test(config); |
255 | /// ``` |
256 | - #[cfg(doc)] |
257 | - pub fn remove_list_subscription_policy_panic() {} |
258 | + pub fn remove_list_subscription_policy(&self, list_pk: i64, policy_pk: i64) -> Result<()> { |
259 | + let mut stmt = self.connection.prepare( |
260 | + "DELETE FROM subscription_policy WHERE pk = ? AND list = ? RETURNING *;", |
261 | + )?; |
262 | + stmt.query_row(rusqlite::params![&policy_pk, &list_pk,], |_| Ok(())) |
263 | + .map_err(|err| { |
264 | + if matches!(err, rusqlite::Error::QueryReturnedNoRows) { |
265 | + Error::from(err).chain_err(|| NotFound("list or list policy not found!")) |
266 | + } else { |
267 | + err.into() |
268 | + } |
269 | + })?; |
270 | + |
271 | + trace!("remove_list_subscription_policy {} {}.", list_pk, policy_pk); |
272 | + Ok(()) |
273 | + } |
274 | |
275 | /// Set the unique post policy for a list. |
276 | pub fn set_list_subscription_policy( |
277 | diff --git a/web/Cargo.toml b/web/Cargo.toml |
278 | index 3e0bef5..39e8d99 100644 |
279 | --- a/web/Cargo.toml |
280 | +++ b/web/Cargo.toml |
281 | @@ -13,6 +13,7 @@ categories = ["email"] |
282 | [[bin]] |
283 | name = "mpot-web" |
284 | path = "src/main.rs" |
285 | + doc-scrape-examples = true |
286 | |
287 | [dependencies] |
288 | axum = { version = "^0.6" } |