Skip to content

Commit 30444aa

Browse files
committed
wip rust ext
1 parent 9ee2cb6 commit 30444aa

File tree

11 files changed

+767
-0
lines changed

11 files changed

+767
-0
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
- name: Install doxygen
4343
run: sudo apt-get install -y doxygen
4444

45+
- name: Clean up problematic directories
46+
run: rm -rf docs/jupyter_execute
47+
4548
- name: Install dependencies
4649
run: make develop
4750

docs/src/api.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,30 @@ Or document specific classes with `doxygenclass`:
5252
:members:
5353
```
5454

55+
## Rust Example
56+
57+
This is an example of documenting Rust code using sphinx-rust integration.
58+
59+
### Document a Crate
60+
61+
Use `rust:crate` to document an entire Rust crate:
62+
63+
```rust:crate calculator
64+
```
65+
66+
### Document Individual Items
67+
68+
Or document specific structs, enums, and functions:
69+
70+
```rust:struct calculator::Calculator
71+
```
72+
73+
```rust:struct calculator::ScientificCalculator
74+
```
75+
76+
```rust:enum calculator::Operation
77+
```
78+
79+
```rust:enum calculator::CalculatorError
80+
```
81+

examples/rust/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target/
2+
Cargo.lock

examples/rust/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "calculator"
3+
version = "0.1.0"
4+
edition = "2021"
5+
description = "A simple calculator library demonstrating Rust documentation"
6+
license = "Apache-2.0"
7+
8+
[lib]
9+
name = "calculator"
10+
path = "src/lib.rs"

examples/rust/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Calculator Library (Rust)
2+
3+
A simple calculator library demonstrating Rust documentation with sphinx-rust.
4+
5+
## Features
6+
7+
- Basic arithmetic operations (add, subtract, multiply, divide)
8+
- Scientific calculator with trigonometric and logarithmic functions
9+
- Operation history tracking
10+
- Full Rust documentation with examples
11+
12+
## Usage
13+
14+
```rust
15+
use calculator::{Calculator, Operation};
16+
17+
fn main() {
18+
let mut calc = Calculator::new();
19+
20+
// Basic operations
21+
let sum = calc.add(5.0, 3.0);
22+
println!("5 + 3 = {}", sum);
23+
24+
let product = calc.multiply(4.0, 7.0);
25+
println!("4 * 7 = {}", product);
26+
27+
// View history
28+
for result in calc.history() {
29+
println!("{}", result);
30+
}
31+
}
32+
```
33+
34+
## Scientific Calculator
35+
36+
```rust
37+
use calculator::ScientificCalculator;
38+
39+
fn main() {
40+
let mut sci = ScientificCalculator::new();
41+
sci.set_use_degrees(true);
42+
43+
println!("sin(90°) = {}", sci.sin(90.0));
44+
println!("sqrt(16) = {}", sci.sqrt(16.0));
45+
println!("2^10 = {}", sci.pow(2.0, 10.0));
46+
}
47+
```

0 commit comments

Comments
 (0)