Skip to content

Commit 8d8bb2c

Browse files
committed
docs
1 parent 55988d5 commit 8d8bb2c

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tmc-langs-core/src/tmc_core.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ impl TmcCore {
190190
self.organizations()
191191
}
192192

193+
/// Unimplemented.
193194
#[deprecated = "unimplemented"]
194195
pub fn send_diagnostics(&self) {
195196
unimplemented!()
@@ -227,6 +228,15 @@ impl TmcCore {
227228
///
228229
/// # Errors
229230
/// Returns an error if there's some problem reaching the API, or if the API returns an error.
231+
///
232+
/// # Examples
233+
/// ```rust,no_run
234+
/// use tmc_langs_core::TmcCore;
235+
///
236+
/// let core = TmcCore::new_in_config("https://tmc.mooc.fi".to_string()).unwrap();
237+
/// // authenticate
238+
/// let course_details = core.get_course_details(600).unwrap();
239+
/// ```
230240
pub fn get_course_details(&self, course_id: usize) -> Result<CourseDetails> {
231241
self.core_course(course_id)
232242
}
@@ -235,6 +245,15 @@ impl TmcCore {
235245
///
236246
/// # Errors
237247
/// Returns an error if there's some problem reaching the API, or if the API returns an error.
248+
///
249+
/// # Examples
250+
/// ```rust,no_run
251+
/// use tmc_langs_core::TmcCore;
252+
///
253+
/// let core = TmcCore::new_in_config("https://tmc.mooc.fi".to_string()).unwrap();
254+
/// // authenticate
255+
/// let courses = core.list_courses("hy").unwrap();
256+
/// ```
238257
pub fn list_courses(&self, organization_slug: &str) -> Result<Vec<Course>> {
239258
self.organization_courses(organization_slug)
240259
}
@@ -243,6 +262,24 @@ impl TmcCore {
243262
///
244263
/// # Errors
245264
/// Returns an error if there's some problem reaching the API, or if the API returns an error.
265+
///
266+
/// # Examples
267+
/// ```rust,no_run
268+
/// use tmc_langs_core::{TmcCore, Language};
269+
/// use url::Url;
270+
/// use std::path::Path;
271+
///
272+
/// let core = TmcCore::new_in_config("https://tmc.mooc.fi".to_string()).unwrap();
273+
/// // authenticate
274+
/// let course_details = core.get_course_details(600).unwrap();
275+
/// let submission_url = &course_details.exercises[0].return_url;
276+
/// let submission_url = Url::parse(&submission_url).unwrap();
277+
/// let new_submission = core.paste_with_comment(
278+
/// submission_url,
279+
/// Path::new("./exercises/python/123"),
280+
/// "my python solution".to_string(),
281+
/// Language::Eng).unwrap();
282+
/// ```
246283
pub fn paste_with_comment(
247284
&self,
248285
submission_url: Url,
@@ -264,6 +301,24 @@ impl TmcCore {
264301
/// # Errors
265302
/// Returns an error if no matching language plugin for the project is found,
266303
/// or if the plugin returns an error while trying to run the style check.
304+
///
305+
/// # Examples
306+
/// ```rust,no_run
307+
/// use tmc_langs_core::{TmcCore, Language};
308+
/// use std::path::Path;
309+
///
310+
/// let core = TmcCore::new_in_config("https://tmc.mooc.fi".to_string()).unwrap();
311+
/// // authenticate
312+
/// let validation_result = core.run_checkstyle(Path::new("./exercises/python/123"), Language::Eng).unwrap();
313+
/// match validation_result {
314+
/// Some(validation_result) => if let Some(validation_errors) = validation_result.validation_errors {
315+
/// println!("found validation errors: {:?}", validation_errors);
316+
/// } else {
317+
/// println!("no errors");
318+
/// }
319+
/// None => println!("no style checks"),
320+
/// }
321+
/// ```
267322
pub fn run_checkstyle(
268323
&self,
269324
path: &Path,

0 commit comments

Comments
 (0)