Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0c7ca34
doc-links(go): Go doc links become MENTIONS edges, held until their a…
DeusData Oct 10, 2026
a1190af
doc-links(java, kotlin): Javadoc and KDoc references become MENTIONS …
DeusData Oct 10, 2026
3af25b4
doc-links(rust): intra-doc links become MENTIONS edges, held until th…
DeusData Oct 10, 2026
ef5359e
extract(perl): a module's POD that no sub holds is its File node's doc
DeusData Oct 10, 2026
f4277ae
doc-links(perl): POD L<> codes become MENTIONS edges, held until thei…
DeusData Oct 10, 2026
196ca71
doc-links(ts): JSDoc and TSDoc links become MENTIONS edges, held unti…
DeusData Oct 10, 2026
7a321ca
doc-links(php): PHPDoc @see references become MENTIONS edges, held un…
DeusData Oct 10, 2026
80e000a
doc-links(c): Doxygen @ref and @see names become MENTIONS edges, held…
DeusData Oct 10, 2026
2fdcbfe
doc-links(php): a property's, constant's or case's doc block belongs …
DeusData Oct 10, 2026
c5c400a
doc-links(php): a bare name() in a type's doc is the type's method
DeusData Oct 10, 2026
06e69d0
doc-links(ts): bare specifiers through tsconfig paths and workspace p…
DeusData Oct 10, 2026
f4a49fe
feat(docs): diagrams and OpenAPI operations in the graph
DeusData Oct 11, 2026
1dd84d7
fix(doclinks): removed declarations repair incrementally in TS, PHP, …
DeusData Oct 11, 2026
d65f5f9
Merge main into feat/doc-links-languages-diagrams
DeusData Oct 11, 2026
abf6558
feat(docs): a section's text keeps its diagram's labels, not its syntax
DeusData Oct 11, 2026
78eace4
doc-links: ship the doc-comment families that passed their held-out a…
DeusData Oct 11, 2026
75b98a4
Merge main into feat/doc-links-languages-diagrams
DeusData Oct 11, 2026
72b8176
feat(docs): a diagram section's candidates carry its diagram family's p
DeusData Oct 11, 2026
ae2a7f8
Merge main 1691be73 into feat/doc-links-languages-diagrams
DeusData Oct 11, 2026
65d365e
test(doc-links jvm): a variable named far does not compile on Windows
DeusData Oct 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Makefile.cbm
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,16 @@ EXTRACTION_SRCS = \
$(CBM_DIR)/pdf/pdf_text.c \
$(CBM_DIR)/pdf/pdf_tables.c \
$(CBM_DIR)/pdf/pdf_unicode.c \
$(CBM_DIR)/doclink_go.c \
$(CBM_DIR)/doclink_jvm.c \
$(CBM_DIR)/doclink_rs.c \
$(CBM_DIR)/doclink_perl.c \
$(CBM_DIR)/doclink_ts.c \
$(CBM_DIR)/doclink_php.c \
$(CBM_DIR)/doclink_c.c \
$(CBM_DIR)/diagram.c \
$(CBM_DIR)/route_path.c \
$(CBM_DIR)/openapi.c \
$(CBM_DIR)/sql_values.c \
$(CBM_DIR)/helpers.c \
$(CBM_DIR)/cpp_branch_views.c \
Expand Down Expand Up @@ -512,6 +522,14 @@ PIPELINE_SRCS = \
src/pipeline/doc_links_pdf.c \
src/pipeline/doc_links_rst.c \
src/pipeline/doc_links_adoc.c \
src/pipeline/doc_links_go.c \
src/pipeline/doc_links_jvm.c \
src/pipeline/doc_links_rs.c \
src/pipeline/doc_links_perl.c \
src/pipeline/doc_links_ts.c \
src/pipeline/doc_links_php.c \
src/pipeline/doc_links_c.c \
src/pipeline/pass_diagrams.c \
src/pipeline/doc_links_msbuild.c \
src/pipeline/pass_route_nodes.c \
src/pipeline/pass_enrichment.c \
Expand Down Expand Up @@ -774,7 +792,7 @@ TEST_DISCOVER_SRCS = \

TEST_GRAPH_BUFFER_SRCS = tests/test_graph_buffer.c

