domingo, 2 de julio de 2023

Rustdoc


Todos los elementos de Lenguaje Rust se pueden documentar usando una sintaxis especial ///.

/// Determine whether the first argument is divisible by the second argument.

///

/// If the second argument is zero, the result is false.

fn is_divisible_by(lhs: u32, rhs: u32) -> bool {

    if rhs == 0 {

        return false;  // Corner case, early return

    }

    lhs % rhs == 0     // The last expression in a block is the return value

}


Los contenidos se tratan como Markdown. Las librerias de Rust se documentan automáticamente en docs.rs mediante la herramienta rustdoc. Es idiomático documentar todos los elementos públicos en una API utilizando este patrón.

Y para utilizarla podemos hacer : 

rustdoc src/main.rs 



No hay comentarios.:

Publicar un comentario