This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 8407928cc docs: add service doc for gdrive & onedrive (#3028)
8407928cc is described below

commit 8407928cc70dbbbbbdd97d1061b87c67c7b813e2
Author: Isaac <[email protected]>
AuthorDate: Sun Sep 10 17:07:53 2023 +0200

    docs: add service doc for gdrive & onedrive (#3028)
---
 core/src/services/gdrive/builder.rs   | 69 +----------------------------------
 core/src/services/gdrive/docs.md      | 65 +++++++++++++++++++++++++++++++++
 core/src/services/onedrive/builder.rs | 46 +----------------------
 core/src/services/onedrive/docs.md    | 44 ++++++++++++++++++++++
 website/docs/services/gdrive.mdx      | 65 +++++++++++++++++++++++++++++++++
 website/docs/services/onedrive.mdx    | 65 +++++++++++++++++++++++++++++++++
 6 files changed, 241 insertions(+), 113 deletions(-)

diff --git a/core/src/services/gdrive/builder.rs 
b/core/src/services/gdrive/builder.rs
index 9c5aefd7d..984c27909 100644
--- a/core/src/services/gdrive/builder.rs
+++ b/core/src/services/gdrive/builder.rs
@@ -34,75 +34,8 @@ use crate::Scheme;
 use crate::*;
 
 /// [GoogleDrive](https://drive.google.com/) backend support.
-///
-/// # Capabilities
-///
-/// This service can be used to:
-///
-/// - [x] stat
-/// - [x] read
-/// - [x] write
-/// - [x] delete
-/// - [x] create_dir
-/// - [ ] list
-/// - [ ] copy
-/// - [ ] rename
-/// - [ ] batch
-///
-/// # Notes
-///
-///
-/// # Configuration
-///
-/// - `root`: Set the work directory for backend
-///
-/// ## Credentials related
-///
-/// ### Just provide Access Token (Temporary)
-///
-/// - `access_token`: set the access_token for google drive api
-/// Please notice its expiration.
-///
-/// ### Or provide Client ID and Client Secret and refresh token (Long Term)
-///
-/// If you want to let OpenDAL to refresh the access token automatically,
-/// please provide the following fields:
-///
-/// - `refresh_token`: set the refresh_token for google drive api
-/// - `client_id`: set the client_id for google drive api
-/// - `client_secret`: set the client_secret for google drive api
-///
-/// OpenDAL is a library, it cannot do the first step of OAuth2 for you.
-/// You need to get authorization code from user by calling GoogleDrive's 
authorize url
-/// and exchange it for refresh token.
-///
-/// Make sure you have enabled Google Drive API in your Google Cloud Console.
-/// And your OAuth scope contains `https://www.googleapis.com/auth/drive`.
-///
-/// Please refer to [GoogleDrive OAuth2 
Flow](https://developers.google.com/identity/protocols/oauth2/)
-/// for more information.
-///
-/// You can refer to [`GdriveBuilder`]'s docs for more information
-///
-/// # Example
-///
-/// ## Via Builder
-///
-/// ```rust
-/// use anyhow::Result;
-/// use opendal::services::Gdrive;
-/// use opendal::Operator;
-///
-/// #[tokio::main]
-/// async fn main() -> Result<()> {
-///     let mut builder = Gdrive::default();
-///     builder.root("/test");
-///     builder.access_token("<token>");
-///
-///     Ok(())
-/// }
-/// ```
 #[derive(Default)]
+#[doc = include_str!("docs.md")]
 pub struct GdriveBuilder {
     root: Option<String>,
 
diff --git a/core/src/services/gdrive/docs.md b/core/src/services/gdrive/docs.md
new file mode 100644
index 000000000..325a26c37
--- /dev/null
+++ b/core/src/services/gdrive/docs.md
@@ -0,0 +1,65 @@
+## Capabilities
+
+This service can be used to:
+
+- [x] stat
+- [x] read
+- [x] write
+- [x] delete
+- [x] create_dir
+- [ ] list
+- [ ] copy
+- [ ] rename
+- [ ] batch
+
+
+# Configuration
+
+- `root`: Set the work directory for backend
+
+### Credentials related
+
+#### Just provide Access Token (Temporary)
+
+- `access_token`: set the access_token for google drive api
+Please notice its expiration.
+
+#### Or provide Client ID and Client Secret and refresh token (Long Term)
+
+If you want to let OpenDAL to refresh the access token automatically,
+please provide the following fields:
+
+- `refresh_token`: set the refresh_token for google drive api
+- `client_id`: set the client_id for google drive api
+- `client_secret`: set the client_secret for google drive api
+
+OpenDAL is a library, it cannot do the first step of OAuth2 for you.
+You need to get authorization code from user by calling GoogleDrive's 
authorize url
+and exchange it for refresh token.
+
+Make sure you have enabled Google Drive API in your Google Cloud Console.
+And your OAuth scope contains `https://www.googleapis.com/auth/drive`.
+
+Please refer to [GoogleDrive OAuth2 
Flow](https://developers.google.com/identity/protocols/oauth2/)
+for more information.
+
+You can refer to [`GdriveBuilder`]'s docs for more information
+
+## Example
+
+### Via Builder
+
+```rust
+use anyhow::Result;
+use opendal::services::Gdrive;
+use opendal::Operator;
+
+#[tokio::main]
+async fn main() -> Result<()> {
+    let mut builder = Gdrive::default();
+    builder.root("/test");
+    builder.access_token("<token>");
+
+    Ok(())
+}
+
diff --git a/core/src/services/onedrive/builder.rs 
b/core/src/services/onedrive/builder.rs
index 63f00a8a2..96aa426e8 100644
--- a/core/src/services/onedrive/builder.rs
+++ b/core/src/services/onedrive/builder.rs
@@ -28,51 +28,7 @@ use crate::Scheme;
 use crate::*;
 
 /// [OneDrive](https://onedrive.com) backend support.
-///
-/// # Capabilities
-///
-/// This service can be used to:
-///
-/// - [x] read
-/// - [x] write
-/// - [x] list
-/// - [ ] copy
-/// - [ ] rename
-/// - [ ] ~~scan~~
-/// - [ ] ~~presign~~
-/// - [ ] blocking
-///
-/// # Notes
-///
-/// Currently, only OneDrive Personal is supported.
-///
-/// # Configuration
-///
-/// - `access_token`: set the access_token for Graph API
-/// - `root`: Set the work directory for backend
-///
-/// You can refer to [`OnedriveBuilder`]'s docs for more information
-///
-/// # Example
-///
-/// ## Via Builder
-///
-/// ```no_run
-/// use anyhow::Result;
-/// use opendal::services::Onedrive;
-/// use opendal::Operator;
-///
-/// #[tokio::main]
-/// async fn main() -> Result<()> {
-///     // create backend builder
-///     let mut builder = Onedrive::default();
-///
-///     builder.access_token("xxx").root("/path/to/root");
-///
-///     let op: Operator = Operator::new(builder)?.finish();
-///     Ok(())
-/// }
-/// ```
+#[doc = include_str!("docs.md")]
 #[derive(Default)]
 pub struct OnedriveBuilder {
     access_token: Option<String>,
diff --git a/core/src/services/onedrive/docs.md 
b/core/src/services/onedrive/docs.md
new file mode 100644
index 000000000..0ee24a320
--- /dev/null
+++ b/core/src/services/onedrive/docs.md
@@ -0,0 +1,44 @@
+## Capabilities
+
+This service can be used to:
+
+- [x] read
+- [x] write
+- [x] list
+- [ ] copy
+- [ ] rename
+- [ ] ~~scan~~
+- [ ] ~~presign~~
+- [ ] blocking
+
+## Notes
+
+Currently, only OneDrive Personal is supported.
+
+## Configuration
+
+- `access_token`: set the access_token for Graph API
+- `root`: Set the work directory for backend
+
+You can refer to [`OnedriveBuilder`]'s docs for more information
+
+## Example
+
+### Via Builder
+
+```rust
+use anyhow::Result;
+use opendal::services::Onedrive;
+use opendal::Operator;
+
+#[tokio::main]
+async fn main() -> Result<()> {
+    // create backend builder
+    let mut builder = Onedrive::default();
+
+    builder.access_token("xxx").root("/path/to/root");
+
+    let op: Operator = Operator::new(builder)?.finish();
+    Ok(())
+}
+
diff --git a/website/docs/services/gdrive.mdx b/website/docs/services/gdrive.mdx
new file mode 100644
index 000000000..bff0af362
--- /dev/null
+++ b/website/docs/services/gdrive.mdx
@@ -0,0 +1,65 @@
+---
+title: Gdrive
+---
+
+[Google Drive](https://drive.google.com) services support.
+
+import Docs from '../../../core/src/services/gdrive/docs.md'
+
+<Docs components={props.components} />
+
+### Via Config
+
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+<Tabs>
+  <TabItem value="rust" label="Rust" default>
+
+```rust
+use anyhow::Result;
+use opendal::Operator;
+use opendal::Scheme;
+use std::collections::HashMap;
+
+#[tokio::main]
+async fn main() -> Result<()> {
+    let mut map = HashMap::new();
+    map.insert("root".to_string(), "/path/to/dir".to_string());
+    map.insert("access_token".to_string(), "your_access_token".to_string());
+
+    let op: Operator = Operator::via_map(Scheme::Gdrive, map)?;
+    Ok(())
+}
+```
+
+  </TabItem>
+  <TabItem value="node.js" label="Node.js">
+
+```javascript
+import { Operator } from "opendal";
+
+async function main() {
+  const op = new Operator("gdrive", {
+    root: "/path/to/dir",
+    access_token: "your_access_token",
+  });
+}
+```
+
+  </TabItem>
+  <TabItem value="python" label="Python">
+
+```python
+import opendal
+
+op = opendal.Operator("gdrive",
+  root="/path/to/dir",
+  access_token="your_access_token",
+)
+```
+
+  </TabItem>
+</Tabs>
+
diff --git a/website/docs/services/onedrive.mdx 
b/website/docs/services/onedrive.mdx
new file mode 100644
index 000000000..61ab43943
--- /dev/null
+++ b/website/docs/services/onedrive.mdx
@@ -0,0 +1,65 @@
+---
+title: OneDrive
+---
+
+[OneDrive](https://onedrive.com) services support.
+
+import Docs from '../../../core/src/services/onedrive/docs.md'
+
+<Docs components={props.components} />
+
+### Via Config
+
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+<Tabs>
+  <TabItem value="rust" label="Rust" default>
+
+```rust
+use anyhow::Result;
+use opendal::Operator;
+use opendal::Scheme;
+use std::collections::HashMap;
+
+#[tokio::main]
+async fn main() -> Result<()> {
+    let mut map = HashMap::new();
+    map.insert("root".to_string(), "/path/to/dir".to_string());
+    map.insert("access_token".to_string(), "your_access_token".to_string());
+
+    let op: Operator = Operator::via_map(Scheme::Onedrive, map)?;
+    Ok(())
+}
+```
+
+  </TabItem>
+  <TabItem value="node.js" label="Node.js">
+
+```javascript
+import { Operator } from "opendal";
+
+async function main() {
+  const op = new Operator("onedrive", {
+    root: "/path/to/dir",
+    access_token: "your_access_token",
+  });
+}
+```
+
+  </TabItem>
+  <TabItem value="python" label="Python">
+
+```python
+import opendal
+
+op = opendal.Operator("onedrive",
+  root="/path/to/dir",
+  access_token="your_access_token",
+)
+```
+
+  </TabItem>
+</Tabs>
+

Reply via email to