Skip to content

We have now the CI ensure all doc strings remain formatted #16916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI

on:
push:
branches: [ main ]
pull_request:

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rust nightly
run: rustup toolchain install nightly

- name: Run rustfmt (nightly)
run: cargo +nightly fmt --all -- --config format_code_in_doc_comments=true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @yazanmashal03

I am not sure what this check is doing - it seems to just run the fmt rather than check its output, for example

1 change: 0 additions & 1 deletion datafusion-examples/examples/advanced_parquet_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ use url::Url;
/// │ ╚═══════════════════╝ │ 1. With cached ParquetMetadata, so
/// └───────────────────────┘ the ParquetSource does not re-read /
/// Parquet File decode the thrift footer
///
/// ```
///
/// Within a Row Group, Column Chunks store data in DataPages. This example also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use url::Url;
///
/// - AWS_ACCESS_KEY_ID
/// - AWS_SECRET_ACCESS_KEY
///
#[tokio::main]
async fn main() -> Result<()> {
let ctx = SessionContext::new();
Expand Down
1 change: 0 additions & 1 deletion datafusion-examples/examples/flight/flight_sql_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ macro_rules! status {
///
/// Based heavily on Ballista's implementation: https://github.com/apache/datafusion-ballista/blob/main/ballista/scheduler/src/flight_sql.rs
/// and the example in arrow-rs: https://github.com/apache/arrow-rs/blob/master/arrow-flight/examples/flight_sql_server.rs
///
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
Expand Down
1 change: 0 additions & 1 deletion datafusion-examples/examples/parquet_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ use url::Url;
/// Thus some parquet files are │ │
/// "pruned" and thus are not └─────────────┘
/// scanned at all Parquet Files
///
/// ```
///
/// [`ListingTable`]: datafusion::datasource::listing::ListingTable
Expand Down
1 change: 0 additions & 1 deletion datafusion-examples/examples/sql_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use std::sync::Arc;
///
/// [`query_memtable`]: a simple query against a [`MemTable`]
/// [`query_parquet`]: a simple query against a directory with multiple Parquet files
///
#[tokio::main]
async fn main() -> Result<()> {
query_memtable().await?;
Expand Down
2 changes: 1 addition & 1 deletion datafusion-examples/examples/thread_pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl CpuRuntime {
/// message such as:
///
/// ```text
///A Tokio 1.x context was found, but IO is disabled.
/// A Tokio 1.x context was found, but IO is disabled.
/// ```
pub fn handle(&self) -> &Handle {
&self.handle
Expand Down
47 changes: 23 additions & 24 deletions datafusion/common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use hex;
/// /// Field 3 doc
/// field3: Option<usize>, default = None
/// }
///}
/// }
/// ```
///
/// Will generate
Expand Down Expand Up @@ -1139,36 +1139,35 @@ impl ConfigOptions {
/// # Example
/// ```
/// use datafusion_common::{
/// config::ConfigExtension, extensions_options,
/// config::ConfigOptions,
/// config::ConfigExtension, config::ConfigOptions, extensions_options,
/// };
/// // Define a new configuration struct using the `extensions_options` macro
/// extensions_options! {
/// /// My own config options.
/// pub struct MyConfig {
/// /// Should "foo" be replaced by "bar"?
/// pub foo_to_bar: bool, default = true
/// // Define a new configuration struct using the `extensions_options` macro
/// extensions_options! {
/// /// My own config options.
/// pub struct MyConfig {
/// /// Should "foo" be replaced by "bar"?
/// pub foo_to_bar: bool, default = true
///
/// /// How many "baz" should be created?
/// pub baz_count: usize, default = 1337
/// }
/// }
/// /// How many "baz" should be created?
/// pub baz_count: usize, default = 1337
/// }
/// }
///
/// impl ConfigExtension for MyConfig {
/// impl ConfigExtension for MyConfig {
/// const PREFIX: &'static str = "my_config";
/// }
/// }
///
/// // set up config struct and register extension
/// let mut config = ConfigOptions::default();
/// config.extensions.insert(MyConfig::default());
/// // set up config struct and register extension
/// let mut config = ConfigOptions::default();
/// config.extensions.insert(MyConfig::default());
///
/// // overwrite config default
/// config.set("my_config.baz_count", "42").unwrap();
/// // overwrite config default
/// config.set("my_config.baz_count", "42").unwrap();
///
/// // check config state
/// let my_config = config.extensions.get::<MyConfig>().unwrap();
/// assert!(my_config.foo_to_bar,);
/// assert_eq!(my_config.baz_count, 42,);
/// // check config state
/// let my_config = config.extensions.get::<MyConfig>().unwrap();
/// assert!(my_config.foo_to_bar,);
/// assert_eq!(my_config.baz_count, 42,);
/// ```
///
/// # Note:
Expand Down
22 changes: 10 additions & 12 deletions datafusion/common/src/dfschema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ pub type DFSchemaRef = Arc<DFSchema>;
/// an Arrow schema.
///
/// ```rust
/// use datafusion_common::{DFSchema, Column};
/// use arrow::datatypes::{DataType, Field, Schema};
/// use datafusion_common::{Column, DFSchema};
///
/// let arrow_schema = Schema::new(vec![
/// Field::new("c1", DataType::Int32, false),
/// ]);
/// let arrow_schema = Schema::new(vec![Field::new("c1", DataType::Int32, false)]);
///
/// let df_schema = DFSchema::try_from_qualified_schema("t1", &arrow_schema).unwrap();
/// let column = Column::from_qualified_name("t1.c1");
Expand All @@ -77,12 +75,10 @@ pub type DFSchemaRef = Arc<DFSchema>;
/// Create an unqualified schema using TryFrom:
///
/// ```rust
/// use datafusion_common::{DFSchema, Column};
/// use arrow::datatypes::{DataType, Field, Schema};
/// use datafusion_common::{Column, DFSchema};
///
/// let arrow_schema = Schema::new(vec![
/// Field::new("c1", DataType::Int32, false),
/// ]);
/// let arrow_schema = Schema::new(vec![Field::new("c1", DataType::Int32, false)]);
///
/// let df_schema = DFSchema::try_from(arrow_schema).unwrap();
/// let column = Column::new_unqualified("c1");
Expand All @@ -94,13 +90,15 @@ pub type DFSchemaRef = Arc<DFSchema>;
/// Use the `Into` trait to convert `DFSchema` into an Arrow schema:
///
/// ```rust
/// use arrow::datatypes::{Field, Schema};
/// use datafusion_common::DFSchema;
/// use arrow::datatypes::{Schema, Field};
/// use std::collections::HashMap;
///
/// let df_schema = DFSchema::from_unqualified_fields(vec![
/// Field::new("c1", arrow::datatypes::DataType::Int32, false),
/// ].into(),HashMap::new()).unwrap();
/// let df_schema = DFSchema::from_unqualified_fields(
/// vec![Field::new("c1", arrow::datatypes::DataType::Int32, false)].into(),
/// HashMap::new(),
/// )
/// .unwrap();
/// let schema = Schema::from(df_schema);
/// assert_eq!(schema.fields().len(), 1);
/// ```
Expand Down
7 changes: 5 additions & 2 deletions datafusion/common/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ use crate::Span;
/// ```rust
/// # use datafusion_common::{Location, Span, Diagnostic};
/// let span = Some(Span {
/// start: Location{ line: 2, column: 1 },
/// end: Location{ line: 4, column: 15 }
/// start: Location { line: 2, column: 1 },
/// end: Location {
/// line: 4,
/// column: 15,
/// },
/// });
/// let diagnostic = Diagnostic::new_error("Something went wrong", span)
/// .with_help("Have you tried turning it on and off again?", None);
Expand Down
17 changes: 13 additions & 4 deletions datafusion/common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,10 @@ impl DataFusionError {
/// let mut builder = DataFusionError::builder();
/// builder.add_error(DataFusionError::Internal("foo".to_owned()));
/// // ok_or returns the value if no errors have been added
/// assert_contains!(builder.error_or(42).unwrap_err().to_string(), "Internal error: foo");
/// assert_contains!(
/// builder.error_or(42).unwrap_err().to_string(),
/// "Internal error: foo"
/// );
/// ```
#[derive(Debug, Default)]
pub struct DataFusionErrorBuilder(Vec<DataFusionError>);
Expand All @@ -695,7 +698,10 @@ impl DataFusionErrorBuilder {
/// # use datafusion_common::{assert_contains, DataFusionError};
/// let mut builder = DataFusionError::builder();
/// builder.add_error(DataFusionError::Internal("foo".to_owned()));
/// assert_contains!(builder.error_or(42).unwrap_err().to_string(), "Internal error: foo");
/// assert_contains!(
/// builder.error_or(42).unwrap_err().to_string(),
/// "Internal error: foo"
/// );
/// ```
pub fn add_error(&mut self, error: DataFusionError) {
self.0.push(error);
Expand All @@ -707,8 +713,11 @@ impl DataFusionErrorBuilder {
/// ```
/// # use datafusion_common::{assert_contains, DataFusionError};
/// let builder = DataFusionError::builder()
/// .with_error(DataFusionError::Internal("foo".to_owned()));
/// assert_contains!(builder.error_or(42).unwrap_err().to_string(), "Internal error: foo");
/// .with_error(DataFusionError::Internal("foo".to_owned()));
/// assert_contains!(
/// builder.error_or(42).unwrap_err().to_string(),
/// "Internal error: foo"
/// );
/// ```
pub fn with_error(mut self, error: DataFusionError) -> Self {
self.0.push(error);
Expand Down
Loading
Loading