Index the named =head / =item sections of one POD block. */
| 2573 | |
| 2574 | /* Index the named =head / =item sections of one POD block. */ |
| 2575 | static void pod_index_block(CBMExtractCtx *ctx, pod_index_t *ix, TSNode pod) { |
| 2576 | CBMArena *a = doc_scratch(ctx); |
| 2577 | uint32_t pb = ts_node_start_byte(pod); |
| 2578 | uint32_t pe = ts_node_end_byte(pod); |
| 2579 | pod_cmd_t *cmds = NULL; |
| 2580 | int n = pod_commands(a, ctx->source, pb, pe, &cmds); |
| 2581 | for (int ci = 0; ci < n; ci++) { |
| 2582 | if (cmds[ci].type != POD_HEAD && cmds[ci].type != POD_ITEM) { |
| 2583 | continue; |
| 2584 | } |
| 2585 | const char *nm = NULL; |
| 2586 | size_t nl = pod_heading_name(a, ctx->source, cmds[ci].wb, cmds[ci].eb, &nm); |
| 2587 | if (nl == 0) { |
| 2588 | continue; |
| 2589 | } |
| 2590 | uint32_t se = pod_section_end(cmds, n, ci, pe); |
| 2591 | pod_sec_t sec = {nm, nl, cmds[ci].sb, pod_trim_end(ctx->source, cmds[ci].sb, se), false}; |
| 2592 | pod_index_push(a, ix, &sec); |
| 2593 | } |
| 2594 | } |
| 2595 | |
| 2596 | /* The file's POD sections by name, built on the first Perl sub (or for the |
| 2597 | * module doc of a file without one). */ |
no test coverage detected