Skip to content

Commit 6ebb364

Browse files
committed
std: cleanup file::io rustdoc_ng output
1 parent 44dc3fb commit 6ebb364

File tree

1 file changed

+49
-67
lines changed

1 file changed

+49
-67
lines changed

src/libstd/rt/io/file.rs

Lines changed: 49 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -479,25 +479,29 @@ pub trait FileSystemInfo {
479479
///
480480
/// * Check if a file exists, reading from it if so
481481
///
482-
/// use std;
483-
/// use std::path::Path;
484-
/// use std::rt::io::file::{FileInfo, FileReader};
485-
///
486-
/// let f = &Path("/some/file/path.txt");
487-
/// if f.exists() {
488-
/// let reader = f.open_reader(Open);
489-
/// let mut mem = [0u8, 8*64000];
490-
/// reader.read(mem);
491-
/// // ...
492-
/// }
482+
/// ~~~{.rust}
483+
/// use std;
484+
/// use std::path::Path;
485+
/// use std::rt::io::file::{FileInfo, FileReader};
486+
///
487+
/// let f = &Path("/some/file/path.txt");
488+
/// if f.exists() {
489+
/// let reader = f.open_reader(Open);
490+
/// let mut mem = [0u8, 8*64000];
491+
/// reader.read(mem);
492+
/// // ...
493+
/// }
494+
/// ~~~
493495
///
494496
/// * Is the given path a file?
495497
///
496-
/// let f = get_file_path_from_wherever();
497-
/// match f.is_file() {
498-
/// true => doing_something_with_a_file(f),
499-
/// _ => {}
500-
/// }
498+
/// ~~~{.rust}
499+
/// let f = get_file_path_from_wherever();
500+
/// match f.is_file() {
501+
/// true => doing_something_with_a_file(f),
502+
/// _ => {}
503+
/// }
504+
/// ~~~
501505
pub trait FileInfo : FileSystemInfo {
502506
/// Whether the underlying implemention (be it a file path,
503507
/// or something else) points at a "regular file" on the FS. Will return
@@ -572,27 +576,31 @@ impl FileInfo for Path { }
572576
///
573577
/// * Check if a directory exists, `mkdir`'ing it if not
574578
///
575-
/// use std;
576-
/// use std::path::Path;
577-
/// use std::rt::io::file::{DirectoryInfo};
579+
/// ~~~{.rust}
580+
/// use std;
581+
/// use std::path::Path;
582+
/// use std::rt::io::file::{DirectoryInfo};
578583
///
579-
/// let dir = &Path("/some/dir");
580-
/// if !dir.exists() {
581-
/// dir.mkdir();
582-
/// }
584+
/// let dir = &Path("/some/dir");
585+
/// if !dir.exists() {
586+
/// dir.mkdir();
587+
/// }
588+
/// ~~~
583589
///
584590
/// * Is the given path a directory? If so, iterate on its contents
585591
///
586-
/// fn visit_dirs(dir: &Path, cb: &fn(&Path)) {
587-
/// if dir.is_dir() {
588-
/// let contents = dir.readdir();
589-
/// for entry in contents.iter() {
590-
/// if entry.is_dir() { visit_dirs(entry, cb); }
591-
/// else { cb(entry); }
592-
/// }
592+
/// ~~~{.rust}
593+
/// fn visit_dirs(dir: &Path, cb: &fn(&Path)) {
594+
/// if dir.is_dir() {
595+
/// let contents = dir.readdir();
596+
/// for entry in contents.iter() {
597+
/// if entry.is_dir() { visit_dirs(entry, cb); }
598+
/// else { cb(entry); }
593599
/// }
594-
/// else { fail!("nope"); }
595600
/// }
601+
/// else { fail!("nope"); }
602+
/// }
603+
/// ~~~
596604
trait DirectoryInfo : FileSystemInfo {
597605
/// Whether the underlying implemention (be it a file path,
598606
/// or something else) is pointing at a directory in the underlying FS.
@@ -678,7 +686,8 @@ trait DirectoryInfo : FileSystemInfo {
678686
/// `DirectoryInfo` impl for `path::Path`
679687
impl DirectoryInfo for Path { }
680688

681-
fn file_test_smoke_test_impl() {
689+
#[test]
690+
fn file_test_io_smoke_test() {
682691
do run_in_mt_newsched_task {
683692
let message = "it's alright. have a good time";
684693
let filename = &Path("./tmp/file_rt_io_file_test.txt");
@@ -701,11 +710,7 @@ fn file_test_smoke_test_impl() {
701710
}
702711

703712
#[test]
704-
fn file_test_io_smoke_test() {
705-
file_test_smoke_test_impl();
706-
}
707-
708-
fn file_test_invalid_path_opened_without_create_should_raise_condition_impl() {
713+
fn file_test_io_invalid_path_opened_without_create_should_raise_condition() {
709714
do run_in_mt_newsched_task {
710715
let filename = &Path("./tmp/file_that_does_not_exist.txt");
711716
let mut called = false;
@@ -718,12 +723,9 @@ fn file_test_invalid_path_opened_without_create_should_raise_condition_impl() {
718723
assert!(called);
719724
}
720725
}
721-
#[test]
722-
fn file_test_io_invalid_path_opened_without_create_should_raise_condition() {
723-
file_test_invalid_path_opened_without_create_should_raise_condition_impl();
724-
}
725726

726-
fn file_test_unlinking_invalid_path_should_raise_condition_impl() {
727+
#[test]
728+
fn file_test_iounlinking_invalid_path_should_raise_condition() {
727729
do run_in_mt_newsched_task {
728730
let filename = &Path("./tmp/file_another_file_that_does_not_exist.txt");
729731
let mut called = false;
@@ -735,12 +737,9 @@ fn file_test_unlinking_invalid_path_should_raise_condition_impl() {
735737
assert!(called);
736738
}
737739
}
738-
#[test]
739-
fn file_test_iounlinking_invalid_path_should_raise_condition() {
740-
file_test_unlinking_invalid_path_should_raise_condition_impl();
741-
}
742740

743-
fn file_test_io_non_positional_read_impl() {
741+
#[test]
742+
fn file_test_io_non_positional_read() {
744743
do run_in_mt_newsched_task {
745744
use str;
746745
let message = "ten-four";
@@ -768,11 +767,7 @@ fn file_test_io_non_positional_read_impl() {
768767
}
769768

770769
#[test]
771-
fn file_test_io_non_positional_read() {
772-
file_test_io_non_positional_read_impl();
773-
}
774-
775-
fn file_test_io_seeking_impl() {
770+
fn file_test_io_seek_and_tell_smoke_test() {
776771
do run_in_mt_newsched_task {
777772
use str;
778773
let message = "ten-four";
@@ -801,11 +796,7 @@ fn file_test_io_seeking_impl() {
801796
}
802797

803798
#[test]
804-
fn file_test_io_seek_and_tell_smoke_test() {
805-
file_test_io_seeking_impl();
806-
}
807-
808-
fn file_test_io_seek_and_write_impl() {
799+
fn file_test_io_seek_and_write() {
809800
do run_in_mt_newsched_task {
810801
use str;
811802
let initial_msg = "food-is-yummy";
@@ -831,11 +822,7 @@ fn file_test_io_seek_and_write_impl() {
831822
}
832823

833824
#[test]
834-
fn file_test_io_seek_and_write() {
835-
file_test_io_seek_and_write_impl();
836-
}
837-
838-
fn file_test_io_seek_shakedown_impl() {
825+
fn file_test_io_seek_shakedown() {
839826
do run_in_mt_newsched_task {
840827
use str; // 01234567890123
841828
let initial_msg = "qwer-asdf-zxcv";
@@ -870,11 +857,6 @@ fn file_test_io_seek_shakedown_impl() {
870857
}
871858
}
872859

873-
#[test]
874-
fn file_test_io_seek_shakedown() {
875-
file_test_io_seek_shakedown_impl();
876-
}
877-
878860
#[test]
879861
fn file_test_stat_is_correct_on_is_file() {
880862
do run_in_mt_newsched_task {

0 commit comments

Comments
 (0)