| 146 | } |
| 147 | |
| 148 | static void php_push(const php_emit_t *em, const char *ref, size_t n, uint32_t line) { |
| 149 | while (n > 0 && (ref[n - SKIP_ONE] == '.' || ref[n - SKIP_ONE] == ',' || |
| 150 | ref[n - SKIP_ONE] == ';' || ref[n - SKIP_ONE] == ':')) { |
| 151 | n--; /* sentence punctuation */ |
| 152 | } |
| 153 | if (n == 0) { |
| 154 | return; |
| 155 | } |
| 156 | if (n > CBM_DOCLINK_PHP_REF_MAX) { |
| 157 | n = CBM_DOCLINK_PHP_REF_MAX + SKIP_ONE; /* clipped: the resolver calls it unparseable */ |
| 158 | } |
| 159 | int syntax = php_is_url(ref, n) ? CBM_DOCLINK_HREF : CBM_DOCLINK_PHP_SEE; |
| 160 | char *copy = cbm_arena_strndup(em->ctx->arena, ref, n); |
| 161 | if (!copy) { |
| 162 | return; |
| 163 | } |
| 164 | CBMDocLink link = { |
| 165 | .source_qn = em->def->qualified_name, |
| 166 | .raw = copy, |
| 167 | .line = line, |
| 168 | .def_line = em->def->start_line, |
| 169 | .syntax = (uint16_t)syntax, |
| 170 | }; |
| 171 | cbm_doclinks_push(&em->ctx->result->doc_links, em->ctx->arena, link); |
| 172 | } |
| 173 | |
| 174 | /* One doc line: its text after the leading `*`, and its source line. */ |
| 175 | typedef struct { |
no test coverage detected