Skip to content

Commit 69fd1ba

Browse files
committed
i think were ready for publishing
1 parent e792dd9 commit 69fd1ba

File tree

8 files changed

+31
-4
lines changed

8 files changed

+31
-4
lines changed

function_history_backend_thread/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use crate::types::{CommandResult, ListType, Status};
1111

1212
pub mod types;
1313

14+
/// the thread that handles the commands
1415
pub fn command_thread(
1516
rx_t: Receiver<FullCommand>,
1617
tx_t: Sender<(CommandResult, Status)>,

git-function-history-lib/src/languages/go.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ impl GoParameter {
3232
}
3333

3434
impl GoFunction {
35+
/// Create a new Go function
3536
pub const fn new(
3637
name: String,
3738
body: String,
@@ -199,6 +200,7 @@ pub(crate) fn find_function_in_file(
199200
}
200201

201202
#[derive(Debug, Clone, PartialEq, Eq)]
203+
/// filter for go functions
202204
pub enum GoFilter {
203205
// refers to the type of a parameter of a function
204206
HasParameter(String),
@@ -209,6 +211,7 @@ pub enum GoFilter {
209211
}
210212

211213
impl GoFilter {
214+
/// checks if a function matches the filter
212215
pub fn matches(&self, func: &GoFunction) -> bool {
213216
match self {
214217
Self::HasParameter(param) => match &func.parameters {

git-function-history-lib/src/languages/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use self::{python::PythonFunction, ruby::RubyFunction, rust::RustFunction, umpl:
1212
#[cfg(feature = "unstable")]
1313
use go::GoFunction;
1414
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
15+
/// an enum representing the different languages that are supported
1516
pub enum Language {
1617
/// The python language
1718
Python,
@@ -31,6 +32,7 @@ pub enum Language {
3132
All,
3233
}
3334
#[derive(Debug, Clone, PartialEq, Eq)]
35+
/// the different filters that can be used to filter the functions for different languages
3436
pub enum LanguageFilter {
3537
/// python filter
3638
Python(python::PythonFilter),
@@ -195,6 +197,8 @@ pub trait FileTrait: fmt::Debug + fmt::Display {
195197
fn filter_by(&self, filter: &Filter) -> Result<Self, String>
196198
where
197199
Self: Sized;
200+
201+
/// returns the current function that the file is on
198202
fn get_current(&self) -> Option<Box<dyn FunctionTrait>>;
199203
}
200204

@@ -230,14 +234,17 @@ fn get_from_index(index: &HashMap<usize, Vec<usize>>, char: usize) -> Option<usi
230234

231235
// macro that generates the code for the different languages
232236
macro_rules! make_file {
233-
($name:ident, $function:ident, $filtername:ident) => {
237+
(@gen $name:ident, $function:ident, $doc:expr) => {
238+
#[doc = $doc]
234239
#[derive(Debug, Clone)]
235240
pub struct $name {
236241
file_name: String,
237242
functions: Vec<$function>,
238243
current_pos: usize,
239244
}
240-
245+
};
246+
($name:ident, $function:ident, $filtername:ident) => {
247+
make_file!(@gen $name, $function, concat!(" a way to hold a bunch of ", stringify!($filtername), " functions in a file"));
241248
impl fmt::Display for $name {
242249
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
243250
let mut file: Vec<(String, usize)> = Vec::new();
@@ -323,7 +330,6 @@ macro_rules! make_file {
323330
}
324331
};
325332
}
326-
327333
make_file!(PythonFile, PythonFunction, Python);
328334
make_file!(RustFile, RustFunction, Rust);
329335
// #[cfg(feature = "c_lang")]

git-function-history-lib/src/languages/python.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub struct PythonParams {
6767
}
6868

6969
impl PythonParams {
70+
/// Check if a parameter with the given name exists
7071
pub fn arg_has_name(&self, name: &str) -> bool {
7172
self.args.iter().any(|arg| arg.name == name)
7273
|| self.kwargs.iter().any(|arg| arg.name == name)
@@ -511,6 +512,7 @@ fn get_decorator_list_new(
511512
}
512513

513514
#[derive(Debug, Clone, PartialEq, Eq)]
515+
/// filters for python functions
514516
pub enum PythonFilter {
515517
/// when you want to filter by function that are in a specific class
516518
InClass(String),
@@ -533,6 +535,7 @@ pub enum PythonFilter {
533535
}
534536

535537
impl PythonFilter {
538+
/// checks if a function matches the filter
536539
pub fn matches(&self, function: &PythonFunction) -> bool {
537540
match self {
538541
Self::InClass(class) => function.class.iter().any(|c| c.name == *class),

git-function-history-lib/src/languages/ruby.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub struct RubyFunction {
2121
}
2222

2323
impl RubyFunction {
24+
/// creates a new `RubyFunction`
2425
pub const fn new(
2526
name: String,
2627
lines: (usize, usize),
@@ -83,6 +84,7 @@ pub struct RubyParams {
8384
}
8485

8586
impl RubyParams {
87+
/// creates `RubyParams` which is a repersentation of the parameters of a ruby function
8688
pub const fn new() -> Self {
8789
Self {
8890
args: Vec::new(),
@@ -320,6 +322,7 @@ impl FunctionTrait for RubyFunction {
320322
}
321323
}
322324
#[derive(Debug, Clone, PartialEq, Eq)]
325+
/// filter for ruby functions
323326
pub enum RubyFilter {
324327
/// find a Ruby functions in a specific class
325328
FunctionInClass(String),
@@ -330,6 +333,7 @@ pub enum RubyFilter {
330333
}
331334

332335
impl RubyFilter {
336+
/// check if a function matches the filter
333337
pub fn matches(&self, function: &RubyFunction) -> bool {
334338
match self {
335339
Self::FunctionInClass(name) => function.class.iter().any(|class| &class.name == name),

git-function-history-lib/src/languages/rust.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ fn get_ret_type(fns: &Fn) -> Option<String> {
451451
.and_then(|ret| ret.ty().map(|ty| ty.to_string()))
452452
}
453453
#[derive(Debug, Clone, PartialEq, Eq)]
454+
455+
/// filters for rust functions
454456
pub enum RustFilter {
455457
/// when you want to filter by function that are in a specific block (impl, trait, extern)
456458
InBlock(BlockType),
@@ -495,6 +497,7 @@ pub enum RustFilter {
495497
}
496498

497499
impl RustFilter {
500+
/// checks if a function matches the filter
498501
pub fn matches(&self, function: &RustFunction) -> bool {
499502
match self {
500503
Self::InBlock(block_type) => function

git-function-history-lib/src/languages/umpl.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ use crate::impl_function_trait;
66

77
use super::FunctionTrait;
88
#[derive(Debug, Clone, PartialEq, Eq)]
9+
10+
/// represents a function in the umpl language
911
pub struct UMPLFunction {
1012
pub(crate) lines: (usize, usize),
1113
pub(crate) name: String,
1214
pub(crate) body: String,
1315
pub(crate) args_count: usize,
1416
pub(crate) parents: Vec<UMPLParentFunction>,
1517
}
18+
19+
/// represents a parent function in the umpl language
1620
#[derive(Debug, Clone, PartialEq, Eq)]
1721
pub struct UMPLParentFunction {
1822
pub(crate) lines: (usize, usize),
@@ -203,6 +207,8 @@ fn find_function_recurse(
203207
}
204208

205209
#[derive(Debug, Clone, PartialEq, Eq)]
210+
211+
/// filter for umpl functions
206212
pub enum UMPLFilter {
207213
HasParameterCount(usize),
208214
HasParentWithParamCount(usize),
@@ -211,6 +217,7 @@ pub enum UMPLFilter {
211217
}
212218

213219
impl UMPLFilter {
220+
/// check if a function matches the filter
214221
pub fn matches(&self, function: &UMPLFunction) -> bool {
215222
match self {
216223
Self::HasParameterCount(count) => function.args_count == *count,

git-function-history-lib/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use crate::{
1818
use crate::languages::GoFile;
1919

2020
#[derive(Debug, Clone)]
21+
/// a enum that can be used to store a file of any of the supported languages
2122
pub enum FileType {
2223
Rust(RustFile),
2324
Python(PythonFile),
@@ -312,7 +313,6 @@ impl Display for Commit {
312313
pub struct FunctionHistory {
313314
pub(crate) name: String,
314315
pub(crate) commit_history: Vec<Commit>,
315-
316316
current_iter_pos: usize,
317317
current_pos: usize,
318318
}

0 commit comments

Comments
 (0)