Skip to content

Commit cb8946c

Browse files
committed
wip
1 parent 3e7f376 commit cb8946c

35 files changed

Lines changed: 2421 additions & 0 deletions

.github/workflows/docs.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Docs
2+
on: [push, pull_request]
3+
4+
jobs:
5+
test:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- uses: dtolnay/rust-toolchain@stable
10+
- run: cargo build
11+
- run: cargo test
12+
- uses: peaceiris/actions-mdbook@v1
13+
with:
14+
mdbook-version: '0.4.40'
15+
- run: mdbook test book -L ./target/debug/deps
16+
17+
publish:
18+
if: github.ref == 'refs/heads/main'
19+
needs: test
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: write
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: dtolnay/rust-toolchain@stable
26+
- run: cargo build
27+
- uses: peaceiris/actions-mdbook@v1
28+
with:
29+
mdbook-version: '0.4.40'
30+
- run: mdbook build book
31+
- uses: peaceiris/actions-gh-pages@v4
32+
with:
33+
github_token: ${{ secrets.GITHUB_TOKEN }}
34+
publish_dir: ./book/book

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ result*
77

88
# Generated by pre-commit hooks (from Nix dev shell)
99
/.pre-commit-config.yaml
10+
11+
# mdBook build output
12+
/book/book/

