Skip to content
Zhen Zhang edited this page Jul 12, 2016 · 10 revisions

We follow the Rust guidelines. Additional Servo-specific conventions follow.

Glob imports

Glob imports are additionally allowed in generated code, since the generator would be much more complex if it had to keep track of this.

Platform specific code

Each crate contains its own platform-specific code - we don't have a single platform abstraction layer for all of servo.

some_crate/mod.rs
some_crate/platform/$(port_name)/mod.rs

$(port_name) is generally the same as a #[cfg(target_os = "...")] string.

If not inside platform, you never access platform::$(port_name)::mod, you access platform::mod. Within the platform module, we use conditional compilation, mostly with #[cfg(target_os = "...")] to make symbols appear in the right place. If we find ourselves with multiple ports for a single os we will use the custom port_name cfg item to identify them and modify the build as appropriate.

DOM code

Specification name == TypeName

Specification method == TypeName::MethodName

Non-standard method == TypeName::method_name

dom/lowercasespecname.rs => implementation

Function/method argument naming

Except for ones for static methods that are called from generated code (everything that takes a GlobalRef argument), the rest should following the Rust style guideline.

See also

Clone this wiki locally