Skip to content

Commit 9fa9972

Browse files
committed
fix readme links
1 parent b04c774 commit 9fa9972

9 files changed

Lines changed: 154 additions & 35 deletions

File tree

Cargo.lock

Lines changed: 27 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ dx serve --example dioxus-code-live-input # textarea bound to runtime highlight
118118

119119
## License
120120

121-
[MIT](LICENSE).
121+
MIT. See the repository `LICENSE` file.

code-editor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repository.workspace = true
88
homepage.workspace = true
99
keywords.workspace = true
1010
categories.workspace = true
11-
readme = "../README.md"
11+
readme = "README.md"
1212

1313
[dependencies]
1414
dioxus = { version = "0.7.0", default-features = false, features = ["lib"] }

code-editor/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<div align="center">
2+
<h1>dioxus-code-editor</h1>
3+
<p><strong>Syntax-highlighted code editor component for Dioxus.</strong></p>
4+
</div>
5+
6+
<div align="center">
7+
<a href="https://crates.io/crates/dioxus-code-editor">
8+
<img src="https://img.shields.io/crates/v/dioxus-code-editor.svg?style=flat-square" alt="Crates.io version" />
9+
</a>
10+
<a href="https://crates.io/crates/dioxus-code-editor">
11+
<img src="https://img.shields.io/crates/d/dioxus-code-editor.svg?style=flat-square" alt="Downloads" />
12+
</a>
13+
<a href="https://docs.rs/dioxus-code-editor">
14+
<img src="https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square" alt="docs.rs" />
15+
</a>
16+
</div>
17+
18+
---
19+
20+
A controlled, syntax-highlighted code editor for Dioxus. Pairs a `contenteditable` input layer with the [`dioxus-code`](https://crates.io/crates/dioxus-code) highlighter so user edits stay in sync with rendered tokens.
21+
22+
## Quick start
23+
24+
```toml
25+
[dependencies]
26+
dioxus-code-editor = "0.0.1"
27+
```
28+
29+
```rust
30+
use dioxus::prelude::*;
31+
use dioxus_code::Theme;
32+
use dioxus_code_editor::CodeEditor;
33+
34+
#[component]
35+
fn Editor() -> Element {
36+
let mut source = use_signal(String::new);
37+
38+
rsx! {
39+
CodeEditor {
40+
value: source(),
41+
language: "rust",
42+
theme: Theme::TOKYO_NIGHT,
43+
oninput: move |value| source.set(value),
44+
}
45+
}
46+
}
47+
```
48+
49+
The component is controlled — drive `value` from your own signal and update it inside `oninput`.
50+
51+
## Props
52+
53+
| prop | description |
54+
|---|---|
55+
| `value` | Current editor contents. |
56+
| `language` | Arborium language hint, e.g. `"rust"`. |
57+
| `name` | Filename used for language detection when `language` is empty. |
58+
| `theme` | Syntax theme shared with `dioxus-code`. |
59+
| `line_numbers` | Show a one-based line gutter. Defaults to `true`. |
60+
| `read_only` | Disable editing while preserving highlighting. |
61+
| `spellcheck` | Forward `spellcheck` to the input layer. |
62+
| `aria_label` | Accessible label for the editor textbox. |
63+
| `placeholder` | Shown only while `value` is empty. |
64+
| `class` | Extra class names appended to the editor root. |
65+
| `oninput` | Called with the full editor text after each input event. |
66+
67+
## License
68+
69+
[MIT](LICENSE).

code-editor/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![doc = include_str!("../../README.md")]
1+
#![doc = include_str!("../README.md")]
22
#![warn(missing_docs)]
33

44
use dioxus::prelude::*;

dioxus-code-macro/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repository.workspace = true
88
homepage.workspace = true
99
keywords.workspace = true
1010
categories.workspace = true
11-
readme = "../README.md"
11+
readme = "README.md"
1212

1313
[lib]
1414
proc-macro = true

dioxus-code-macro/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<div align="center">
2+
<h1>dioxus-code-macro</h1>
3+
<p><strong>Compile-time syntax highlighting macro for <a href="https://crates.io/crates/dioxus-code">dioxus-code</a>.</strong></p>
4+
</div>
5+
6+
<div align="center">
7+
<a href="https://crates.io/crates/dioxus-code-macro">
8+
<img src="https://img.shields.io/crates/v/dioxus-code-macro.svg?style=flat-square" alt="Crates.io version" />
9+
</a>
10+
<a href="https://crates.io/crates/dioxus-code-macro">
11+
<img src="https://img.shields.io/crates/d/dioxus-code-macro.svg?style=flat-square" alt="Downloads" />
12+
</a>
13+
<a href="https://docs.rs/dioxus-code-macro">
14+
<img src="https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square" alt="docs.rs" />
15+
</a>
16+
</div>
17+
18+
---
19+
20+
Implementation crate for the `code!` macro re-exported by [`dioxus-code`](https://crates.io/crates/dioxus-code) under its default `macro` feature. You usually depend on `dioxus-code` instead of pulling this in directly.
21+
22+
The macro reads a source file at compile time, parses it with [`arborium`](https://crates.io/crates/arborium), and expands to a static span tree. The runtime binary ships only the spans — no parser.
23+
24+
```rust
25+
use dioxus_code::code;
26+
27+
let tree = code!("/snippets/demo.rs");
28+
```
29+
30+
## Path resolution
31+
32+
Paths are resolved relative to the *consumer's* `CARGO_MANIFEST_DIR`. A leading `/` anchors to that directory; bare paths resolve from it as well. `concat!(...)` and `env!(...)` expressions are also accepted.
33+
34+
```rust
35+
code!(concat!(env!("CARGO_MANIFEST_DIR"), "/snippets/demo.rs"));
36+
```
37+
38+
## Explicit language
39+
40+
When the file extension isn't enough to infer the language, pass `language = "..."`:
41+
42+
```rust
43+
code!("/snippets/Containerfile", language = "dockerfile");
44+
```
45+
46+
## License
47+
48+
[MIT](LICENSE).

dioxus-code-macro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![doc = include_str!("../../README.md")]
1+
#![doc = include_str!("../README.md")]
22
#![warn(missing_docs)]
33

44
use std::env;

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ include!(concat!(env!("OUT_DIR"), "/theme_assets.rs"));
5454
/// A parsed source string with its highlighted spans.
5555
///
5656
/// Produced by [`SourceCode::into_tree`] (runtime parsing) or by the
57-
/// [`code!`] macro (compile-time parsing). Pass it to [`Code`] for rendering,
57+
/// [`code!`] macro (compile-time parsing). Pass it to [`Code()`] for rendering,
5858
/// or inspect [`source`](Self::source) and [`spans`](Self::spans) directly.
5959
#[derive(Debug, Clone, PartialEq, Eq)]
6060
pub struct CodeTree {
@@ -221,7 +221,7 @@ fn normalize_spans(spans: impl IntoIterator<Item = Span>) -> Vec<HighlightSpan>
221221
///
222222
/// Available with the `runtime` feature. Build one with [`SourceCode::new`],
223223
/// optionally annotate it with a language or filename, then convert it via
224-
/// [`IntoTree::into_tree`] (or pass it directly to [`Code`]).
224+
/// [`IntoTree::into_tree`] (or pass it directly to [`Code()`]).
225225
#[derive(Debug, Clone, PartialEq, Eq)]
226226
pub struct SourceCode {
227227
source: String,
@@ -350,7 +350,7 @@ impl From<String> for CodeSource {
350350
}
351351
}
352352

353-
/// Pre-parsed source ready to hand to the [`Code`] component.
353+
/// Pre-parsed source ready to hand to the [`Code()`] component.
354354
///
355355
/// Anything implementing [`IntoTree`] — including [`CodeTree`], [`SourceCode`],
356356
/// and (with the `runtime` feature) string types — converts into this via the
@@ -438,7 +438,7 @@ pub struct CodeSpanProps {
438438

439439
/// Render a single highlighted token as `<span class="a-{tag}">{text}</span>`.
440440
///
441-
/// Used internally by [`Code`] but exposed so callers can build their own
441+
/// Used internally by [`Code()`] but exposed so callers can build their own
442442
/// layouts on top of [`HighlightSpan`].
443443
#[component]
444444
pub fn CodeSpan(props: CodeSpanProps) -> Element {
@@ -451,7 +451,7 @@ pub fn CodeSpan(props: CodeSpanProps) -> Element {
451451
}
452452
}
453453

454-
/// Props for [`Code`].
454+
/// Props for [`Code()`].
455455
#[derive(Props, Clone, PartialEq)]
456456
pub struct CodeProps {
457457
/// Source to render. Accepts anything implementing [`IntoTree`].

0 commit comments

Comments
 (0)