@@ -211,6 +211,10 @@ typedef enum {
211211 CBM_LANG_CHIALISP , // Chialisp (.clsp/.clib/.clinc — Chia smart-coin s-expression language)
212212 CBM_LANG_PDF , // PDF documents: the text layer, read without a grammar (doc_pdf.c)
213213 CBM_LANG_ASCIIDOC , // AsciiDoc documents, read without a grammar (doc_adoc.c)
214+ CBM_LANG_OPENAPI , // openapi.json / swagger.json: the JSON grammar, no node per key; their
215+ // operations are Routes (openapi.c)
216+ CBM_LANG_DIAGRAM , // diagram files (PlantUML, DOT, D2, draw.io, Excalidraw), read
217+ // without a grammar (diagram.c)
214218 CBM_LANG_COUNT
215219} CBMLanguage ;
216220
@@ -612,6 +616,23 @@ typedef struct {
612616 int cap ;
613617} CBMChannelArray ;
614618
619+ /* One arrow of a diagram (diagram.c): from one DiagramElement definition of
620+ * the file to another, written as a DIAGRAM_ARROW edge. */
621+ typedef struct {
622+ const char * from_qn ;
623+ const char * to_qn ;
624+ const char * label ; /* the arrow's text, NULL for none */
625+ const char * style ; /* what the arrow means as its format writes it: "flow",
626+ * "message", "inherits", "composition", ... */
627+ uint32_t line ;
628+ } CBMDiagramArrow ;
629+
630+ typedef struct {
631+ CBMDiagramArrow * items ;
632+ int count ;
633+ int cap ;
634+ } CBMDiagramArrowArray ;
635+
615636typedef struct {
616637 CBMFieldType * items ;
617638 int count ;
@@ -661,6 +682,7 @@ typedef struct CBMFileResult {
661682 CBMStringRefArray string_refs ; // URL/config string literals from AST
662683 CBMInfraBindingArray infra_bindings ; // topic→URL pairs from IaC configs
663684 CBMChannelArray channels ; // Socket.IO / EventEmitter pub/sub participation
685+ CBMDiagramArrowArray diagram_arrows ; // arrows between the file's DiagramElement defs
664686 CBMFieldTypeArray field_types ; // Python: annotated instance fields (#1277)
665687
666688 const char * module_qn ; // module qualified name
@@ -1122,6 +1144,7 @@ void cbm_infrabinding_push(CBMInfraBindingArray *arr, CBMArena *a, CBMInfraBindi
11221144void cbm_impltrait_push (CBMImplTraitArray * arr , CBMArena * a , CBMImplTrait it );
11231145void cbm_resolvedcall_push (CBMResolvedCallArray * arr , CBMArena * a , CBMResolvedCall rc );
11241146void cbm_channels_push (CBMChannelArray * arr , CBMArena * a , CBMChannel ch );
1147+ void cbm_diagram_arrows_push (CBMDiagramArrowArray * arr , CBMArena * a , CBMDiagramArrow da );
11251148
11261149// --- Sub-extractor entry points ---
11271150
@@ -1140,6 +1163,31 @@ void cbm_extract_type_refs(CBMExtractCtx *ctx);
11401163void cbm_extract_env_accesses (CBMExtractCtx * ctx );
11411164void cbm_extract_type_assigns (CBMExtractCtx * ctx );
11421165void cbm_extract_channels (CBMExtractCtx * ctx );
1166+ /* Diagrams (diagram.c): a Diagram definition per diagram -- a Markdown, reST
1167+ * or AsciiDoc block, or a diagram file -- with a DiagramElement definition per
1168+ * element and the arrows between them. */
1169+ void cbm_extract_diagrams (CBMExtractCtx * ctx );
1170+ /* Is a Markdown block a diagram fence, and the labels its parser reads from
1171+ * it (space-joined; NULL for none): a Section's text keeps those labels in
1172+ * place of the fence (extract_markdown_section_body). */
1173+ bool cbm_diagram_fence_is_diagram (const char * source , TSNode block );
1174+ const char * cbm_diagram_fence_labels (CBMExtractCtx * ctx , TSNode block );
1175+ /* A diagram file (CBM_LANG_DIAGRAM): its format comes from its extension. */
1176+ void cbm_extract_diagram_file (CBMExtractCtx * ctx );
1177+
1178+ /* OpenAPI / Swagger documents (openapi.c): a Route definition per operation and
1179+ * a doc link per operationId. Self-gated: openapi.json / swagger.json, and YAML
1180+ * or JSON files whose root says `openapi` or `swagger`. */
1181+ void cbm_extract_openapi (CBMExtractCtx * ctx );
1182+
1183+ /* Canonicalize route-path parameter placeholders (":id", "{id}", "<id>",
1184+ * "${...}") to a single "{}" token so that client call sites, server handlers
1185+ * and OpenAPI operations rendezvous on the same Route QN regardless of
1186+ * framework syntax. Parameter names are intentionally discarded ("/u/{id}" and
1187+ * "/u/{slug}" both canonicalize to "/u/{}"). The result never exceeds the
1188+ * input length, so out_sz >= strlen(in) + 1 always suffices. Returns out.
1189+ * (route_path.c) */
1190+ const char * cbm_route_canon_path (const char * in , char * out , size_t out_sz );
11431191
11441192// Single-pass unified extraction (replaces the 7 calls above except defs+imports).
11451193void cbm_extract_unified (CBMExtractCtx * ctx );
0 commit comments