cc: Convert functions containing a dot
@@ -138,19 +138,12 @@ fn consume_tokens(tokens: &[RefToken]) -> (usize, String) {
}
[Word("@note"), Whitespace(" "), ..] => (2, "Note: ".into()),
[Word("@return"), Whitespace(_), Word(_), ..] => (2, "Returns: ".into()),
- [Word(word), Separator("()"), ..] => {
- // Looks like a function reference.
- if let Some(sk_ref) = sk_reference(word) {
- let reference = convert_reference(sk_ref);
- return (2, format!("[`{reference}()`]"));
- }
- if let Some(gr_ref) = gr_reference(word) {
- let reference = convert_reference(gr_ref);
- return (2, format!("[`{reference}()`]"));
- }
- let function_name = word.to_snake_case();
- (2, format!("`{function_name}()`"))
+
+ [Word(word_a), Separator("."), Word(word_b), Separator("()"), ..] => {
+ // Function reference with a dot.
+ process_function(4, &format!("{word_a}.{word_b}"))
}
+ [Word(word), Separator("()"), ..] => process_function(2, word),
[Word(word), ..] => {
if let Some(sk_ref) = sk_reference(word) {
let reference = convert_reference(sk_ref);
@@ -185,6 +178,20 @@ fn consume_tokens(tokens: &[RefToken]) -> (usize, String) {
}
}
+fn process_function(consumed: usize, word: &str) -> (usize, String) {
+ // Looks like a function reference.
+ if let Some(sk_ref) = sk_reference(word) {
+ let reference = convert_reference(sk_ref);
+ return (consumed, format!("[`{reference}()`]"));
+ }
+ if let Some(gr_ref) = gr_reference(word) {
+ let reference = convert_reference(gr_ref);
+ return (consumed, format!("[`{reference}()`]"));
+ }
+ let function_name = word.to_snake_case();
+ (consumed, format!("`{function_name}()`"))
+}
+
fn consume_until_ws(tokens: &[RefToken]) -> (usize, String) {
let mut r = String::new();
