Skip to content

Commit 239bf74

Browse files
committed
Refactor documentation headings and content for clarity and conciseness.
1 parent c0785b2 commit 239bf74

18 files changed

+1790
-747
lines changed

docsite/docs/basic-patterns.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,8 @@ fn with_optional_block(data: String, block: Option<Proc>) -> Result<String, Erro
642642

643643
<div className="success-message">
644644

645-
### 🎉 Patterns Mastered!
645+
### Patterns Mastered
646646

647-
You now know the essential patterns for building Ruby extensions with Rust. Practice these patterns to build robust, efficient extensions!
647+
You now know the essential patterns for building Ruby extensions with Rust. Practice these patterns to build robust, efficient extensions.
648648

649649
</div>

docsite/docs/contributing.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,10 @@ Every contribution matters:
445445

446446
<div className="success-message">
447447

448-
### 🎉 Ready to Contribute?
448+
### Ready to Contribute?
449449

450450
Check out our [good first issues](https://github.com/oxidize-rb/rb-sys/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) to get started!
451451

452-
Join our [Slack](https://join.slack.com/t/oxidize-rb/shared_invite/zt-16zv5tqte-Vi7WfzxCesdo2TqF_RYBCw) to say hello!
452+
Join our [Slack](https://join.slack.com/t/oxidize-rb/shared_invite/zt-16zv5tqte-Vi7WfzxCesdo2TqF_RYBCw) to discuss ideas.
453453

454454
</div>

docsite/docs/cookbook.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,8 @@ impl RangeIterator {
529529

530530
<div className="success-message">
531531

532-
### 🍳 More Recipes Coming!
532+
### More Recipes Coming
533533

534-
Have a pattern you'd like to see? [Open an issue](https://github.com/oxidize-rb/rb-sys/issues) or contribute your own!
534+
Have a pattern you'd like to see? [Open an issue](https://github.com/oxidize-rb/rb-sys/issues) or contribute your own.
535535

536536
</div>

docsite/docs/core-concepts.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ graph TB
4646
4747
style A fill:#CC342D,color:#fff
4848
style B fill:#000,color:#fff
49-
style C fill:#CE422B,color:#fff
50-
style D fill:#f9f9f9
49+
style C fill:#D99A6C,color:#fff
50+
style D fill:#545B69,color:#fff
5151
style E fill:#CC342D,color:#fff
5252
style F fill:#CC342D,color:#fff
5353
```
@@ -434,8 +434,8 @@ Now that you understand the core concepts:
434434

435435
<div className="success-message">
436436

437-
### 🧠 Understanding Complete!
437+
### Understanding Complete
438438

439-
You now have a solid foundation in rb-sys core concepts. Ready to build amazing extensions!
439+
You now have a solid foundation in rb-sys core concepts. Ready to build extensions.
440440

441441
</div>

docsite/docs/faq.mdx

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,13 @@ Find answers to common questions about building Ruby extensions with Rust.
1616

1717
**A:** Consider Rust when you need:
1818

19-
**Good fit for Rust:**
2019
- CPU-intensive algorithms (parsing, compression, cryptography)
2120
- Memory-intensive operations (image processing, data transformation)
2221
- System-level integration (OS APIs, hardware access)
2322
- Concurrent/parallel processing
2423
- Security-critical code
2524
- Wrapping existing Rust libraries
2625

27-
**Keep in Ruby:**
28-
- Simple business logic
29-
- Database queries (use Ruby's ORM)
30-
- Web framework code
31-
- Glue code between services
32-
- Anything that's "fast enough" in Ruby
33-
3426
### Q: Is Rust harder to learn than C?
3527

3628
**A:** Different, not necessarily harder:
@@ -45,24 +37,24 @@ Find answers to common questions about building Ruby extensions with Rust.
4537
- Better error messages
4638
- Modern tooling (Cargo, rustfmt, clippy)
4739
- Comprehensive standard library
48-
- Amazing documentation
40+
- Good documentation
4941

5042
Most developers find Rust's learning curve worth it for the safety guarantees.
5143

5244
### Q: How much faster will my code be?
5345

54-
**A:** It depends on what you're doing:
46+
**A:** It depends on what you're doing.
5547

5648
- **CPU-bound operations**: Often 10-100x faster
5749
- **Memory allocation heavy**: 5-20x faster
5850
- **String processing**: 5-50x faster
5951
- **Simple operations**: May be slower due to FFI overhead
6052

61-
**Remember:** With Ruby's YJIT, pure Ruby is faster than ever. Profile first!
53+
With Ruby's YJIT, pure Ruby is faster than ever. Profile first.
6254

6355
### Q: Will this work with Rails?
6456

65-
**A:** Yes! rb-sys extensions work perfectly with Rails:
57+
**A:** Yes, rb-sys extensions work with Rails.
6658

6759
```ruby
6860
# Gemfile
@@ -83,7 +75,7 @@ Many production Rails apps use Rust extensions for performance-critical paths.
8375

8476
### Q: How do I debug Rust extensions?
8577

86-
**A:** Several approaches:
78+
**A:** There are several approaches:
8779

8880
**1. Print debugging:**
8981
```rust
@@ -121,7 +113,7 @@ gdb --args ruby -r ./lib/my_extension.rb -e "MyExtension.method"
121113

122114
### Q: How do I handle Ruby version compatibility?
123115

124-
**A:** rb-sys provides version detection:
116+
**A:** rb-sys provides version detection.
125117

126118
```rust
127119
// In build.rs
@@ -145,7 +137,7 @@ fn ruby2_compat() {
145137

146138
### Q: Can I use async/await in Ruby extensions?
147139

148-
**A:** Yes, but you need to properly handle async runtimes. Since Ruby extensions are synchronous, you'll need to block on async code:
140+
**A:** Yes, but you need to properly handle async runtimes. Since Ruby extensions are synchronous, you'll need to block on async code.
149141

150142
```rust
151143
use magnus::{Error, Ruby};
@@ -196,7 +188,7 @@ fn parallel_operation(data: Vec<u8>) -> Result<Vec<u8>, Error> {
196188

197189
### Q: How do I distribute my gem?
198190

199-
**A:** Multiple strategies:
191+
**A:** There are multiple strategies:
200192

201193
**1. Source gems (easiest):**
202194
```ruby
@@ -238,18 +230,18 @@ jobs:
238230
239231
### Q: Why is my extension slower than expected?
240232
241-
**A:** Common causes:
233+
**A:** There are common causes:
242234
243235
**1. Too many conversions:**
244236
```rust
245237
use magnus::{Error, RArray, TryConvert};
246238

247-
// Bad: Converts entire array upfront
239+
// Bad: Converts entire array upfront
248240
fn sum(numbers: Vec<i64>) -> i64 {
249241
numbers.iter().sum()
250242
}
251243

252-
// Good: Iterates without conversion
244+
// Good: Iterates without conversion
253245
fn sum_good(array: RArray) -> Result<i64, Error> {
254246
let mut total = 0;
255247
for item in array.each() {
@@ -262,7 +254,7 @@ fn sum_good(array: RArray) -> Result<i64, Error> {
262254
**2. Not releasing the GVL:**
263255
```rust
264256
fn release_gvl_example(data: &[u8]) {
265-
// Release GVL for operations > 100ms
257+
// Release GVL for operations > 100ms
266258
if data.len() > 1_000_000 {
267259
// Use rb_thread_call_without_gvl
268260
}
@@ -272,13 +264,13 @@ fn release_gvl_example(data: &[u8]) {
272264
**3. Excessive allocations:**
273265
```rust
274266
fn excessive_allocations() {
275-
// Bad: Allocates repeatedly
267+
// Bad: Allocates repeatedly
276268
for i in 0..1000 {
277269
let mut vec: Vec<i32> = Vec::new();
278270
// ...
279271
}
280272

281-
// Good: Reuse allocation
273+
// Good: Reuse allocation
282274
let mut vec: Vec<i32> = Vec::with_capacity(1000);
283275
for i in 0..1000 {
284276
vec.clear();
@@ -289,7 +281,7 @@ fn excessive_allocations() {
289281

290282
### Q: How do I profile my extension?
291283

292-
**A:** Use cargo's built-in profiling:
284+
**A:** Use cargo's built-in profiling.
293285

294286
```bash
295287
# Add to Cargo.toml
@@ -355,7 +347,7 @@ impl Drop for TempFile {
355347

356348
### Q: Can I share memory between Ruby and Rust?
357349

358-
**A:** Yes, but carefully:
350+
**A:** Yes, but carefully.
359351

360352
```rust
361353
use magnus::{Error, RString};
@@ -383,17 +375,17 @@ impl SharedBuffer {
383375

384376
### Q: How should I handle panics?
385377

386-
**A:** Avoid them entirely:
378+
**A:** Avoid them entirely.
387379

388380
```rust
389381
use magnus::{Error, exception};
390382

391-
// Bad: Panics crash Ruby
383+
// Bad: Panics crash Ruby
392384
fn bad_function(index: usize, data: Vec<String>) -> String {
393385
data[index].clone() // Panics on out of bounds
394386
}
395387

396-
// Good: Return errors
388+
// Good: Return errors
397389
fn good_function(index: usize, data: Vec<String>) -> Result<String, Error> {
398390
data.get(index)
399391
.cloned()
@@ -422,15 +414,15 @@ fn safe_wrapper() -> Result<(), Error> {
422414

423415
### Q: Do users need Rust installed?
424416

425-
**A:** Depends on distribution method:
417+
**A:** It depends on the distribution method:
426418

427419
- **Source gems**: Yes, users need Rust
428420
- **Pre-compiled gems**: No, includes compiled binary
429421
- **Bundled with vendored**: No, but larger gem size
430422

431423
### Q: How do I support multiple platforms?
432424

433-
**A:** Use rb-sys's cross-compilation:
425+
**A:** Use rb-sys's cross-compilation.
434426

435427
```bash
436428
# Install cross-compilation tool
@@ -445,7 +437,7 @@ gem install rb_sys
445437

446438
### Q: What about Ruby version compatibility?
447439

448-
**A:** rb-sys handles most differences:
440+
**A:** rb-sys handles most differences.
449441

450442
```toml
451443
# Cargo.toml
@@ -459,15 +451,15 @@ gem install rb_sys
459451

460452
### Q: "undefined symbol" errors?
461453

462-
**A:** Common causes:
454+
**A:** There are common causes:
463455

464456
1. **Missing rb-sys dependency**
465457
2. **Wrong library type in Cargo.toml** - use `crate-type = ["cdylib"]`
466458
3. **Name mismatch** between Rust and Ruby
467459

468460
### Q: "libclang not found" during installation?
469461

470-
**A:** Install libclang:
462+
**A:** Install libclang.
471463

472464
```bash
473465
# macOS
@@ -482,7 +474,7 @@ gem install libclang
482474

483475
### Q: Extension works locally but fails in production?
484476

485-
**A:** Check:
477+
**A:** Check the following:
486478

487479
1. **Platform compatibility** - build for production architecture
488480
2. **Ruby version** - ensure compatibility
@@ -493,7 +485,7 @@ gem install libclang
493485

494486
### Q: Where can I get help?
495487

496-
**A:** Multiple resources:
488+
**A:** There are multiple resources:
497489

498490
1. **[Oxidize Slack](https://join.slack.com/t/oxidize-rb/shared_invite/zt-16zv5tqte-Vi7WfzxCesdo2TqF_RYBCw)** - Active community
499491
2. **[GitHub Discussions](https://github.com/oxidize-rb/rb-sys/discussions)** - Q&A forum
@@ -502,7 +494,7 @@ gem install libclang
502494

503495
### Q: How can I contribute?
504496

505-
**A:** We love contributions!
497+
**A:** We welcome contributions.
506498

507499
- **Documentation**: Fix typos, add examples
508500
- **Code**: Fix bugs, add features
@@ -515,8 +507,8 @@ See our [Contributing Guide](contributing) for details.
515507

516508
<div className="success-message">
517509

518-
### 🤝 Still Have Questions?
510+
### Still Have Questions?
519511

520-
Join our [Slack community](https://join.slack.com/t/oxidize-rb/shared_invite/zt-16zv5tqte-Vi7WfzxCesdo2TqF_RYBCw) - we're happy to help!
512+
Join our [Slack community](https://join.slack.com/t/oxidize-rb/shared_invite/zt-16zv5tqte-Vi7WfzxCesdo2TqF_RYBCw) - we are happy to help.
521513

522-
</div>
514+
</div>

0 commit comments

Comments
 (0)