Removed docs headers

This commit is contained in:
veeso
2021-12-11 10:19:29 +01:00
committed by Christian Visintin
parent 2e0322bc0e
commit 027545f14c
52 changed files with 0 additions and 966 deletions

View File

@@ -31,16 +31,12 @@ use super::{ExplorerOpts, FileExplorer, FileSorting, GroupDirs};
// Ext
use std::collections::VecDeque;
/// ## FileExplorerBuilder
///
/// Struct used to create a `FileExplorer`
pub struct FileExplorerBuilder {
explorer: Option<FileExplorer>,
}
impl FileExplorerBuilder {
/// ### new
///
/// Build a new `FileExplorerBuilder`
pub fn new() -> Self {
FileExplorerBuilder {
@@ -48,15 +44,11 @@ impl FileExplorerBuilder {
}
}
/// ### build
///
/// Take FileExplorer out of builder
pub fn build(&mut self) -> FileExplorer {
self.explorer.take().unwrap()
}
/// ### with_hidden_files
///
/// Enable HIDDEN_FILES option
pub fn with_hidden_files(&mut self, val: bool) -> &mut FileExplorerBuilder {
if let Some(e) = self.explorer.as_mut() {
@@ -68,8 +60,6 @@ impl FileExplorerBuilder {
self
}
/// ### with_file_sorting
///
/// Set sorting method
pub fn with_file_sorting(&mut self, sorting: FileSorting) -> &mut FileExplorerBuilder {
if let Some(e) = self.explorer.as_mut() {
@@ -78,8 +68,6 @@ impl FileExplorerBuilder {
self
}
/// ### with_dirs_first
///
/// Enable DIRS_FIRST option
pub fn with_group_dirs(&mut self, group_dirs: Option<GroupDirs>) -> &mut FileExplorerBuilder {
if let Some(e) = self.explorer.as_mut() {
@@ -88,8 +76,6 @@ impl FileExplorerBuilder {
self
}
/// ### with_stack_size
///
/// Set stack size for FileExplorer
pub fn with_stack_size(&mut self, sz: usize) -> &mut FileExplorerBuilder {
if let Some(e) = self.explorer.as_mut() {
@@ -99,8 +85,6 @@ impl FileExplorerBuilder {
self
}
/// ### with_formatter
///
/// Set formatter for FileExplorer
pub fn with_formatter(&mut self, fmt_str: Option<&str>) -> &mut FileExplorerBuilder {
if let Some(e) = self.explorer.as_mut() {

View File

@@ -64,8 +64,6 @@ lazy_static! {
static ref FMT_ATTR_REGEX: Regex = Regex::new(r"(?:([A-Z]+))(:?([0-9]+))?(:?(.+))?").ok().unwrap();
}
/// ## CallChainBlock
///
/// Call Chain block is a block in a chain of functions which are called in order to format the Entry.
/// A callChain is instantiated starting from the Formatter syntax and the regex, once the groups are found
/// a chain of function is made using the Formatters method.
@@ -84,8 +82,6 @@ struct CallChainBlock {
}
impl CallChainBlock {
/// ### new
///
/// Create a new `CallChainBlock`
pub fn new(
func: FmtCallback,
@@ -102,8 +98,6 @@ impl CallChainBlock {
}
}
/// ### next
///
/// Call next callback in the CallChain
pub fn next(&self, fmt: &Formatter, fsentry: &Entry, cur_str: &str) -> String {
// Call func
@@ -122,8 +116,6 @@ impl CallChainBlock {
}
}
/// ### push
///
/// Push func to the last element in the Call chain
pub fn push(
&mut self,
@@ -144,8 +136,6 @@ impl CallChainBlock {
}
}
/// ## Formatter
///
/// Formatter takes care of formatting FsEntries according to the provided keys.
/// Formatting is performed using the `CallChainBlock`, which composed makes a Call Chain. This method is extremely fast compared to match the format groups
/// at each fmt call.
@@ -154,8 +144,6 @@ pub struct Formatter {
}
impl Default for Formatter {
/// ### default
///
/// Instantiates a Formatter with the default fmt syntax
fn default() -> Self {
Formatter {
@@ -165,8 +153,6 @@ impl Default for Formatter {
}
impl Formatter {
/// ### new
///
/// Instantiates a new `Formatter` with the provided format string
pub fn new(fmt_str: &str) -> Self {
Formatter {
@@ -174,8 +160,6 @@ impl Formatter {
}
}
/// ### fmt
///
/// Format fsentry
pub fn fmt(&self, fsentry: &Entry) -> String {
// Execute callchain blocks
@@ -184,8 +168,6 @@ impl Formatter {
// Fmt methods
/// ### fmt_atime
///
/// Format last access time
fn fmt_atime(
&self,
@@ -213,8 +195,6 @@ impl Formatter {
)
}
/// ### fmt_ctime
///
/// Format creation time
fn fmt_ctime(
&self,
@@ -242,8 +222,6 @@ impl Formatter {
)
}
/// ### fmt_group
///
/// Format owner group
fn fmt_group(
&self,
@@ -277,8 +255,6 @@ impl Formatter {
)
}
/// ### fmt_mtime
///
/// Format last change time
fn fmt_mtime(
&self,
@@ -306,8 +282,6 @@ impl Formatter {
)
}
/// ### fmt_name
///
/// Format file name
fn fmt_name(
&self,
@@ -339,8 +313,6 @@ impl Formatter {
format!("{}{}{:0width$}", cur_str, prefix, name, width = file_len)
}
/// ### fmt_path
///
/// Format path
fn fmt_path(
&self,
@@ -366,8 +338,6 @@ impl Formatter {
)
}
/// ### fmt_pex
///
/// Format file permissions
fn fmt_pex(
&self,
@@ -403,8 +373,6 @@ impl Formatter {
format!("{}{}{:10}", cur_str, prefix, pex)
}
/// ### fmt_size
///
/// Format file size
fn fmt_size(
&self,
@@ -425,8 +393,6 @@ impl Formatter {
}
}
/// ### fmt_symlink
///
/// Format file symlink (if any)
fn fmt_symlink(
&self,
@@ -454,8 +420,6 @@ impl Formatter {
}
}
/// ### fmt_user
///
/// Format owner user
fn fmt_user(
&self,
@@ -483,8 +447,6 @@ impl Formatter {
format!("{}{}{:12}", cur_str, prefix, username)
}
/// ### fmt_fallback
///
/// Fallback function in case the format key is unknown
/// It does nothing, just returns cur_str
fn fmt_fallback(
@@ -501,8 +463,6 @@ impl Formatter {
// Static
/// ### make_callchain
///
/// Make a callchain starting from the fmt str
fn make_callchain(fmt_str: &str) -> CallChainBlock {
// Init chain block
@@ -952,8 +912,6 @@ mod tests {
assert_eq!(formatter.fmt(&entry).as_str(), "File path: c/bar.txt");
}
/// ### dummy_fmt
///
/// Dummy formatter, just yelds an 'A' at the end of the current string
fn dummy_fmt(
_fmt: &Formatter,

View File

@@ -47,8 +47,6 @@ bitflags! {
}
}
/// ## FileSorting
///
/// FileSorting defines the criteria for sorting files
#[derive(Copy, Clone, PartialEq, std::fmt::Debug)]
pub enum FileSorting {
@@ -58,8 +56,6 @@ pub enum FileSorting {
Size,
}
/// ## GroupDirs
///
/// GroupDirs defines how directories should be grouped in sorting files
#[derive(PartialEq, std::fmt::Debug)]
pub enum GroupDirs {
@@ -67,8 +63,6 @@ pub enum GroupDirs {
Last,
}
/// ## FileExplorer
///
/// File explorer states
pub struct FileExplorer {
pub wrkdir: PathBuf, // Current directory
@@ -97,8 +91,6 @@ impl Default for FileExplorer {
}
impl FileExplorer {
/// ### pushd
///
/// push directory to stack
pub fn pushd(&mut self, dir: &Path) {
// Check if stack would overflow the size
@@ -109,15 +101,11 @@ impl FileExplorer {
self.dirstack.push_back(PathBuf::from(dir));
}
/// ### popd
///
/// Pop directory from the stack and return the directory
pub fn popd(&mut self) -> Option<PathBuf> {
self.dirstack.pop_back()
}
/// ### set_files
///
/// Set Explorer files
/// This method will also sort entries based on current options
/// Once all sorting have been performed, index is moved to first valid entry.
@@ -127,8 +115,6 @@ impl FileExplorer {
self.sort();
}
/// ### del_entry
///
/// Delete file at provided index
pub fn del_entry(&mut self, idx: usize) {
if self.files.len() > idx {
@@ -137,16 +123,12 @@ impl FileExplorer {
}
/*
/// ### count
///
/// Return amount of files
pub fn count(&self) -> usize {
self.files.len()
}
*/
/// ### iter_files
///
/// Iterate over files
/// Filters are applied based on current options (e.g. hidden files not returned)
pub fn iter_files(&self) -> impl Iterator<Item = &Entry> + '_ {
@@ -163,15 +145,11 @@ impl FileExplorer {
}))
}
/// ### iter_files_all
///
/// Iterate all files; doesn't care about options
pub fn iter_files_all(&self) -> impl Iterator<Item = &Entry> + '_ {
Box::new(self.files.iter())
}
/// ### get
///
/// Get file at relative index
pub fn get(&self, idx: usize) -> Option<&Entry> {
let opts: ExplorerOpts = self.opts;
@@ -193,8 +171,6 @@ impl FileExplorer {
// Formatting
/// ### fmt_file
///
/// Format a file entry
pub fn fmt_file(&self, entry: &Entry) -> String {
self.fmt.fmt(entry)
@@ -202,8 +178,6 @@ impl FileExplorer {
// Sorting
/// ### sort_by
///
/// Choose sorting method; then sort files
pub fn sort_by(&mut self, sorting: FileSorting) {
// If method HAS ACTUALLY CHANGED, sort (performance!)
@@ -213,15 +187,11 @@ impl FileExplorer {
}
}
/// ### get_file_sorting
///
/// Get current file sorting method
pub fn get_file_sorting(&self) -> FileSorting {
self.file_sorting
}
/// ### group_dirs_by
///
/// Choose group dirs method; then sort files
pub fn group_dirs_by(&mut self, group_dirs: Option<GroupDirs>) {
// If method HAS ACTUALLY CHANGED, sort (performance!)
@@ -231,8 +201,6 @@ impl FileExplorer {
}
}
/// ### sort
///
/// Sort files based on Explorer options.
fn sort(&mut self) {
// Choose sorting method
@@ -252,60 +220,44 @@ impl FileExplorer {
}
}
/// ### sort_files_by_name
///
/// Sort explorer files by their name. All names are converted to lowercase
fn sort_files_by_name(&mut self) {
self.files.sort_by_key(|x: &Entry| x.name().to_lowercase());
}
/// ### sort_files_by_mtime
///
/// Sort files by mtime; the newest comes first
fn sort_files_by_mtime(&mut self) {
self.files
.sort_by(|a: &Entry, b: &Entry| b.metadata().mtime.cmp(&a.metadata().mtime));
}
/// ### sort_files_by_creation_time
///
/// Sort files by creation time; the newest comes first
fn sort_files_by_creation_time(&mut self) {
self.files
.sort_by_key(|b: &Entry| Reverse(b.metadata().ctime));
}
/// ### sort_files_by_size
///
/// Sort files by size
fn sort_files_by_size(&mut self) {
self.files
.sort_by_key(|b: &Entry| Reverse(b.metadata().size));
}
/// ### sort_files_directories_first
///
/// Sort files; directories come first
fn sort_files_directories_first(&mut self) {
self.files.sort_by_key(|x: &Entry| x.is_file());
}
/// ### sort_files_directories_last
///
/// Sort files; directories come last
fn sort_files_directories_last(&mut self) {
self.files.sort_by_key(|x: &Entry| x.is_dir());
}
/// ### toggle_hidden_files
///
/// Enable/disable hidden files
pub fn toggle_hidden_files(&mut self) {
self.opts.toggle(ExplorerOpts::SHOW_HIDDEN_FILES);
}
/// ### hidden_files_visible
///
/// Returns whether hidden files are visible
pub fn hidden_files_visible(&self) -> bool {
self.opts.intersects(ExplorerOpts::SHOW_HIDDEN_FILES)