TEST_PIPELINE_SRCS = tests/test_registry.c tests/test_pipeline.c tests/test_pipeline_conventions.c tests/test_pipeline_frozen.c tests/test_importance.c tests/test_cross_repo.c tests/test_fqn.c tests/test_route_canon.c tests/test_path_alias.c tests/test_configlink.c tests/test_doclinks.c tests/test_doc_mentions.c tests/test_doc_links_md.c tests/test_doc_links_pdf.c tests/test_doc_links_rst.c tests/test_doc_links_adoc.c tests/test_infrascan.c tests/test_worker_pool.c tests/test_parallel.c tests/test_index_resilience.c tests/test_index_format.c tests/test_call_reference_contract.c tests/repro/repro_call_scope_usages.c tests/repro/repro_call_argument_usages.c tests/repro/repro_reference_precision.c tests/repro/repro_lexical_binding_precision.c tests/repro/repro_call_argument_matrix_a.c tests/repro/repro_call_argument_matrix_b.c tests/repro/repro_call_node_behaviors.c tests/repro/repro_language_registry.c tests/repro/repro_call_node_manifest.c tests/repro/repro_lsp_ordered_signatures.c tests/repro/repro_lsp_ordered_local.c tests/repro/repro_ts_overload_return_chains.c tests/repro/repro_harness_cleanup.c tests/repro/repro_runner_filter.c
TEST_PIPELINE_SRCS = tests/test_registry.c tests/test_pipeline.c tests/test_pipeline_conventions.c tests/test_pipeline_frozen.c tests/test_importance.c tests/test_cross_repo.c tests/test_fqn.c tests/test_route_canon.c tests/test_path_alias.c tests/test_configlink.c tests/test_doclinks.c tests/test_doc_mentions.c tests/test_doc_links_md.c tests/test_doc_links_pdf.c tests/test_doc_links_rst.c tests/test_doc_links_adoc.c tests/test_doc_mentions_go.c tests/test_doc_mentions_jvm.c tests/test_doc_mentions_rs.c tests/test_doc_mentions_perl.c tests/test_doc_mentions_ts.c tests/test_doc_mentions_php.c tests/test_doc_mentions_c.c tests/test_diagrams.c tests/test_openapi.c tests/test_infrascan.c tests/test_worker_pool.c tests/test_parallel.c tests/test_index_resilience.c tests/test_index_format.c tests/test_call_reference_contract.c tests/repro/repro_call_scope_usages.c tests/repro/repro_call_argument_usages.c tests/repro/repro_reference_precision.c tests/repro/repro_lexical_binding_precision.c tests/repro/repro_call_argument_matrix_a.c tests/repro/repro_call_argument_matrix_b.c tests/repro/repro_call_node_behaviors.c tests/repro/repro_language_registry.c tests/repro/repro_call_node_manifest.c tests/repro/repro_lsp_ordered_signatures.c tests/repro/repro_lsp_ordered_local.c tests/repro/repro_ts_overload_return_chains.c tests/repro/repro_harness_cleanup.c tests/repro/repro_runner_filter.c

TEST_WATCHER_SRCS = tests/test_watcher.c

Expand Down
31 changes: 31 additions & 0 deletions internal/cbm/cbm.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ void cbm_channels_push(CBMChannelArray *arr, CBMArena *a, CBMChannel ch) {
arr->items[arr->count++] = ch;
}

void cbm_diagram_arrows_push(CBMDiagramArrowArray *arr, CBMArena *a, CBMDiagramArrow da) {
GROW_ARRAY(arr, a);
arr->items[arr->count++] = da;
}

// --- String input reader (for parse_with_options) ---

