Skip to content

Commit

Permalink
docs: warn on missing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JayWhite2357 committed Apr 26, 2024
1 parent 9764402 commit 6e0000a
Show file tree
Hide file tree
Showing 55 changed files with 215 additions and 32 deletions.
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ index = "https://spaceandtime.jfrog.io/artifactory/git/sxt-proofs-cargo-local.gi
[target.x86_64-unknown-linux-gnu]
linker = "/usr/bin/clang" # used to decrease build time
rustflags = ["-Clink-arg=-fuse-ld=lld"] # used to decrease link time

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ tracing-opentelemetry = { version = "0.22.0" }
tracing-subscriber = { version = "0.3.0" }
typetag = { version = "0.2.13" }
wasm-bindgen = { version = "0.2.92" }

[workspace.lints.rust]
missing_docs = "warn"
3 changes: 3 additions & 0 deletions crates/proofs-sql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ lalrpop = { version = "0.20.0" }

[dev-dependencies]
serde_json = { workspace = true }

[lints]
workspace = true
1 change: 1 addition & 0 deletions crates/proofs-sql/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! TODO: add docs
extern crate lalrpop;

fn main() {
Expand Down
4 changes: 4 additions & 0 deletions crates/proofs-sql/src/decimal_unknown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
pub struct DecimalUnknown {
value: String,
precision: u8,
/// TODO: add docs
pub scale: i8,
}

Expand Down Expand Up @@ -80,12 +81,15 @@ impl DecimalUnknown {
}
}

/// TODO: add docs
pub fn value(&self) -> String {
self.value.to_owned()
}
/// TODO: add docs
pub fn precision(&self) -> u8 {
self.precision
}
/// TODO: add docs
pub fn scale(&self) -> i8 {
self.scale
}
Expand Down
4 changes: 4 additions & 0 deletions crates/proofs-sql/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ use thiserror::Error;
#[derive(Debug, Error, Eq, PartialEq)]
pub enum ParseError {
#[error("Unable to parse query")]
/// TODO: add docs
QueryParseError(String),
#[error("Unable to parse identifier")]
/// TODO: add docs
IdentifierParseError(String),
#[error("Unable to parse resource_id")]
/// TODO: add docs
ResourceIdParseError(String),
}

/// TODO: add docs
pub type ParseResult<T> = std::result::Result<T, ParseError>;
35 changes: 35 additions & 0 deletions crates/proofs-sql/src/intermediate_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,45 @@ use serde::{Deserialize, Serialize};
pub enum SetExpression {
/// Query result as `SetExpression`
Query {
/// TODO: add docs
result_exprs: Vec<SelectResultExpr>,
/// TODO: add docs
from: Vec<Box<TableExpression>>,
/// TODO: add docs
where_expr: Option<Box<Expression>>,
/// TODO: add docs
group_by: Vec<Identifier>,
},
}

#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
/// TODO: add docs
pub enum SelectResultExpr {
/// TODO: add docs
ALL,
/// TODO: add docs
AliasedResultExpr(AliasedResultExpr),
}

#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
/// TODO: add docs
pub struct AliasedResultExpr {
/// TODO: add docs
pub expr: Box<Expression>,
/// TODO: add docs
pub alias: Identifier,
}

