mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-02-02 10:54:15 -05:00
added book
This commit is contained in:
parent
fc4198897c
commit
6a8c24ebbf
10 changed files with 121 additions and 5 deletions
1
docs/book/.gitignore
vendored
Normal file
1
docs/book/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
book
|
11
docs/book/book.toml
Normal file
11
docs/book/book.toml
Normal file
|
@ -0,0 +1,11 @@
|
|||
[book]
|
||||
authors = ["Marc-Stefan Cassola"]
|
||||
language = "en"
|
||||
multilingual = false
|
||||
src = "src"
|
||||
title = "Leptos-Use Documentation"
|
||||
|
||||
[output.html]
|
||||
no-section-label = true
|
||||
|
||||
[preprocessor.cmdrun]
|
12
docs/book/src/SUMMARY.md
Normal file
12
docs/book/src/SUMMARY.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Summary
|
||||
|
||||
[Introduction]()
|
||||
|
||||
# Getting Started
|
||||
|
||||
- [Get Started](getting_started/get_started.md)
|
||||
- [Functions](getting_started/functions.md)
|
||||
|
||||
# Browser
|
||||
|
||||
- [useEventListener](browser/use_event_listener.md)
|
3
docs/book/src/browser/use_event_listener.md
Normal file
3
docs/book/src/browser/use_event_listener.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# use_event_listener
|
||||
|
||||
<!-- cmdrun python3 ../extract_doc_comment.py use_event_listener -->
|
21
docs/book/src/extract_doc_comment.py
Normal file
21
docs/book/src/extract_doc_comment.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
name = sys.argv[1]
|
||||
file_name = f"../../../../src/{name}.rs"
|
||||
with open(file_name) as f:
|
||||
in_code_block = False
|
||||
for line in f.readlines():
|
||||
if line.startswith("///"):
|
||||
line = line.strip().replace("/// ", "").replace("///", "")
|
||||
if "```" in line:
|
||||
if not in_code_block:
|
||||
line = line.replace("```", "```rust,ignore")
|
||||
in_code_block = not in_code_block
|
||||
|
||||
print(line)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
3
docs/book/src/getting_started/functions.md
Normal file
3
docs/book/src/getting_started/functions.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Functions
|
||||
|
||||
<!-- cmdrun python3 generate_function_overview.py browser -->
|
33
docs/book/src/getting_started/generate_function_overview.py
Normal file
33
docs/book/src/getting_started/generate_function_overview.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
for entry in sys.argv[1:]:
|
||||
generate_function_overview_for_category(entry)
|
||||
|
||||
|
||||
def generate_function_overview_for_category(category):
|
||||
print(f"## {category.title()}")
|
||||
|
||||
listdir = os.listdir(os.path.join(os.getcwd(), "..", category))
|
||||
listdir.sort()
|
||||
|
||||
for name in listdir:
|
||||
if name.endswith(".md"):
|
||||
generate_function_overview(category, name[:-3])
|
||||
|
||||
|
||||
def generate_function_overview(category, name):
|
||||
file_name = f"../../../../src/{name}.rs"
|
||||
with open(file_name) as f:
|
||||
in_code_block = False
|
||||
for line in f.readlines():
|
||||
if line.startswith("///"):
|
||||
line = line.strip().replace("/// ", "")
|
||||
print(f"- [{name}](/{category}/{name}.md) – {line}")
|
||||
return
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
31
docs/book/src/getting_started/get_started.md
Normal file
31
docs/book/src/getting_started/get_started.md
Normal file
|
@ -0,0 +1,31 @@
|
|||
# Get Started
|
||||
|
||||
## Installation
|
||||
|
||||
```shell
|
||||
cargo add leptos-use
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
- [Examples Directory](https://github.com/Synphonyte/leptos-use/tree/master/examples)
|
||||
|
||||
## Usage Example
|
||||
|
||||
Simply import the functions you need from `leptos-use`
|
||||
|
||||
```rust,noplayground
|
||||
# use leptos::*;
|
||||
use leptos_use::use_mouse::*;
|
||||
|
||||
#[component]
|
||||
pub fn Demo(cx: Scope) -> into ImplView {
|
||||
let UseMouseReturn { x, y, .. } = use_mouse(cx);
|
||||
|
||||
view! { cx,
|
||||
{x} "x" {y}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Please refer to the [functions list](functions.md) for more details.
|
|
@ -1,6 +1,6 @@
|
|||
pub mod core;
|
||||
mod use_event_listener;
|
||||
mod use_scroll;
|
||||
pub mod use_event_listener;
|
||||
pub mod use_scroll;
|
||||
|
||||
pub use use_event_listener::*;
|
||||
pub use use_scroll::*;
|
||||
pub use use_event_listener::use_event_listener;
|
||||
pub use use_scroll::use_scroll;
|
||||
|
|
|
@ -8,7 +8,8 @@ use std::rc::Rc;
|
|||
use wasm_bindgen::closure::Closure;
|
||||
use wasm_bindgen::JsCast;
|
||||
|
||||
/// Use EventListener with ease. Register using [addEventListener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener) on mounted,
|
||||
/// Use EventListener with ease.
|
||||
/// Register using [addEventListener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener) on mounted,
|
||||
/// and [removeEventListener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener) automatically on cleanup.
|
||||
///
|
||||
/// ## Usage
|
||||
|
|
Loading…
Add table
Reference in a new issue