use crate::bounded::Overflow;
use crate::token::{GeneratedDelimiter, GeneratedToken, documentation, group};
const MODULE_PRELUDE_ROOT: &str = "super";
const MODULE_SENTENCE: &str = "The canonical encode and decode roads for one declared shape, \
published here rather than spliced beside the declaration. Its head imports the scope the \
module sits in, which is where the shape's own names live.";
pub(super) fn published_module(
spelling: &str,
surface: Vec<GeneratedToken>,
) -> Result<Vec<GeneratedToken>, Overflow> {
let mut body = vec![
GeneratedToken::word("use"),
GeneratedToken::word(MODULE_PRELUDE_ROOT),
GeneratedToken::joint(':'),
GeneratedToken::alone(':'),
GeneratedToken::alone('*'),
GeneratedToken::alone(';'),
];
body.extend(surface);
let mut tokens = documentation(MODULE_SENTENCE)?;
tokens.push(GeneratedToken::word("pub"));
tokens.push(GeneratedToken::word("mod"));
tokens.push(GeneratedToken::word(spelling));
tokens.push(group(GeneratedDelimiter::Brace, body)?);
Ok(tokens)
}