impl AliasedResultExpr {
/// TODO: add docs
pub fn new(expr: Expression, alias: Identifier) -> Self {
Self {
expr: Box::new(expr),
alias,
}
}

/// TODO: add docs
pub fn try_as_identifier(&self) -> Option<&Identifier> {
match self.expr.as_ref() {
Expression::Column(column) => Some(column),
Expand All @@ -53,6 +65,7 @@ pub enum TableExpression {
Named {
/// the qualified table Identifier
table: Identifier,
/// TODO: add docs
schema: Option<Identifier>,
},
}
Expand Down Expand Up @@ -97,11 +110,17 @@ pub enum UnaryOperator {

// Aggregation operators
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
/// TODO: add docs
pub enum AggregationOperator {
/// TODO: add docs
Max,
/// TODO: add docs
Min,
/// TODO: add docs
Sum,
/// TODO: add docs
Count,
/// TODO: add docs
First,
}

Expand All @@ -128,14 +147,19 @@ pub enum Expression {

/// Unary operation
Unary {
/// TODO: add docs
op: UnaryOperator,
/// TODO: add docs
expr: Box<Expression>,
},

/// Binary operation
Binary {
/// TODO: add docs
op: BinaryOperator,
/// TODO: add docs
left: Box<Expression>,
/// TODO: add docs
right: Box<Expression>,
},

Expand All @@ -144,40 +168,47 @@ pub enum Expression {

/// Aggregation operation
Aggregation {
/// TODO: add docs
op: AggregationOperator,
/// TODO: add docs
expr: Box<Expression>,
},
}

impl Expression {
/// TODO: add docs
pub fn sum(self) -> Box<Self> {
Box::new(Expression::Aggregation {
op: AggregationOperator::Sum,
expr: Box::new(self),
})
}

/// TODO: add docs
pub fn max(self) -> Box<Self> {
Box::new(Expression::Aggregation {
op: AggregationOperator::Max,
expr: Box::new(self),
})
}

/// TODO: add docs
pub fn min(self) -> Box<Self> {
Box::new(Expression::Aggregation {
op: AggregationOperator::Min,
expr: Box::new(self),
})
}

/// TODO: add docs
pub fn count(self) -> Box<Self> {
Box::new(Expression::Aggregation {
op: AggregationOperator::Count,
expr: Box::new(self),
})
}

/// TODO: add docs
pub fn first(self) -> Box<Self> {
Box::new(Expression::Aggregation {
op: AggregationOperator::First,
Expand All @@ -189,14 +220,18 @@ impl Expression {
/// OrderBy
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct OrderBy {
/// TODO: add docs
pub expr: Identifier,
/// TODO: add docs
pub direction: OrderByDirection,
}

/// OrderByDirection values
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Copy)]
pub enum OrderByDirection {
/// TODO: add docs
Asc,
/// TODO: add docs
Desc,
}

Expand Down
10 changes: 9 additions & 1 deletion crates/proofs-sql/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
//! TODO: add docs

/// TODO: add docs
pub mod decimal_unknown;
#[macro_use]
extern crate lalrpop_util;

/// TODO: add docs
pub mod intermediate_ast;

#[cfg(test)]
Expand All @@ -10,20 +14,24 @@ mod intermediate_ast_tests;
#[cfg(test)]
pub mod test_utility;

/// TODO: add docs
pub mod select_statement;
pub use select_statement::SelectStatement;

/// TODO: add docs
pub mod error;
pub use error::{ParseError, ParseResult};

/// TODO: add docs
pub mod identifier;
pub use identifier::Identifier;

/// TODO: add docs
pub mod resource_id;
pub use resource_id::ResourceId;

// lalrpop-generated code is not clippy-compliant
lalrpop_mod!(#[allow(clippy::all)] pub sql);
lalrpop_mod!(#[allow(clippy::all, missing_docs)] pub sql);

/// Implement Deserialize through FromStr to avoid invalid identifiers.
#[macro_export]
Expand Down
5 changes: 4 additions & 1 deletion crates/proofs-wasm-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ version.workspace = true
[dependencies]
ark-std = { workspace = true }
proofs = { path = "../proofs", default-features = false, features = ["test"] }
wasm-bindgen = { workspace = true }
wasm-bindgen = { workspace = true }

[lints]
workspace = true
1 change: 1 addition & 0 deletions crates/proofs-wasm-test/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! TODO: add docs
use ark_std::test_rng;
use proofs::{
base::database::{OwnedTableTestAccessor, TestAccessor},
Expand Down
3 changes: 3 additions & 0 deletions crates/proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ name = "sumcheck"
[features]
default = ["blitzar"]
test = ["dep:rand"]

[lints]
workspace = true
2 changes: 2 additions & 0 deletions crates/proofs/benches/sumcheck.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(missing_docs)]

use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use merlin::Transcript;
use num_traits::{One, Zero};
Expand Down
1 change: 1 addition & 0 deletions crates/proofs/src/base/bit/abs_bit_mask.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::base::scalar::Scalar;

/// TODO: add docs
pub fn make_abs_bit_mask<S: Scalar>(x: S) -> [u64; 4] {
let (sign, x) = if S::MAX_SIGNED < x { (1, -x) } else { (0, x) };
let mut res: [u64; 4] = x.into();
Expand Down
5 changes: 5 additions & 0 deletions crates/proofs/src/base/bit/bit_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ pub struct BitDistribution {
/// 1 if x_s & (1 << i) != x_t & (1 << i) for some s != t
/// 0 otherwise
pub or_all: [u64; 4],
/// TODO: add docs
pub vary_mask: [u64; 4],
}

impl BitDistribution {
/// TODO: add docs
pub fn new<S: Scalar, T: Into<S> + Clone>(data: &[T]) -> Self {
if data.is_empty() {
return Self {
Expand All @@ -37,6 +39,7 @@ impl BitDistribution {
Self { or_all, vary_mask }
}

/// TODO: add docs
pub fn num_varying_bits(&self) -> usize {
let mut res = 0_usize;
for xi in self.vary_mask.iter() {
Expand All @@ -45,10 +48,12 @@ impl BitDistribution {
res
}

/// TODO: add docs
pub fn has_varying_sign_bit(&self) -> bool {
self.vary_mask[3] & (1 << 63) != 0
}

/// TODO: add docs
pub fn sign_bit(&self) -> bool {
assert!(!self.has_varying_sign_bit());
self.or_all[3] & (1 << 63) != 0
Expand Down
10 changes: 0 additions & 10 deletions crates/proofs/src/base/database/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![warn(missing_docs)]
//! Module with database related functionality. In particular, this module contains the
//! accessor traits and the `OwnedTable` type along with some utility functions to convert
//! between Arrow and `OwnedTable`.
Expand All @@ -20,15 +19,13 @@ pub use record_batch_dataframe_conversion::*;
mod record_batch_utility;
pub use record_batch_utility::*;

#[warn(missing_docs)]
#[cfg(any(test, feature = "test"))]
#[cfg(feature = "blitzar")]
mod record_batch_test_accessor;
#[cfg(any(test, feature = "test"))]
#[cfg(feature = "blitzar")]
pub use record_batch_test_accessor::RecordBatchTestAccessor;

#[warn(missing_docs)]
#[cfg(all(test, feature = "blitzar"))]
mod record_batch_test_accessor_test;

Expand All @@ -37,30 +34,23 @@ mod test_accessor_utility;
#[cfg(any(test, feature = "test"))]
pub use test_accessor_utility::{make_random_test_accessor_data, RandomTestAccessorDescriptor};

#[warn(missing_docs)]
mod owned_column;
pub use owned_column::*;
#[warn(missing_docs)]
mod owned_table;
pub use owned_table::*;
#[cfg(test)]
#[warn(missing_docs)]
mod owned_table_test;

#[warn(missing_docs)]
mod owned_and_arrow_conversions;
pub use owned_and_arrow_conversions::*;
#[cfg(test)]
#[warn(missing_docs)]
mod owned_and_arrow_conversions_test;

#[warn(missing_docs)]
#[cfg(any(test, feature = "test"))]
mod test_accessor;
#[cfg(any(test, feature = "test"))]
pub use test_accessor::{TestAccessor, UnimplementedTestAccessor};

#[warn(missing_docs)]
#[cfg(any(test, feature = "test"))]
mod owned_table_test_accessor;
#[cfg(any(test, feature = "test"))]
Expand Down
1 change: 1 addition & 0 deletions crates/proofs/src/base/math/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::str::FromStr;
#[derive(Eq, PartialEq, Debug, Clone, Hash, Serialize, Copy)]
/// limit-enforced precision
pub struct Precision(u8);
/// TODO: add docs
pub const MAX_SUPPORTED_PRECISION: u8 = 75;

impl Precision {
Expand Down
Loading

0 comments on commit 6e0000a

Please sign in to comment.