#![allow(dead_code)]
use thag_profiler::internal_doc;
pub fn public_api_function() {
println!("This function is part of the public API");
}
#[internal_doc]
pub fn internal_utility_with_macro() {
println!("This function is internal and uses the macro");
}
#[cfg_attr(not(feature = "internal_docs"), doc(hidden))]
pub fn internal_utility_with_manual_attribute() {
println!("This function is internal and uses the manual attribute");
}
fn private_implementation_detail() {
println!("This function is private and only visible with --document-private-items");
}
pub struct ExampleStruct {
pub public_field: String,
private_field: i32,
}
impl ExampleStruct {
#[must_use]
pub const fn new(value: String) -> Self {
Self {
public_field: value,
private_field: 42,
}
}
#[internal_doc]
pub fn internal_method(&self) {
println!("Internal method: {}", self.public_field);
}
#[cfg_attr(not(feature = "internal_docs"), doc(hidden))]
pub fn another_internal_method(&self) {
println!("Another internal method: {}", self.private_field);
}
fn private_method(&self) {
println!("Private method: {}", self.private_field);
}
}
#[internal_doc]
pub mod internal_utilities {
pub fn helper_function() {
println!("Helper function in internal module");
}
}
#[cfg_attr(not(feature = "internal_docs"), doc(hidden))]
pub mod more_internal_utilities {
pub fn another_helper_function() {
println!("Another helper function in internal module");
}
}
mod private_module {
pub fn private_module_function() {
println!("Function in private module");
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_public_api() {
public_api_function();
let example = ExampleStruct::new("test".to_string());
assert_eq!(example.public_field, "test");
}
#[test]
fn test_internal_functions() {
internal_utility_with_macro();
internal_utility_with_manual_attribute();
let example = ExampleStruct::new("test".to_string());
example.internal_method();
example.another_internal_method();
}
}
fn main() {
println!("Documentation attributes example");
public_api_function();
internal_utility_with_macro();
internal_utility_with_manual_attribute();
let example = ExampleStruct::new("example".to_string());
example.internal_method();
example.another_internal_method();
internal_utilities::helper_function();
more_internal_utilities::another_helper_function();
println!("Example completed successfully!");
}