Documentation Contribution Guide
This page explains how to write and maintain documentation for EnerOS, including this website (eneros-web) and crate-embedded documentation (cargo doc). EnerOS documentation is a key entry point for users and developers to understand the system; high-quality documentation is as important as high-quality code.
Document Types
EnerOS documentation is divided into the following types by audience and purpose:
| Type | Location | Audience | Writing Style |
|---|---|---|---|
| Concept Docs | src/content/docs/concepts/ | New users | Intuitive, explanatory |
| Quick Start | src/content/docs/quick-start/ | First-time users | Step-by-step, follow-along |
| Architecture Docs | src/content/docs/architecture/ | Architects | Rigorous, structured |
| Capability Docs | src/content/docs/capabilities/ | Integrators | Scenario-based, comparative |
| Tutorials | src/content/docs/tutorials/ | Developers | End-to-end, practical |
| Compliance Docs | src/content/docs/compliance/ | Security & compliance | Rigorous, clause-style |
| ADR | src/content/docs/adr/ | Everyone | Decision record style |
| API Reference | src/content/docs/api-reference/ | Integrators | Concise, reference style |
| Crate Index | src/content/docs/crates/ | API users | Overview style |
| Crate Docs | /// comments + cargo doc | API users | Standard rustdoc |
| Project Docs | docs/ | Everyone | Free-form |
| README | Repository root | New visitors | Overview style |
Document Audience Matrix
Different documents target different readers; clarify the audience before writing:
| Audience | Focus | Recommended Entry |
|---|---|---|
| Decision Makers | Value, ROI, cases | README, concept docs |
| Architects | Design philosophy, scalability | Architecture docs, ADR |
| Integration Developers | API, SDK, configuration | Quick start, API reference |
| Application Developers | Tutorials, examples | Tutorials, capability docs |
| Operations | Deployment, monitoring, HA | Deployment docs, compliance docs |
| Security Compliance | Compliance, auditing | Compliance docs, security sections |
| Contributors | Process, standards | Contributing guide |
Document Structure
Standard Structure
Each document should follow this structure:
- Frontmatter: Metadata (title, description, category, order)
- H1 Heading: Consistent with
title - Lead paragraph: 1-3 sentences explaining the document’s purpose and audience
- Body: Elaborate in sections, using H2 / H3 headings
- Examples: Complete runnable code or configuration
- Checklist: Checkable items for key operations
- Related Documentation: Cross-links
Heading Hierarchy Standards
| Level | Count | Purpose | Example |
|---|---|---|---|
# | 1 (consistent with title) | Document main title | # Testing Standards |
## | 3-8 | Major sections | ## Test Layering |
### | As needed | Subsections | ### Unit Tests |
#### | Use sparingly | Fine-grained sections | #### Naming Conventions |
Rules:
- Do not skip heading levels (don’t jump from
##directly to####) - Keep blank lines before and after headings
- Use nouns or verb-object phrases for headings, avoid questions
- Do not end headings with punctuation
Paragraphs and Lists
- Blank line between paragraphs
- No blank lines between list items (unless items contain multiple paragraphs)
- Use ordered lists for steps, unordered lists for parallel items
- Keep blank lines before and after lists
Frontmatter Standards
All Markdown files must contain frontmatter:
---
title: "Document Title"
description: "One-sentence description" # Optional but recommended
category: "Quick Start" # Must match sidebar group
order: 3 # Sort order within category
---
Field Descriptions
| Field | Required | Type | Description |
|---|---|---|---|
title | Yes | string | Document title, must match the first # Heading |
description | Recommended | string | One-sentence description, used for SEO and card display |
category | Yes | string | Category name, must match sidebar group |
order | Yes | number | Sort order within category, starting from 1 |
Categories and Order
| Category | Document Count | Order Range |
|---|---|---|
| Quick Start | 6 | 1-6 |
| Concepts | 6 | 1-6 |
| Architecture Design | 4 | 1-4 |
| Capabilities | 17 | 1-17 |
| Tutorials | 6 | 1-6 |
| Contributing Guide | 5 | 1-5 |
| Compliance | 6 | 1-6 |
| ADR | As needed | Auto-increment |
| API Reference | 7 | 1-7 |
| Crate | 9 | 1-9 |
Complete Example
---
title: "Testing Standards"
description: "Test layering and cargo test usage"
category: "Contributing Guide"
order: 3
---
# Testing Standards
EnerOS has 7300+ test cases covering all core functionality. This page details test layering, writing standards, and CI process.
## Test Layering
...
Writing Standards
Language
- Primary language: Chinese first
- Proper nouns kept in English: mTLS, SCADA, RTU, IEC 61850, GraphQL, WebSocket, SSE, Token, Cookie
- Abbreviations given full form on first occurrence: Load Flow (PF), Energy Management System (EMS)
- Numbers and units: Arabic numerals + SI units, e.g.,
12ms,100kW,1.06 p.u. - Mixed Chinese-English: Add space between Chinese and English, e.g., “written in Rust”
- Punctuation: Chinese uses full-width punctuation, code and numbers use half-width
Code Blocks
- Must specify language:
```rust,```bash,```toml,```yaml,```json,```sql - Keep blank lines before and after code blocks
- Code examples must be runnable or compilable; avoid pseudocode
- Long code blocks (>30 lines) should be split into multiple, with step-by-step explanations
- Command-line examples use
$prefix or comment explanation
# Install dependencies
sudo apt install -y libssl-dev
# Build the project
cargo build --release
Links
- Internal links use relative paths:
[Testing Standards](/docs/contributing/testing) - Avoid hardcoding domains (except GitHub repository and documentation site homepage)
- Link text should be meaningful, avoid “click here”
- Check link validity, avoid 404
# Correct
See [Testing Standards](/docs/contributing/testing) for details.
# Wrong
See [here](/docs/contributing/testing) for details.
Tables
- Use for comparisons, mappings, parameter descriptions; better than long paragraphs
- Concise headers, each column aligned
- Short cell content, detailed explanations in paragraphs
- Split complex tables into multiple
| Parameter | Type | Default | Description |
|---|---|---|---|
host | string | 0.0.0.0 | Listen address |
port | number | 8080 | Listen port |
workers | number | 4 | Worker thread count |
Emphasis
- Bold: For emphasizing keywords, warnings
- Italic: For first occurrence of terms, foreign words
Inline code: For code identifiers, filenames, commands, parameter names- Avoid overusing emphasis; at most 1-2 per paragraph
Callouts
Use blockquotes for tips, warnings, notes:
> **Tip**: Using `cargo nextest run` is faster than `cargo test`.
> **Warning**: Be sure to change `hmac_key` in `audit.toml` in production environments.
> **Note**: Real-time domain features are fully supported only on Linux.
Example Code Standards
- Must be runnable or compilable; avoid pseudocode and ellipsis
- Do not use
// ...to omit key logic - Include complete
usestatements and imports - Complex examples shown step by step, each step independently verifiable
// Correct: complete example
use eneros_powerflow::{NewtonRaphsonSolver, PowerflowResult};
use eneros_topology::Topology;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let topo = Topology::from_ieee_14bus();
let solver = NewtonRaphsonSolver::new(50, 1e-8);
let result: PowerflowResult = solver.solve(&topo)?;
println!("Converged: {}", result.converged);
Ok(())
}
// Wrong: using ellipsis
// fn main() {
// let topo = ...;
// let result = solver.solve(...);
// ...
// }
Glossary
Key terms on first occurrence should provide full form and abbreviation:
| Chinese | English Full Form | Abbreviation |
|---|---|---|
| 潮流计算 | Power Flow | PF |
| 经济调度 | Economic Dispatch | ED |
| 故障定位隔离与供电恢复 | Fault Detection, Isolation and Service Restoration | FDIR |
| 能量管理系统 | Energy Management System | EMS |
| 监控与数据采集 | Supervisory Control and Data Acquisition | SCADA |
| 配电管理系统 | Distribution Management System | DMS |
| 虚拟电厂 | Virtual Power Plant | VPP |
Crate Embedded Documentation Standards
Doc Comments
Public APIs must have doc comments ///, verified via cargo doc:
/// Solves the load flow equations for a given topology.
///
/// Uses the Newton-Raphson iterative method, with maximum iterations controlled by `max_iterations`.
/// Convergence is considered when the voltage difference between two consecutive iterations is less than `tolerance`.
///
/// # Arguments
/// - `topology`: Grid topology, must have completed island detection
/// - `max_iterations`: Maximum iteration count, recommended 20-50
/// - `tolerance`: Convergence tolerance, default 1e-8
///
/// # Returns
/// Returns [`PowerflowResult`], containing voltage, phase angle, and branch power for each bus.
///
/// # Errors
/// - [`PowerflowError::NonConvergence`]: Iteration count exceeded without convergence
/// - [`PowerflowError::InvalidTopology`]: Topology data incomplete or contains loops
///
/// # Examples
///
/// ```rust
/// use eneros_powerflow::{NewtonRaphsonSolver, PowerflowResult};
/// use eneros_topology::Topology;
///
/// let topo = Topology::from_ieee_14bus();
/// let solver = NewtonRaphsonSolver::new(20, 1e-8);
/// let result: PowerflowResult = solver.solve(&topo).unwrap();
/// assert!(result.converged);
/// ```
pub fn solve(&self, topology: &Topology) -> Result<PowerflowResult> {
unimplemented!()
}
rustdoc Sections
| Section | Purpose | Required |
|---|---|---|
# Arguments | Parameter description | Recommended |
# Returns | Return value description | Recommended |
# Errors | Error condition description | Yes (when returning Result) |
# Panics | Panic condition description | Yes (when may panic) |
# Examples | Runnable examples | Recommended |
# Safety | unsafe safety description | Yes (for unsafe functions) |
# See Also | Related API links | Optional |
Module Documentation
lib.rs and mod.rs should have //! module documentation at the top:
//! # EnerOS Power Flow
//!
//! Grid load flow calculation module, supporting Newton-Raphson and fast decoupled methods.
//!
//! ## Overview
//!
//! - [`NewtonRaphsonSolver`]: Newton-Raphson method, fast convergence but computationally intensive
//! - [`FastDecoupledSolver`]: Fast decoupled method, suitable for distribution networks
//!
//! ## Examples
//!
//! ```rust
//! use eneros_powerflow::NewtonRaphsonSolver;
//! use eneros_topology::Topology;
//!
//! let topo = Topology::from_ieee_14bus();
//! let solver = NewtonRaphsonSolver::new(50, 1e-8);
//! let result = solver.solve(&topo).unwrap();
//! ```
Doc Tests
Example code in cargo doc is executed as tests:
# Run all doc tests
cargo test --doc --workspace
# Run doc tests for a specific crate
cargo test --doc -p eneros-powerflow
Doc test requirements:
- Code must compile
- Use
#to hide unnecessary lines (e.g.,# use ...) - Use
no_runto skip execution but verify compilation:```rust,no_run - Use
ignoreto skip entirely:```rust,ignore - Use
should_panicto verify panic:```rust,should_panic
/// ```rust,no_run
/// # use eneros_powerflow::NewtonRaphsonSolver;
/// // This code will compile but not run
/// let solver = NewtonRaphsonSolver::new(50, 1e-8);
/// ```
Translation Guide
Supported Languages
EnerOS documentation currently supports the following languages:
| Language | Code | Status | Maintainer |
|---|---|---|---|
| Simplified Chinese | zh-CN | Complete | Core team |
| English | en-US | In progress | Community |
| 日本語 | ja-JP | In progress | Community |
| Español | es-ES | Starting | Community |
Translation Process
- Claim a task: Filter by
i18nlabel in GitHub Issues, comment to claim - Base on latest main: Pull the latest code to avoid being out of sync with the original
- Translate: Keep code blocks as-is; only translate comments and explanatory text
- Proofread: Native speaker proofreading to ensure terminology accuracy
- Submit PR: Title prefixed with
[i18n], e.g.,[i18n] Translate testing.md to English
Translation Standards
- Keep code blocks as-is: Do not translate code, commands, configuration, file paths
- Code comments: Can be translated, but keep
//or#prefix - Proper nouns: Keep in English, e.g., mTLS, SCADA, Rust, Cargo
- Links: Internal links unchanged; external links can be replaced with corresponding language versions
- frontmatter: Translate
titleanddescription; keepcategoryandorderunchanged - Terminology consistency: Refer to glossary, maintain consistency with already translated docs
Fluent Localization
The eneros-i18n crate uses Fluent to manage UI text, with translation files in locales/:
locales/
├── en-US.ftl # English
├── zh-CN.ftl # Simplified Chinese
├── ja-JP.ftl # Japanese
└── es-ES.ftl # Spanish
.ftl file example:
# locales/zh-CN.ftl
powerflow-solving = 正在求解潮流...
powerflow-converged = 潮流计算收敛,迭代 { $iterations } 次
powerflow-failed = 潮流计算失败:{ $error }
# locales/en-US.ftl
powerflow-solving = Solving power flow...
powerflow-converged = Power flow converged in { $iterations } iterations
powerflow-failed = Power flow failed: { $error }
Documentation Build and Preview
Local Preview
The EnerOS documentation site is built with Fumadocs using Next.js:
cd eneros-web
npm install
npm run dev # Start dev server, visit http://localhost:3000
Build Production Version
cd eneros-web
npm run build # Build production version
npm run start # Start production server
Common build failure causes:
| Error | Cause | Solution |
|---|---|---|
| frontmatter field type mismatch | order should be number not string | Fix YAML |
| Code block language not specified | ``` missing language identifier | Add rust / bash etc. |
| Relative link 404 | Wrong link path | Fix link path |
| Heading level skip | Jumping from ## to #### | Add intermediate levels |
| frontmatter missing | File doesn’t include --- block | Add frontmatter |
Validate Documentation
# Validate all Markdown files contain frontmatter
cd eneros-web
npm run lint
# Check link validity
npm run check-links
# Type check
npm run typecheck
Cargo Doc Build
# Build all crate documentation
cargo doc --no-deps --all-features
# Build documentation for a specific crate
cargo doc --no-deps -p eneros-powerflow
# Open in browser
cargo doc --no-deps --open
# Build and run doc tests
cargo test --doc --workspace
Deployment
The documentation site is deployed on GitHub Pages, automated by .github/workflows/deploy-web.yml:
| Trigger | Deployment Target | URL |
|---|---|---|
Push to main (affecting eneros-web/) | GitHub Pages | https://www.openeneros.com |
| Create tag | GitHub Release | https://github.com/Gawg-AI/EnerOS/releases |
| Manual trigger | Preview environment | Temporary URL |
ADR Contribution
New architecture decisions must follow the ADR Overview format.
ADR Template
---
title: "ADR 0015: Short Title"
description: "Architecture Decision Record"
category: "ADR"
order: 15
---
# ADR 0015: Short Title
- **Status**: Proposed / Accepted / Deprecated / Superseded
- **Date**: 2026-07-06
- **Decision Makers**: Core team
## Context
(Describe the background, problems, and constraints that prompted this decision)
## Decision
(Describe the specific decision made)
## Alternatives
(List other options considered and their pros and cons)
## Consequences
- **Positive**: ...
- **Negative**: ...
- **Neutral**: ...
## References
- [Related ADR](/docs/adr/0002-power-native-agentos)
- [External Resource](https://example.com)
ADR Submission Process
- Create a new file in
src/content/docs/adr/, with auto-incrementing number - Register in the
src/content/docs/adr/index.mdlist - Submit PR with title
docs(adr): add ADR 0015 ... - At least one architect Review
- Status becomes “Accepted” after merge
Complete Documentation Example
The following is a complete capability document example, demonstrating the application of various standards:
---
title: "Load Flow Capability"
description: "EnerOS Load Flow engine capabilities, interfaces, and examples"
category: "Capabilities"
order: 3
---
# Load Flow Capability
EnerOS provides a high-performance Load Flow (Power Flow) engine, supporting Newton-Raphson and fast decoupled methods, suitable for transmission and distribution network analysis. This page introduces its capabilities, interfaces, and usage examples.
## Supported Solver Methods
| Method | Applicable Scenario | Convergence | Performance |
|--------|---------------------|-------------|-------------|
| Newton-Raphson | Transmission networks, strongly coupled systems | Strong | Medium |
| Fast Decoupled | Distribution networks, radial systems | Medium | High |
| DC Power Flow | Planning, approximate analysis | Weak | Very High |
## API Usage
### Rust API
```rust
use eneros_powerflow::{NewtonRaphsonSolver, PowerflowResult, PowerflowError};
use eneros_topology::Topology;
use std::time::Duration;
fn main() -> Result<(), PowerflowError> {
// Load IEEE 14-bus standard test system
let topo = Topology::from_ieee_14bus();
// Create solver
let solver = NewtonRaphsonSolver::new(50, 1e-8);
// Solve
let result: PowerflowResult = solver.solve(&topo)?;
// Output results
println!("Converged: {}", result.converged);
println!("Iterations: {}", result.iterations);
for bus in &result.buses {
println!(
"Bus {}: V = {:.4} p.u., θ = {:.4} rad",
bus.id, bus.voltage_magnitude, bus.voltage_angle
);
}
Ok(())
}
```
### REST API
```bash
# Solve load flow
curl -X POST http://localhost:8080/api/powerflow/solve \
-H "Content-Type: application/json" \
-d @ieee14.json
# Expected response
# {
# "converged": true,
# "iterations": 4,
# "buses": [
# {"id": 1, "v": 1.06, "theta": 0.0},
# ...
# ]
# }
```
## Performance Metrics
| Test Case | Node Count | Average Latency | Memory Usage |
|-----------|------------|-----------------|--------------|
| IEEE 14-bus | 14 | < 12ms | 2 MB |
| IEEE 30-bus | 30 | < 18ms | 4 MB |
| IEEE 118-bus | 118 | < 45ms | 12 MB |
| IEEE 300-bus | 300 | < 120ms | 28 MB |
## Limitations and Constraints
- Input topology must have completed island detection
- Slack bus must exist and be unique
- Node voltages must be in the [0.5, 1.5] p.u. range
> **Warning**: When load flow does not converge, `PowerflowError::NonConvergence` is returned; the caller should handle this error instead of unwrap.
## Checklist
- [ ] Topology has completed island detection
- [ ] Slack bus is set
- [ ] No duplicate node numbers
- [ ] Impedance parameters are non-zero
## Related Documentation
- [Grid Topology](/docs/capabilities/grid-topology) - Topology engine
- [Security Constraints](/docs/capabilities/physics-constraint) - Constraint engine
- [Load Flow Tutorial](/docs/tutorials/load-flow) - Complete tutorial
- [API Reference](/docs/api-reference/rest) - REST API
Documentation Contribution Checklist
Please check each item before submitting a documentation PR:
- frontmatter is complete (title / description / category / order)
-
titlematches the first# Heading - Heading levels do not skip
- Code blocks specify language
- Code examples are runnable or compilable (no
// ...omissions) - Internal links use relative paths
- Links are valid, no 404
- Table fields are complete, no missing columns
- Spaces between Chinese and English
- Terms given full form on first occurrence
-
npm run buildpasses -
cargo doc --no-depspasses (when crate docs are involved) -
CHANGELOG.mdupdated (if behavior changes are involved)