typedef struct {
Expand Down Expand Up @@ -2837,6 +2842,26 @@ static CBMFileResult *extract_file_ex_body(const char *source, int source_len, C
.module_qn = result->module_qn,
};
cbm_adoc_extract_document(&adoc_ctx);
cbm_extract_diagrams(&adoc_ctx); /* after the Sections they hang under */
cbm_index_mark_done(rel_path);
return result;
}
/* Diagram files have no grammar either: each format is read from the text
* (diagram.c). */
if (language == CBM_LANG_DIAGRAM) {
result->module_qn = cbm_fqn_module_source_lang(a, project, rel_path, language);
CBMExtractCtx diagram_ctx = {
.arena = a,
.scratch = scratch,
.result = result,
.source = source,
.source_len = source_len,
.language = language,
.project = project,
.rel_path = rel_path,
.module_qn = result->module_qn,
};
cbm_extract_diagram_file(&diagram_ctx);
cbm_index_mark_done(rel_path);
return result;
}
Expand Down Expand Up @@ -3021,6 +3046,12 @@ static CBMFileResult *extract_file_ex_body(const char *source, int source_len, C
// Channel detection (Socket.IO / EventEmitter) — JS/TS only.
cbm_extract_channels(&ctx);

// Diagrams: blocks of documents and diagram files (self-gated by language).
cbm_extract_diagrams(&ctx);

// OpenAPI operations as Routes (self-gated: API description documents).
cbm_extract_openapi(&ctx);

// K8s / Kustomize semantic pass (additional structured extraction for YAML-based infra files).
if (ctx.language == CBM_LANG_KUSTOMIZE || ctx.language == CBM_LANG_K8S) {
cbm_extract_k8s(&ctx);
Expand Down
48 changes: 48 additions & 0 deletions internal/cbm/cbm.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ typedef enum {
CBM_LANG_CHIALISP, // Chialisp (.clsp/.clib/.clinc — Chia smart-coin s-expression language)
CBM_LANG_PDF, // PDF documents: the text layer, read without a grammar (doc_pdf.c)
CBM_LANG_ASCIIDOC, // AsciiDoc documents, read without a grammar (doc_adoc.c)
CBM_LANG_OPENAPI, // openapi.json / swagger.json: the JSON grammar, no node per key; their
// operations are Routes (openapi.c)
CBM_LANG_DIAGRAM, // diagram files (PlantUML, DOT, D2, draw.io, Excalidraw), read
// without a grammar (diagram.c)
CBM_LANG_COUNT
} CBMLanguage;

Expand Down Expand Up @@ -612,6 +616,23 @@ typedef struct {
int cap;
} CBMChannelArray;

/* One arrow of a diagram (diagram.c): from one DiagramElement definition of
* the file to another, written as a DIAGRAM_ARROW edge. */
typedef struct {
const char *from_qn;
const char *to_qn;
const char *label; /* the arrow's text, NULL for none */
const char *style; /* what the arrow means as its format writes it: "flow",
* "message", "inherits", "composition", ... */
uint32_t line;
} CBMDiagramArrow;

typedef struct {
CBMDiagramArrow *items;
int count;
int cap;
} CBMDiagramArrowArray;

typedef struct {
CBMFieldType *items;
int count;
Expand Down Expand Up @@ -661,6 +682,7 @@ typedef struct CBMFileResult {
CBMStringRefArray string_refs; // URL/config string literals from AST
CBMInfraBindingArray infra_bindings; // topic→URL pairs from IaC configs
CBMChannelArray channels; // Socket.IO / EventEmitter pub/sub participation
CBMDiagramArrowArray diagram_arrows; // arrows between the file's DiagramElement defs
CBMFieldTypeArray field_types; // Python: annotated instance fields (#1277)

const char *module_qn; // module qualified name
Expand Down Expand Up @@ -1122,6 +1144,7 @@ void cbm_infrabinding_push(CBMInfraBindingArray *arr, CBMArena *a, CBMInfraBindi
void cbm_impltrait_push(CBMImplTraitArray *arr, CBMArena *a, CBMImplTrait it);
void cbm_resolvedcall_push(CBMResolvedCallArray *arr, CBMArena *a, CBMResolvedCall rc);
void cbm_channels_push(CBMChannelArray *arr, CBMArena *a, CBMChannel ch);
void cbm_diagram_arrows_push(CBMDiagramArrowArray *arr, CBMArena *a, CBMDiagramArrow da);

// --- Sub-extractor entry points ---

Expand All @@ -1140,6 +1163,31 @@ void cbm_extract_type_refs(CBMExtractCtx *ctx);
void cbm_extract_env_accesses(CBMExtractCtx *ctx);
void cbm_extract_type_assigns(CBMExtractCtx *ctx);
void cbm_extract_channels(CBMExtractCtx *ctx);
/* Diagrams (diagram.c): a Diagram definition per diagram -- a Markdown, reST
* or AsciiDoc block, or a diagram file -- with a DiagramElement definition per
* element and the arrows between them. */
void cbm_extract_diagrams(CBMExtractCtx *ctx);
/* Is a Markdown block a diagram fence, and the labels its parser reads from
* it (space-joined; NULL for none): a Section's text keeps those labels in
* place of the fence (extract_markdown_section_body). */
bool cbm_diagram_fence_is_diagram(const char *source, TSNode block);
const char *cbm_diagram_fence_labels(CBMExtractCtx *ctx, TSNode block);
/* A diagram file (CBM_LANG_DIAGRAM): its format comes from its extension. */
void cbm_extract_diagram_file(CBMExtractCtx *ctx);

/* OpenAPI / Swagger documents (openapi.c): a Route definition per operation and
* a doc link per operationId. Self-gated: openapi.json / swagger.json, and YAML
* or JSON files whose root says `openapi` or `swagger`. */
void cbm_extract_openapi(CBMExtractCtx *ctx);

/* Canonicalize route-path parameter placeholders (":id", "{id}", "<id>",
* "${...}") to a single "{}" token so that client call sites, server handlers
* and OpenAPI operations rendezvous on the same Route QN regardless of
* framework syntax. Parameter names are intentionally discarded ("/u/{id}" and
* "/u/{slug}" both canonicalize to "/u/{}"). The result never exceeds the
* input length, so out_sz >= strlen(in) + 1 always suffices. Returns out.
* (route_path.c) */
const char *cbm_route_canon_path(const char *in, char *out, size_t out_sz);

// Single-pass unified extraction (replaces the 7 calls above except defs+imports).
void cbm_extract_unified(CBMExtractCtx *ctx);
Expand Down
Loading
Loading