CONTRIBUTING.md

Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,291 @@
1+
# Contributing to ros-z
2+
3+
Thank you for your interest in contributing to ros-z! This document provides guidelines and workflows for contributors.
4+
5+
## Getting Started
6+
7+
### Prerequisites
8+
9+
1. **Rust toolchain**: Install via [rustup](https://rustup.rs/)
10+
2. **Nix** (optional but recommended): For reproducible development environment
11+
3. **mdbook**: For documentation (included in nix environment)
12+
13+
### Setting Up Your Development Environment
14+
15+
#### Using Nix (Recommended)
16+
17+
```bash
18+
# Clone the repository
19+
git clone https://github.com/ZettaScaleLabs/ros-z.git
20+
cd ros-z
21+
22+
# Enter the development shell (includes all dependencies)
23+
nix develop
24+
# or if direnv is installed
25+
direnv allow
26+
```
27+
28+
#### Without Nix
29+
30+
```bash
31+
# Install Rust
32+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
33+
34+
# Install mdbook
35+
cargo install mdbook
36+
37+
# Install other dependencies as needed
38+
```
39+
40+
## Development Workflow
41+
42+
### 1. Build the Project
43+
44+
```bash
45+
# Build the entire workspace
46+
cargo build
47+
48+
# Build specific packages
49+
cargo build -p ros-z
50+
cargo build -p ros-z-msgs
51+
```
52+
53+
### 2. Run Tests
54+
55+
```bash
56+
# Run all tests
57+
cargo test
58+
59+
# Run tests for specific package
60+
cargo test -p ros-z
61+
62+
# Run integration tests
63+
cargo test -p ros-z-tests --features ros-msgs
64+
```
65+
66+
### 3. Test Documentation
67+
68+
When making changes to examples or documentation:
69+
70+
```bash
71+
# Build the library first (required for mdbook test)
72+
cargo build
73+
74+
# Test all code examples in the book
75+
mdbook test book -L ./target/debug/deps
76+
77+
# Preview the book locally
78+
mdbook serve book
79+
```
80+
81+
Open <http://localhost:3000> to see the rendered documentation.
82+
83+
## Pre-Commit Checklist
84+
85+
Before submitting changes, ensure all of these pass:
86+
87+
```bash
88+
# 1. Build succeeds
89+
cargo build
90+
91+
# 2. All tests pass
92+
cargo test
93+
94+
# 3. Documentation examples work (if examples changed)
95+
mdbook test book -L ./target/debug/deps
96+
97+
# 4. Code is formatted
98+
cargo fmt
99+
100+
# 5. No clippy warnings
101+
cargo clippy --all-targets --all-features
102+
```
103+
104+
If you're using the Nix environment, pre-commit hooks will automatically run these checks.
105+
106+
## Making Changes
107+
108+
### Adding New Features
109+
110+
When adding a new ros-z feature:
111+
112+
1. **Implement** the feature in `ros-z/src/`
113+
2. **Add an example** to `ros-z/examples/` demonstrating the feature
114+
3. **Update documentation**:
115+
- Add or update book chapter in `book/src/chapters/`
116+
- Use `{{#include ../../ros-z/examples/your_example.rs}}` to reference the example
117+
- Update `book/src/SUMMARY.md` if adding a new chapter
118+
4. **Test everything**:
119+
```bash
120+
cargo build
121+
cargo test
122+
mdbook test book -L ./target/debug/deps
123+
```
124+
125+
### Updating Existing Features
126+
127+
When changing existing APIs:
128+
129+
1. **Update** the implementation in `ros-z/src/`
130+
2. **Update** affected examples in `ros-z/examples/`
131+
3. **Update** book chapters with new explanations (if needed)
132+
4. **Run tests** to ensure everything still works
133+
5. Make all changes in a **single commit**: "feat: new API + examples + docs"
134+
135+
### Documentation Guidelines
136+
137+
Documentation in ros-z follows a specific pattern:
138+
139+
#### Examples are the Single Source of Truth
140+
141+
- All code examples live in `ros-z/examples/` as complete, runnable programs
142+
- Book chapters reference these examples using `{{#include}}` directives
143+
- **Never** write inline code blocks >5 lines in markdown files
144+
- Examples must compile and pass `mdbook test`
145+
146+
#### Example Template
147+
148+
Every example should follow this pattern:
149+
150+
```rust
151+
use ros_z::prelude::*;
152+
153+
fn main() -> Result<()> {
154+
// Your example code here
155+
let ctx = ZContextBuilder::default().build()?;
156+
let node = ctx.create_node("example").build()?;
157+
// ... rest of example
158+
Ok(())
159+
}
160+
```
161+
162+
For examples that should also work as library functions (testable), use:
163+
164+
```rust
165+
pub fn run_example(ctx: ZContext, /* other params */) -> Result<()> {
166+
// Implementation here
167+
}
168+
169+
#[cfg(not(any(test, doctest)))]
170+
fn main() -> Result<()> {
171+
// CLI argument parsing
172+
let ctx = ZContextBuilder::default().build()?;
173+
run_example(ctx /* pass params */)
174+
}
175+
```
176+
177+
#### Book Chapter Template
178+
179+
```markdown
180+
# Feature Name
181+
182+
Brief introduction to the feature.
183+
184+
## Complete Example
185+
186+
\`\`\`rust,no_run
187+
{{#include ../../../ros-z/examples/your_example.rs}}
188+
\`\`\`
189+
190+
## Key Points
191+
192+
- **Line X**: Explanation of important line
193+
- **Line Y**: Another important detail
194+
195+
## Usage
196+
197+
\`\`\`bash
198+
cargo run --example your_example
199+
\`\`\`
200+
```
201+
202+
### Code Style
203+
204+
- Follow Rust standard formatting: `cargo fmt`
205+
- Run clippy and fix warnings: `cargo clippy`
206+
- Write clear, self-documenting code
207+
- Add comments for complex logic
208+
- Use descriptive variable names
209+
210+
### Commit Messages
211+
212+
Follow conventional commit format:
213+
214+
- `feat: add new feature`
215+
- `fix: resolve bug in X`
216+
- `docs: update documentation for Y`
217+
- `refactor: restructure Z`
218+
- `test: add tests for W`
219+
- `chore: update dependencies`
220+
221+
## Submitting Changes
222+
223+
1. **Fork** the repository
224+
2. **Create a branch** from `main` with a descriptive name
225+
3. **Make your changes** following the guidelines above
226+
4. **Test thoroughly** using the pre-commit checklist
227+
5. **Commit** with clear, conventional commit messages
228+
6. **Push** to your fork
229+
7. **Open a Pull Request** with:
230+
- Clear description of changes
231+
- Reference to related issues (if any)
232+
- Screenshots/examples (if applicable)
233+
234+
## Pull Request Process
235+
236+
1. Ensure all CI checks pass
237+
2. Request review from maintainers
238+
3. Address review feedback
239+
4. Once approved, maintainers will merge
240+
241+
## Project Structure
242+
243+
```
244+
ros-z/
245+
├── ros-z/ # Core library
246+
│ ├── src/ # Production code
247+
│ └── examples/ # Runnable examples (used by book)
248+
├── ros-z-msgs/ # Generated message types
249+
├── ros-z-codegen/ # Code generation utilities
250+
├── rcl-z/ # RCL C bindings
251+
├── ros-z-tests/ # Integration tests
252+
├── book/ # mdBook documentation
253+
│ ├── book.toml # mdBook configuration
254+
│ └── src/ # Book chapters
255+
└── .github/workflows/ # CI/CD
256+
```
257+
258+
## Maintenance Rules
259+
260+
### If-Then Flows
261+
262+
**IF adding new ros-z feature:**
263+
- ADD `examples/new_feature.rs`
264+
- ADD/UPDATE book chapter with `{{#include}}`
265+
- RUN `cargo build && mdbook test book -L ./target/debug/deps`
266+
267+
**IF making API breaking change:**
268+
- UPDATE `examples/*.rs` files
269+
- UPDATE book text references
270+
- Single commit: "feat: new API + examples + docs"
271+
272+
**IF mdbook test fails:**
273+
- RUN `cargo clean && cargo build`
274+
- CHECK `target/debug/deps` contains `libros_z-*.rlib`
275+
- RE-RUN `mdbook test book -L ./target/debug/deps`
276+
277+
## Getting Help
278+
279+
- **Questions**: Open a [GitHub Discussion](https://github.com/ZettaScaleLabs/ros-z/discussions)
280+
- **Bugs**: Open a [GitHub Issue](https://github.com/ZettaScaleLabs/ros-z/issues)
281+
- **Chat**: Join the [Zenoh Discord](https://discord.gg/vSDSpqnbkm)
282+
283+
## License
284+
285+
By contributing to ros-z, you agree that your contributions will be licensed under the same license as the project (see LICENSE file).
286+
287+
## Code of Conduct
288+
289+
Be respectful, inclusive, and professional in all interactions. We're all here to make ROS 2 better!
290+
291+
Thank you for contributing to ros-z! 🦀

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@ better.
3030
be interoperable with ROS 2 Rolling, but we make no guarantees with respect to
3131
official distributions.
3232

33+
## Documentation
34+
35+
Comprehensive documentation with examples is available:
36+
37+
- **Online**: [ros-z Documentation](https://zettascalelabs.github.io/ros-z/) (GitHub Pages)
38+
- **Local**: Build and view locally with `mdbook serve book` (see [book/README.md](book/README.md))
39+
40+
The documentation includes:
41+
- Getting started guide
42+
- Publisher/subscriber examples
43+
- Service examples
44+
- Demo nodes compatible with ROS 2
45+
- API reference
46+
47+
For contributing to the documentation, see [CONTRIBUTING.md](CONTRIBUTING.md).
48+
3349
## Building
3450

3551
ROS-Z is designed to work without ROS dependencies by default.

0 commit comments

Comments
 (0)